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.42 by root, Fri Apr 21 07:09:10 2006 UTC vs.
Revision 1.43 by root, Fri Apr 21 07:19:56 2006 UTC

19 19
20 use XSLoader; 20 use XSLoader;
21 XSLoader::load "CFClient", $VERSION; 21 XSLoader::load "CFClient", $VERSION;
22} 22}
23 23
24use Carp ();
24use AnyEvent; 25use AnyEvent;
25use BerkeleyDB; 26use BerkeleyDB;
26use CFClient::OpenGL; 27use CFClient::OpenGL;
27 28
28our %GL_EXT; 29our %GL_EXT;
255 unless ($GL_NPOT) { 256 unless ($GL_NPOT) {
256 # TODO: does not work for zero-sized textures 257 # TODO: does not work for zero-sized textures
257 $tw = topot $tw; 258 $tw = topot $tw;
258 $th = topot $th; 259 $th = topot $th;
259 260
260 if ($tw != $self->{w} || $th != $self->{h} && defined $data) { 261 if (($tw != $self->{w} || $th != $self->{h}) && defined $data) {
261 my $bpp = (length $data) / ($self->{w} * $self->{h}); 262 my $bpp = (length $data) / ($self->{w} * $self->{h});
262 $data = pack "(a" . ($tw * $bpp) . ")*", 263 $data = pack "(a" . ($tw * $bpp) . ")*",
263 unpack "(a" . ($self->{w} * $bpp) . ")*", $data; 264 unpack "(a" . ($self->{w} * $bpp) . ")*", $data;
264 $data .= ("\x00" x ($tw * $bpp)) x ($th - $self->{h}); 265 $data .= ("\x00" x ($tw * $bpp)) x ($th - $self->{h});
265 } 266 }
293 0, 294 0,
294 $self->{format}, 295 $self->{format},
295 $self->{type}, 296 $self->{type},
296 $data; 297 $data;
297 if (my $error = glGetError) { 298 if (my $error = glGetError) {
298 warn sprintf "texture upload error: %x %dx%d i=%x f=%x t=%x\n", 299 Carp::cluck sprintf "texture upload error: %x %dx%d i=%x f=%x t=%x",
299 $error, $tw, $th, $self->{internalformat}, $self->{format}, $self->{type}; 300 $error, $tw, $th, $self->{internalformat}, $self->{format}, $self->{type};
300 } 301 }
301 } else { 302 } else {
302 glCopyTexImage2D GL_TEXTURE_2D, 0, 303 glCopyTexImage2D GL_TEXTURE_2D, 0,
303 $self->{internalformat}, 304 $self->{internalformat},
304 0, 0, 305 0, 0,
305 $tw, $th, 306 $tw, $th,
306 0; 307 0;
307 glGetError and die "glCopyTexImage2D $tw,$th"; 308 if (my $error = glGetError) {
309 Carp::cluck sprintf "texture upload error: %x %dx%d i=%x",
310 $error, $tw, $th, $self->{internalformat};
311 }
308 } 312 }
309} 313}
310 314
311sub DESTROY { 315sub DESTROY {
312 my ($self) = @_; 316 my ($self) = @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines