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.37 by root, Sun Apr 16 07:25:29 2006 UTC

117sub get($$) { 117sub get($$) {
118 my $data; 118 my $data;
119 119
120 $_[0]->db_get ($_[1], $data) == 0 120 $_[0]->db_get ($_[1], $data) == 0
121 ? $data 121 ? $data
122 : (); 122 : ()
123} 123}
124 124
125my %DB_SYNC; 125my %DB_SYNC;
126 126
127sub put($$$) { 127sub put($$$) {
128 my ($db, $key, $data) = @_; 128 my ($db, $key, $data) = @_;
129 129
130 $db->db_put ($key => $data);
131
132 $DB_SYNC{$db} = AnyEvent->timer (after => 5, cb => sub { $db->db_sync }); 130 $DB_SYNC{$db} = AnyEvent->timer (after => 5, cb => sub { $db->db_sync });
133 131
132 $db->db_put ($key => $data)
134} 133}
135 134
136package CFClient::Texture; 135package CFClient::Texture;
137 136
138use strict; 137use strict;
140use Scalar::Util; 139use Scalar::Util;
141 140
142use SDL::OpenGL; 141use SDL::OpenGL;
143 142
144my %TEXTURES; 143my %TEXTURES;
145my @NAMES;
146 144
147sub new { 145sub new {
148 my ($class, %data) = @_; 146 my ($class, %data) = @_;
149 147
150 my $self = bless { 148 my $self = bless {
262 } 260 }
263 261
264 $self->{s} = $self->{w} / $tw; 262 $self->{s} = $self->{w} / $tw;
265 $self->{t} = $self->{h} / $th; 263 $self->{t} = $self->{h} / $th;
266 264
267 $self->{name} ||= (pop @NAMES) || (glGenTextures 1)->[0]; 265 $self->{name} ||= (glGenTextures 1)->[0];
268 266
269 glBindTexture GL_TEXTURE_2D, $self->{name}; 267 glBindTexture GL_TEXTURE_2D, $self->{name};
270 268
271 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, $::FAST ? GL_NEAREST : GL_LINEAR; 269 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; 270 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, $::FAST ? GL_NEAREST : GL_LINEAR;
295sub DESTROY { 293sub DESTROY {
296 my ($self) = @_; 294 my ($self) = @_;
297 295
298 delete $TEXTURES{$self+0}; 296 delete $TEXTURES{$self+0};
299 297
300 if (my $name = delete $self->{name}) { 298 glDeleteTextures delete $self->{name}
301 glDeleteTextures $name; 299 if $self->{name};
302 push @NAMES, $name;
303 }
304
305} 300}
306 301
307sub restore_state{ 302sub restore_state{
308 $_->upload 303 $_->upload
309 for grep $_, values %TEXTURES; 304 for values %TEXTURES;
310}; 305};
311 306
3121; 3071;
313 308
314=back 309=back

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines