1 | package CFPlus::OpenGL; |
1 | package DC::OpenGL; |
2 | |
2 | |
3 | use strict; |
3 | use strict; |
4 | |
4 | |
5 | use Carp (); |
5 | use Carp (); |
6 | use CFPlus; |
6 | use DC; |
7 | |
7 | |
8 | our %GL_EXT; |
8 | our %GL_EXT; |
9 | our $GL_VERSION; |
9 | our $GL_VERSION; |
10 | |
10 | |
11 | our $GL_NPOT; |
11 | our $GL_NPOT; |
12 | our $GL_COMPRESS; |
12 | our $GL_COMPRESS; |
13 | our $GL_BFSEP; # blendfuncseparate |
13 | our $GL_BFSEP; # blendfuncseparate |
|
|
14 | our $APPLE_NVIDIA_BUG; |
14 | |
15 | |
15 | our $DEBUG = 1; |
16 | our $DEBUG = 1; |
16 | our %INIT_HOOK; |
17 | our %INIT_HOOK; |
17 | our %SHUTDOWN_HOOK; |
18 | our %SHUTDOWN_HOOK; |
18 | |
19 | |
19 | sub import { |
20 | sub import { |
20 | my $caller = caller; |
21 | my $caller = caller; |
21 | |
22 | |
22 | no strict; |
23 | no strict; |
23 | |
24 | |
24 | my $symtab = *{"main::CFPlus::OpenGL::"}{HASH}; |
25 | my $symtab = *{"main::DC::OpenGL::"}{HASH}; |
25 | |
26 | |
26 | for (keys %$symtab) { |
27 | for (keys %$symtab) { |
27 | *{"$caller\::$_"} = *$_ |
28 | *{"$caller\::$_"} = *$_ |
28 | if /^(?:gl[A-Z_]|GL_)/; |
29 | if /^(?:gl[A-Z_]|GL_)/; |
29 | } |
30 | } |
… | |
… | |
52 | } |
53 | } |
53 | |
54 | |
54 | $GL_BFSEP = $GL_EXT{GL_EXT_blend_func_separate} || $GL_VERSION >= 2.0; |
55 | $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; |
56 | $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; |
57 | $GL_COMPRESS = $GL_EXT{GL_ARB_texture_compression} || $GL_VERSION >= 1.3; |
|
|
58 | |
|
|
59 | $GL_COMPRESS = 0 if DC::OpenGL::gl_vendor eq "Apple Computer, Inc."; # there is no end to their suckage |
|
|
60 | |
|
|
61 | $APPLE_NVIDIA_BUG = DC::OpenGL::gl_vendor eq "NVIDIA Corporation" && $^O eq "darwin"; |
|
|
62 | apple_nvidia_bug $APPLE_NVIDIA_BUG; |
57 | |
63 | |
58 | disable_GL_EXT_blend_func_separate |
64 | disable_GL_EXT_blend_func_separate |
59 | unless $GL_BFSEP; |
65 | unless $GL_BFSEP; |
60 | |
66 | |
61 | glDisable GL_COLOR_MATERIAL; |
67 | glDisable GL_COLOR_MATERIAL; |