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

Comparing deliantra/Deliantra-Client/DC/Texture.pm (file contents):
Revision 1.7 by root, Thu Jun 15 15:33:58 2006 UTC vs.
Revision 1.9 by root, Sat Jun 17 15:48:59 2006 UTC

161 $self->{type}, 161 $self->{type},
162 $data; 162 $data;
163 gl_check "uploading texture %dx%d if=%x f=%x t=%x", 163 gl_check "uploading texture %dx%d if=%x f=%x t=%x",
164 $tw, $th, $self->{internalformat}, $self->{format}, $self->{type}; 164 $tw, $th, $self->{internalformat}, $self->{format}, $self->{type};
165 } else { 165 } else {
166 exists $self->{render_cb} or die;
166 glCopyTexImage2D GL_TEXTURE_2D, 0, 167 glCopyTexImage2D GL_TEXTURE_2D, 0,
167 $self->{internalformat}, 168 $self->{internalformat},
168 0, 0, 169 0, 0,
169 $tw, $th, 170 $tw, $th,
170 0; 171 0;
171 gl_check "copying to texture %dx%d if=%x", 172 gl_check "copying to texture %dx%d if=%x",
172 $tw, $th, $self->{internalformat}; 173 $tw, $th, $self->{internalformat};
173 } 174 }
174} 175}
175 176
177sub shutdown {
178 my ($self) = @_;
179
180 glDeleteTexture $self->{name}
181 if $self->{name};
182}
183
176sub DESTROY { 184sub DESTROY {
177 my ($self) = @_; 185 my ($self) = @_;
178 186
179 delete $TEXTURES{$self+0}; 187 delete $TEXTURES{$self+0};
180 188
181 glDeleteTexture delete $self->{name} 189 $self->shutdown;
182 if $self->{name};
183} 190}
184 191
185$CFClient::OpenGL::INIT_HOOK{"CFClient::Texture"} = sub { 192$CFClient::OpenGL::INIT_HOOK{"CFClient::Texture"} = sub {
193 # first mark all existing texture names as in-use, in case the context lost textures
194 glBindTexture GL_TEXTURE_2D, $_->{name}
195 for values %TEXTURES;
186 $_->upload 196 $_->upload
187 for values %TEXTURES; 197 for values %TEXTURES;
188}; 198};
189 199
200$CFClient::OpenGL::SHUTDOWN_HOOK{"CFClient::Texture"} = sub {
201 $_->shutdown
202 for values %TEXTURES;
203};
204
1901; 2051;
191 206
192=back 207=back
193 208
194=head1 AUTHOR 209=head1 AUTHOR

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines