… | |
… | |
355 | glGetError; |
355 | glGetError; |
356 | |
356 | |
357 | if (defined $data) { |
357 | if (defined $data) { |
358 | glTexImage2D GL_TEXTURE_2D, 0, |
358 | glTexImage2D GL_TEXTURE_2D, 0, |
359 | $self->{internalformat}, |
359 | $self->{internalformat}, |
360 | $tw, $th, # need to pad texture first |
360 | $tw, $th, |
361 | 0, |
361 | 0, |
362 | $self->{format}, |
362 | $self->{format}, |
363 | $self->{type}, |
363 | $self->{type}, |
364 | $data; |
364 | $data; |
365 | CFClient::gl_check "uploading texture %dx%d if=%x f=%x t=%x", |
365 | CFClient::gl_check "uploading texture %dx%d if=%x f=%x t=%x", |
… | |
… | |
371 | $tw, $th, |
371 | $tw, $th, |
372 | 0; |
372 | 0; |
373 | CFClient::gl_check "copying to texture %dx%d if=%x", |
373 | CFClient::gl_check "copying to texture %dx%d if=%x", |
374 | $tw, $th, $self->{internalformat}; |
374 | $tw, $th, $self->{internalformat}; |
375 | } |
375 | } |
|
|
376 | |
|
|
377 | glBindTexture GL_TEXTURE_2D, 0; # just to be on the safe side |
376 | } |
378 | } |
377 | |
379 | |
378 | sub DESTROY { |
380 | sub DESTROY { |
379 | my ($self) = @_; |
381 | my ($self) = @_; |
380 | |
382 | |
… | |
… | |
382 | |
384 | |
383 | glDeleteTexture delete $self->{name} |
385 | glDeleteTexture delete $self->{name} |
384 | if $self->{name}; |
386 | if $self->{name}; |
385 | } |
387 | } |
386 | |
388 | |
387 | sub restore_state{ |
389 | sub restore_state { |
388 | $_->upload |
390 | $_->upload |
389 | for values %TEXTURES; |
391 | for values %TEXTURES; |
390 | }; |
392 | } |
391 | |
393 | |
392 | 1; |
394 | 1; |
393 | |
395 | |
394 | =back |
396 | =back |
395 | |
397 | |