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.35 by root, Sat Apr 15 22:55:59 2006 UTC vs.
Revision 1.36 by root, Sat Apr 15 23:24:59 2006 UTC

140use Scalar::Util; 140use Scalar::Util;
141 141
142use SDL::OpenGL; 142use SDL::OpenGL;
143 143
144my %TEXTURES; 144my %TEXTURES;
145my @NAMES;
146 145
147sub new { 146sub new {
148 my ($class, %data) = @_; 147 my ($class, %data) = @_;
149 148
150 my $self = bless { 149 my $self = bless {
262 } 261 }
263 262
264 $self->{s} = $self->{w} / $tw; 263 $self->{s} = $self->{w} / $tw;
265 $self->{t} = $self->{h} / $th; 264 $self->{t} = $self->{h} / $th;
266 265
267 $self->{name} ||= (pop @NAMES) || (glGenTextures 1)->[0]; 266 $self->{name} ||= (glGenTextures 1)->[0];
268 267
269 glBindTexture GL_TEXTURE_2D, $self->{name}; 268 glBindTexture GL_TEXTURE_2D, $self->{name};
270 269
271 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, $::FAST ? GL_NEAREST : GL_LINEAR; 270 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, $::FAST ? GL_NEAREST : GL_LINEAR;
272 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, $::FAST ? GL_NEAREST : GL_LINEAR; 271 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, $::FAST ? GL_NEAREST : GL_LINEAR;
295sub DESTROY { 294sub DESTROY {
296 my ($self) = @_; 295 my ($self) = @_;
297 296
298 delete $TEXTURES{$self+0}; 297 delete $TEXTURES{$self+0};
299 298
300 if (my $name = delete $self->{name}) { 299 glDeleteTextures delete $self->{name}
301 glDeleteTextures $name; 300 if $self->{name};
302 push @NAMES, $name;
303 }
304
305} 301}
306 302
307sub restore_state{ 303sub restore_state{
308 $_->upload 304 $_->upload
309 for grep $_, values %TEXTURES; 305 for values %TEXTURES;
310}; 306};
311 307
3121; 3081;
313 309
314=back 310=back

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines