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

Comparing deliantra/Deliantra-Client/DC.pm (file contents):
Revision 1.48 by root, Tue Apr 25 11:18:48 2006 UTC vs.
Revision 1.49 by root, Sun Apr 30 08:09:44 2006 UTC

28 28
29our %GL_EXT; 29our %GL_EXT;
30our $GL_VERSION; 30our $GL_VERSION;
31 31
32our $GL_NPOT; 32our $GL_NPOT;
33our $GL_DEBUG = 1;
33 34
34sub gl_init { 35sub gl_init {
35 $GL_VERSION = gl_version * 1; 36 $GL_VERSION = gl_version * 1;
36 %GL_EXT = map +($_ => 1), split /\s+/, gl_extensions; 37 %GL_EXT = map +($_ => 1), split /\s+/, gl_extensions;
37 38
38 $GL_NPOT = $GL_EXT{GL_ARB_texture_non_power_of_two} || $GL_VERSION >= 2; 39 $GL_NPOT = $GL_EXT{GL_ARB_texture_non_power_of_two} || $GL_VERSION >= 2;
39 40
40 glEnable GL_TEXTURE_2D;
41 glEnable GL_COLOR_MATERIAL; 41 glDisable GL_COLOR_MATERIAL;
42 glShadeModel GL_FLAT; 42 glShadeModel GL_FLAT;
43 glDisable GL_DITHER;
43 glDisable GL_DEPTH_TEST; 44 glDisable GL_DEPTH_TEST;
44 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
45
46 glHint GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST; 45 glHint GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST;
47 46
48 CFClient::Texture::restore_state (); 47 CFClient::Texture::restore_state ();
48}
49
50sub gl_check {
51 return unless $GL_DEBUG;
52
53 if (my $error = glGetError) {
54 Carp::cluck sprintf "opengl error %x while %s", $error, sprintf @_;
55 }
49} 56}
50 57
51sub find_rcfile($) { 58sub find_rcfile($) {
52 my $path; 59 my $path;
53 60
298 $tw, $th, # need to pad texture first 305 $tw, $th, # need to pad texture first
299 0, 306 0,
300 $self->{format}, 307 $self->{format},
301 $self->{type}, 308 $self->{type},
302 $data; 309 $data;
303 if (my $error = glGetError) { 310 CFClient::gl_check "uploading texture %dx%d if=%x f=%x t=%x",
304 Carp::cluck sprintf "texture upload error: %x %dx%d i=%x f=%x t=%x",
305 $error, $tw, $th, $self->{internalformat}, $self->{format}, $self->{type}; 311 $tw, $th, $self->{internalformat}, $self->{format}, $self->{type};
306 }
307 } else { 312 } else {
308 glCopyTexImage2D GL_TEXTURE_2D, 0, 313 glCopyTexImage2D GL_TEXTURE_2D, 0,
309 $self->{internalformat}, 314 $self->{internalformat},
310 0, 0, 315 0, 0,
311 $tw, $th, 316 $tw, $th,
312 0; 317 0;
313 if (my $error = glGetError) { 318 CFClient::gl_check "copying to texture %dx%d if=%x",
314 Carp::cluck sprintf "texture upload error: %x %dx%d i=%x",
315 $error, $tw, $th, $self->{internalformat}; 319 $tw, $th, $self->{internalformat};
316 }
317 } 320 }
318} 321}
319 322
320sub DESTROY { 323sub DESTROY {
321 my ($self) = @_; 324 my ($self) = @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines