ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/OpenGL.pm
Revision: 1.3
Committed: Sat Jun 17 15:07:53 2006 UTC (18 years ago) by root
Branch: MAIN
Changes since 1.2: +7 -0 lines
Log Message:
free textures on vidoe shutdown, seems useless, but maybe fixes scaras problem

File Contents

# User Rev Content
1 root 1.1 package CFClient::OpenGL;
2    
3     use strict;
4    
5 root 1.2 use Carp ();
6     use CFClient;
7    
8     our %GL_EXT;
9     our $GL_VERSION;
10    
11     our $GL_NPOT;
12    
13     our $DEBUG = 1;
14     our %INIT_HOOK;
15 root 1.3 our %SHUTDOWN_HOOK;
16 root 1.1
17     sub import {
18     my $caller = caller;
19    
20     no strict;
21    
22     my $symtab = *{"main::CFClient::OpenGL::"}{HASH};
23    
24     for (keys %$symtab) {
25 root 1.2 *{"$caller\::$_"} = *$_
26     if /^(?:gl[A-Z_]|GL_)/;
27 root 1.1 }
28     }
29    
30 root 1.2 sub init {
31     $GL_VERSION = gl_version * 1;
32     %GL_EXT = map +($_ => 1), split /\s+/, gl_extensions;
33    
34     $GL_NPOT = $GL_EXT{GL_ARB_texture_non_power_of_two} || $GL_VERSION >= 2;
35     $GL_NPOT = 0 if gl_vendor =~ /ATI Technologies/; # ATI doesn't get it right...
36    
37     glDisable GL_COLOR_MATERIAL;
38     glShadeModel GL_FLAT;
39     glDisable GL_DITHER;
40     glDisable GL_DEPTH_TEST;
41     glDepthMask 0;
42     glHint GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST;
43 root 1.3 glDrawBuffer GL_BACK;
44     glReadBuffer GL_BACK;
45 root 1.2
46     $_->() for values %INIT_HOOK;
47     }
48    
49 root 1.3 sub shutdown {
50     $_->() for values %SHUTDOWN_HOOK;
51     }
52    
53 root 1.2 sub gl_check {
54     return unless $DEBUG;
55    
56     if (my $error = glGetError) {
57     my ($format, @args) = @_;
58     Carp::cluck sprintf "opengl error %x while $format", $error, @args;
59     }
60     }
61    
62     1;
63