ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/OpenGL.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/OpenGL.pm (file contents):
Revision 1.13 by root, Wed Dec 26 20:46:39 2007 UTC vs.
Revision 1.21 by root, Sat Apr 3 02:58:25 2010 UTC

1package dc::OpenGL; 1package DC::OpenGL;
2 2
3use strict; 3use common::sense;
4 4
5use Carp (); 5use Carp ();
6use dc; 6use DC;
7 7
8our %GL_EXT; 8our %GL_EXT;
9our $GL_VERSION; 9our $GL_VERSION;
10 10
11our $GL_NPOT; 11our $GL_NPOT;
12our $GL_COMPRESS; 12our $GL_COMPRESS;
13our $GL_BFSEP; # blendfuncseparate 13our $GL_BFSEP; # blendfuncseparate
14our $GL_MULTITEX;
15our $APPLE_NVIDIA_BUG;
14 16
15our $DEBUG = 1; 17our $DEBUG = 1;
16our %INIT_HOOK; 18our %INIT_HOOK;
17our %SHUTDOWN_HOOK; 19our %SHUTDOWN_HOOK;
18 20
19sub import { 21sub import {
20 my $caller = caller; 22 my $caller = caller;
21 23
22 no strict;
23
24 my $symtab = *{"main::dc::OpenGL::"}{HASH}; 24 my $symtab = *{"main::DC::OpenGL::"}{HASH};
25 25
26 for (keys %$symtab) { 26 for (keys %$symtab) {
27 *{"$caller\::$_"} = *$_ 27 *{"$caller\::$_"} = *$_
28 if /^(?:gl[A-Z_]|GL_)/; 28 if /^(?:gl[A-Z_]|GL_)/;
29 } 29 }
37 # try to find a suitable default 37 # try to find a suitable default
38 if ( 38 if (
39 $GL_VERSION >= 2.0 39 $GL_VERSION >= 2.0
40 && (!$GL_EXT{GL_ARB_texture_non_power_of_two} 40 && (!$GL_EXT{GL_ARB_texture_non_power_of_two}
41 || !$GL_EXT{GL_EXT_blend_func_separate}) 41 || !$GL_EXT{GL_EXT_blend_func_separate})
42 ) { 42 ) {
43 $::CFG->{force_opengl11} = 1; 43 $::CFG->{force_opengl11} = 1;
44 } else { 44 } else {
45 $::CFG->{force_opengl11} = 0; 45 $::CFG->{force_opengl11} = 0;
46 } 46 }
47 } 47 }
48 48
49 if ($::CFG->{force_opengl11}) { 49 if ($::CFG->{force_opengl11}) {
50 $GL_VERSION = 1.1; 50 $GL_VERSION = 1.1;
51 %GL_EXT = (); 51 %GL_EXT = ();
52 } 52 }
53 53
54 $GL_BFSEP = $GL_EXT{GL_EXT_blend_func_separate} || $GL_VERSION >= 2.0; 54 $GL_BFSEP = $GL_EXT{GL_EXT_blend_func_separate} || $GL_VERSION >= 2.0;
55 $GL_NPOT = $GL_EXT{GL_ARB_texture_non_power_of_two} || $GL_VERSION >= 2.0; 55 $GL_NPOT = $GL_EXT{GL_ARB_texture_non_power_of_two} || $GL_VERSION >= 2.0;
56 $GL_COMPRESS = $GL_EXT{GL_ARB_texture_compression} || $GL_VERSION >= 1.3; 56 $GL_COMPRESS = $GL_EXT{GL_ARB_texture_compression} || $GL_VERSION >= 1.3;
57 $GL_MULTITEX = $GL_EXT{GL_ARB_multitexture} || $GL_VERSION >= 1.3;
58 $GL_MULTITEX &&= 2 <= glGetInteger GL_MAX_TEXTURE_UNITS;
59
60 $GL_COMPRESS = 0 if DC::OpenGL::gl_vendor eq "Apple Computer, Inc."; # there is no end to their suckage
61
62 $APPLE_NVIDIA_BUG = DC::OpenGL::gl_vendor eq "NVIDIA Corporation" && $^O eq "darwin";
63 apple_nvidia_bug $APPLE_NVIDIA_BUG;
57 64
58 disable_GL_EXT_blend_func_separate 65 disable_GL_EXT_blend_func_separate
59 unless $GL_BFSEP; 66 unless $GL_BFSEP;
60 67
61 glDisable GL_COLOR_MATERIAL; 68 glDisable GL_COLOR_MATERIAL;
72 glHint GL_GENERATE_MIPMAP_HINT , $hint; 79 glHint GL_GENERATE_MIPMAP_HINT , $hint;
73 glHint GL_TEXTURE_COMPRESSION_HINT , $hint; 80 glHint GL_TEXTURE_COMPRESSION_HINT , $hint;
74 #glDrawBuffer GL_BACK; 81 #glDrawBuffer GL_BACK;
75 #glReadBuffer GL_BACK; 82 #glReadBuffer GL_BACK;
76 83
84 c_init;
77 $_->() for values %INIT_HOOK; 85 $_->() for values %INIT_HOOK;
78} 86}
79 87
80sub quit { 88sub quit {
81 undef $GL_VERSION; 89 undef $GL_VERSION;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines