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.44 by root, Mon Apr 24 08:22:20 2006 UTC vs.
Revision 1.48 by root, Tue Apr 25 11:18:48 2006 UTC

49} 49}
50 50
51sub find_rcfile($) { 51sub find_rcfile($) {
52 my $path; 52 my $path;
53 53
54 for (@INC) { 54 for (grep !ref, @INC) {
55 $path = "$_/CFClient/resources/$_[0]"; 55 $path = "$_/CFClient/resources/$_[0]";
56 return $path if -r $path; 56 return $path if -r $path;
57 } 57 }
58 58
59 die "FATAL: can't find required file $_[0]\n"; 59 die "FATAL: can't find required file $_[0]\n";
210} 210}
211 211
212sub new_from_opengl { 212sub new_from_opengl {
213 my ($class, $w, $h, $cb) = @_; 213 my ($class, $w, $h, $cb) = @_;
214 214
215 $class->new (w => $w, h => $h, render_cb => $cb) 215 $class->new (w => $w || 1, h => $h || 1, render_cb => $cb)
216} 216}
217 217
218sub topot { 218sub topot {
219 (grep $_ >= $_[0], 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768)[0] 219 (grep $_ >= $_[0], 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768)[0]
220} 220}
243 = CFClient::load_image_inline $self->{image}; 243 = CFClient::load_image_inline $self->{image};
244 } 244 }
245 245
246 my ($tw, $th) = @$self{qw(w h)}; 246 my ($tw, $th) = @$self{qw(w h)};
247 247
248 unless ($tw && $th) { 248 unless ($tw > 0 && $th > 0) {
249 $tw = $th = 1; 249 $tw = $th = 1;
250 $data = "\x00" x 64; 250 $data = "\x00" x 64;
251 } 251 }
252 252
253 $self->{minified} = [CFClient::average $tw, $th, $data] 253 $self->{minified} = [CFClient::average $tw, $th, $data]
267 } 267 }
268 268
269 $self->{s} = $self->{w} / $tw; 269 $self->{s} = $self->{w} / $tw;
270 $self->{t} = $self->{h} / $th; 270 $self->{t} = $self->{h} / $th;
271 271
272 glGetError;
273
274 $self->{name} ||= glGenTexture; 272 $self->{name} ||= glGenTexture;
275 273
276 glBindTexture GL_TEXTURE_2D, $self->{name}; 274 glBindTexture GL_TEXTURE_2D, $self->{name};
277 275
278 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP; 276 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP;
279 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP; 277 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP;
280 278
281 if ($::FAST) { 279 if ($::FAST) {
282 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST; 280 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST;
283 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST; 281 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST;
282 } elsif ($self->{mipmap} && $GL_VERSION >= 1.4) {
283 # alternatively check for 0x8191
284 glTexParameter GL_TEXTURE_2D, GL_GENERATE_MIPMAP, 1;
285 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR;
286 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR;
284 } else { 287 } else {
285 glTexParameter GL_TEXTURE_2D, GL_GENERATE_MIPMAP, $self->{mipmap}; 288 glTexParameter GL_TEXTURE_2D, GL_GENERATE_MIPMAP, $self->{mipmap};
286 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR; 289 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR;
287 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, $self->{mipmap} ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR; 290 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR;
288 } 291 }
289 292
293 glGetError;
294
290 if (defined $data) { 295 if (defined $data) {
291 glTexImage2D GL_TEXTURE_2D, 0, 296 glTexImage2D GL_TEXTURE_2D, 0,
292 $self->{internalformat}, 297 $self->{internalformat},
293 $tw, $th, # need to pad texture first 298 $tw, $th, # need to pad texture first
294 0, 299 0,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines