--- deliantra/Deliantra-Client/DC/Texture.pm 2006/06/14 18:59:31 1.6 +++ deliantra/Deliantra-Client/DC/Texture.pm 2006/06/17 15:07:53 1.8 @@ -42,7 +42,7 @@ sub new_from_image { my ($class, $image, %arg) = @_; - $class->new (image => $image, %arg) + $class->new (image => $image, internalformat => undef, %arg) } sub new_from_file { @@ -109,8 +109,10 @@ $self->{render_cb}->($self, $self->{w}, $self->{h}); } else { - ($self->{w}, $self->{h}, $data, $self->{internalformat}, $self->{format}, $self->{type}) + ($self->{w}, $self->{h}, $data, my $internalformat, $self->{format}, $self->{type}) = CFClient::load_image_inline $self->{image}; + + $self->{internalformat} ||= $internalformat; } my ($tw, $th) = @$self{qw(w h)}; @@ -171,13 +173,19 @@ } } +sub shutdown { + my ($self) = @_; + + glDeleteTexture delete $self->{name} + if $self->{name}; +} + sub DESTROY { my ($self) = @_; delete $TEXTURES{$self+0}; - glDeleteTexture delete $self->{name} - if $self->{name}; + $self->shutdown; } $CFClient::OpenGL::INIT_HOOK{"CFClient::Texture"} = sub { @@ -185,6 +193,11 @@ for values %TEXTURES; }; +$CFClient::OpenGL::SHUTDOWN_HOOK{"CFClient::Texture"} = sub { + $_->shutdown + for values %TEXTURES; +}; + 1; =back