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.34 by root, Sat Apr 15 21:16:49 2006 UTC vs.
Revision 1.36 by root, Sat Apr 15 23:24:59 2006 UTC

139 139
140use Scalar::Util; 140use Scalar::Util;
141 141
142use SDL::OpenGL; 142use SDL::OpenGL;
143 143
144my @textures; 144my %TEXTURES;
145 145
146sub new { 146sub new {
147 my ($class, %data) = @_; 147 my ($class, %data) = @_;
148 148
149 my $self = bless { 149 my $self = bless {
151 format => GL_RGBA, 151 format => GL_RGBA,
152 type => GL_UNSIGNED_BYTE, 152 type => GL_UNSIGNED_BYTE,
153 %data, 153 %data,
154 }, $class; 154 }, $class;
155 155
156 push @textures, $self; 156 Scalar::Util::weaken ($TEXTURES{$self+0} = $self);
157 Scalar::Util::weaken $textures[-1];
158 157
159 $self->upload; 158 $self->upload;
160 159
161 $self 160 $self
162} 161}
293} 292}
294 293
295sub DESTROY { 294sub DESTROY {
296 my ($self) = @_; 295 my ($self) = @_;
297 296
298 return unless exists $self->{name}; 297 delete $TEXTURES{$self+0};
299 298
300 glDeleteTextures delete $self->{name}; 299 glDeleteTextures delete $self->{name}
300 if $self->{name};
301} 301}
302 302
303sub restore_state{ 303sub restore_state{
304 $_->upload 304 $_->upload
305 for grep $_, @textures; 305 for values %TEXTURES;
306}; 306};
307 307
3081; 3081;
309 309
310=back 310=back

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines