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.38 by root, Mon Apr 17 06:50:26 2006 UTC vs.
Revision 1.41 by root, Wed Apr 19 23:37:48 2006 UTC

21 XSLoader::load "CFClient", $VERSION; 21 XSLoader::load "CFClient", $VERSION;
22} 22}
23 23
24use AnyEvent; 24use AnyEvent;
25use BerkeleyDB; 25use BerkeleyDB;
26use SDL::OpenGL; 26use CFClient::OpenGL;
27 27
28our %GL_EXT; 28our %GL_EXT;
29our $GL_VERSION; 29our $GL_VERSION;
30 30
31our $GL_NPOT; 31our $GL_NPOT;
93mkdir "$Crossfire::VARDIR/pclient", 0777; 93mkdir "$Crossfire::VARDIR/pclient", 0777;
94 94
95our $DB_ENV = new BerkeleyDB::Env 95our $DB_ENV = new BerkeleyDB::Env
96 -Home => "$Crossfire::VARDIR/pclient", 96 -Home => "$Crossfire::VARDIR/pclient",
97 -Cachesize => 1_000_000, 97 -Cachesize => 1_000_000,
98 -ErrFile => "/proc/self/fd/2", 98 -ErrFile => "$Crossfire::VARDIR/pclient/errorlog.txt",
99 -ErrPrefix => "DATABASE", 99# -ErrPrefix => "DATABASE",
100 -Verbose => 1, 100 -Verbose => 1,
101 -Flags => DB_CREATE | DB_JOINENV | DB_RECOVER_FATAL | DB_INIT_MPOOL | DB_INIT_LOCK | DB_INIT_TXN, 101 -Flags => DB_CREATE | DB_RECOVER_FATAL | DB_INIT_MPOOL | DB_INIT_LOCK | DB_INIT_TXN,
102 or die "unable to create/open database home $Crossfire::VARDIR/pclient: $BerkeleyDB::Error"; 102 or die "unable to create/open database home $Crossfire::VARDIR/pclient: $BerkeleyDB::Error";
103 103
104sub db_table($) { 104sub db_table($) {
105 my ($table) = @_; 105 my ($table) = @_;
106 106
141 141
142use strict; 142use strict;
143 143
144use Scalar::Util; 144use Scalar::Util;
145 145
146use SDL::OpenGL; 146use CFClient::OpenGL;
147 147
148my %TEXTURES; 148my %TEXTURES;
149 149
150sub new { 150sub new {
151 my ($class, %data) = @_; 151 my ($class, %data) = @_;
265 } 265 }
266 266
267 $self->{s} = $self->{w} / $tw; 267 $self->{s} = $self->{w} / $tw;
268 $self->{t} = $self->{h} / $th; 268 $self->{t} = $self->{h} / $th;
269 269
270 glGetError;
271
270 $self->{name} ||= (glGenTextures 1)->[0]; 272 $self->{name} ||= glGenTexture;
271 273
272 glBindTexture GL_TEXTURE_2D, $self->{name}; 274 glBindTexture GL_TEXTURE_2D, $self->{name};
273 275
274 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, $::FAST ? GL_NEAREST : GL_LINEAR; 276 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, $::FAST ? GL_NEAREST : GL_LINEAR;
275 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, $::FAST ? GL_NEAREST : GL_LINEAR; 277 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, $::FAST ? GL_NEAREST : GL_LINEAR;
282 $tw, $th, # need to pad texture first 284 $tw, $th, # need to pad texture first
283 0, 285 0,
284 $self->{format}, 286 $self->{format},
285 $self->{type}, 287 $self->{type},
286 $data; 288 $data;
287 glGetError and die; 289 if (my $error = glGetError) {
290 warn sprintf "texture upload error: %x %dx%d i=%x f=%x t=%x\n",
291 $error, $tw, $th, $self->{internalformat}, $self->{format}, $self->{type};
292 }
288 } else { 293 } else {
289 glCopyTexImage2D GL_TEXTURE_2D, 0, 294 glCopyTexImage2D GL_TEXTURE_2D, 0,
290 $self->{internalformat}, 295 $self->{internalformat},
291 0, 0, 296 0, 0,
292 $tw, $th, 297 $tw, $th,
298sub DESTROY { 303sub DESTROY {
299 my ($self) = @_; 304 my ($self) = @_;
300 305
301 delete $TEXTURES{$self+0}; 306 delete $TEXTURES{$self+0};
302 307
303 glDeleteTextures delete $self->{name} 308 glDeleteTexture delete $self->{name}
304 if $self->{name}; 309 if $self->{name};
305} 310}
306 311
307sub restore_state{ 312sub restore_state{
308 $_->upload 313 $_->upload

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines