ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/OpenGL.pm
Revision: 1.7
Committed: Thu Aug 9 05:38:30 2007 UTC (16 years, 10 months ago) by root
Branch: MAIN
Changes since 1.6: +2 -1 lines
Log Message:
disable npot on <2.0 opengl cards as those might announce support for it
but then fall back to software rendering once you use mipmapping and other
stuff.

File Contents

# User Rev Content
1 root 1.4 package CFPlus::OpenGL;
2 root 1.1
3     use strict;
4    
5 root 1.2 use Carp ();
6 root 1.4 use CFPlus;
7 root 1.2
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 root 1.4 my $symtab = *{"main::CFPlus::OpenGL::"}{HASH};
23 root 1.1
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 root 1.7 # $GL_NPOT = $GL_EXT{GL_ARB_texture_non_power_of_two} || $GL_VERSION >= 2;
35     $GL_NPOT = $GL_VERSION >= 2; # some pre-2.0 cards seem to fall back to software rendering
36 root 1.2 $GL_NPOT = 0 if gl_vendor =~ /ATI Technologies/; # ATI doesn't get it right...
37    
38     glDisable GL_COLOR_MATERIAL;
39     glShadeModel GL_FLAT;
40     glDisable GL_DITHER;
41     glDisable GL_DEPTH_TEST;
42     glDepthMask 0;
43 root 1.5
44     my $hint = $::FAST ? GL_FASTEST : GL_NICEST;
45     glHint GL_PERSPECTIVE_CORRECTION_HINT, $hint;
46 root 1.6 glHint GL_POINT_SMOOTH_HINT , $hint;
47 root 1.5 glHint GL_LINE_SMOOTH_HINT , $hint;
48     glHint GL_POLYGON_SMOOTH_HINT , $hint;
49     glHint GL_GENERATE_MIPMAP_HINT , $hint;
50     #glDrawBuffer GL_BACK;
51     #glReadBuffer GL_BACK;
52 root 1.2
53     $_->() for values %INIT_HOOK;
54     }
55    
56 root 1.3 sub shutdown {
57     $_->() for values %SHUTDOWN_HOOK;
58     }
59    
60 root 1.2 sub gl_check {
61     return unless $DEBUG;
62    
63     if (my $error = glGetError) {
64     my ($format, @args) = @_;
65     Carp::cluck sprintf "opengl error %x while $format", $error, @args;
66     }
67     }
68    
69     1;
70