ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/Texture.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/Texture.pm (file contents):
Revision 1.25 by root, Mon Aug 6 05:06:33 2007 UTC vs.
Revision 1.27 by root, Tue Aug 21 00:59:34 2007 UTC

121 # $rw,$rh rendered/used size 121 # $rw,$rh rendered/used size
122 # $dw,$dh $data 122 # $dw,$dh $data
123 123
124 my ($data, $dw, $dh); 124 my ($data, $dw, $dh);
125 125
126 if (exists $self->{data}) { 126 if (defined $self->{data}) {
127 $data = $self->{data}; 127 $data = $self->{data};
128 ($dw, $dh) = @$self{qw(w h)}; 128 ($dw, $dh) = @$self{qw(w h)};
129 129
130 } elsif (exists $self->{render_cb}) { 130 } elsif ($self->{render_cb}) {
131 ($dw, $dh) = @$self{qw(w h)}; 131 ($dw, $dh) = @$self{qw(w h)};
132 132
133 } elsif (exists $self->{image}) { 133 } elsif (defined $self->{image}) {
134 ($self->{w}, $self->{h}, $data, my $internalformat, $self->{format}, $self->{type}) 134 ($self->{w}, $self->{h}, $data, my $internalformat, $self->{format}, $self->{type})
135 = CFPlus::load_image_inline $self->{image}; 135 = CFPlus::load_image_inline $self->{image};
136 136
137 $self->{internalformat} ||= $internalformat; 137 $self->{internalformat} ||= $internalformat;
138 ($dw, $dh) = @$self{qw(w h)}; 138 ($dw, $dh) = @$self{qw(w h)};
139 139
140 delete $self->{image} if delete $self->{delete_image}; 140 delete $self->{image} if delete $self->{delete_image};
141 141
142 } elsif (exists $self->{tile}) { 142 } elsif (defined $self->{tile}) {
143 ++$self->{loading}; 143 ++$self->{loading};
144 return CFPlus::DB::get tilecache => $self->{tile}, sub { 144 return CFPlus::DB::get tilecache => $self->{tile}, sub {
145 $self->loading_done ($_[0]); 145 $self->loading_done ($_[0]);
146
147 $::MAP->set_texture ($self->{tile}, @$self{qw(name w h s t)}, @{$self->{minified}})
148 if $::MAP;
149 $::MAPWIDGET->update
150 if $::MAPWIDGET;
151 }; 146 };
152 147
153 } elsif (exists $self->{path}) { 148 } elsif (defined $self->{path}) {
154 ++$self->{loading}; 149 ++$self->{loading};
155 return CFPlus::DB::read_file $self->{path}, sub { 150 return CFPlus::DB::read_file $self->{path}, sub {
156 $self->loading_done ($_[0]); 151 $self->loading_done ($_[0]);
157 }; 152 };
158 153
273 gl_check "copying to texture %dx%d if=%x", 268 gl_check "copying to texture %dx%d if=%x",
274 $tw, $th, $self->{internalformat}; 269 $tw, $th, $self->{internalformat};
275 270
276 #glDisable GL_SCISSOR_TEST; 271 #glDisable GL_SCISSOR_TEST;
277 } else { 272 } else {
273 my $if = $self->{internalformat};
274
275 if ($GL_COMPRESS && $::CFG->{texture_compression}) {
276 if ($if == GL_RGB) {
277 $if = GL_COMPRESSED_RGB_ARB;
278 } elsif ($if == GL_RGBA) {
279 $if = GL_COMPRESSED_RGBA_ARB;
280 }
281 }
282
278 glTexImage2D GL_TEXTURE_2D, 0, 283 glTexImage2D GL_TEXTURE_2D, 0,
279 $self->{internalformat}, 284 $if,
280 $dw, $dh, 285 $dw, $dh,
281 0, 286 0,
282 $self->{format}, 287 $self->{format},
283 $self->{type}, 288 $self->{type},
284 $data; 289 $data;
286 $tw, $th, $self->{internalformat}, $self->{format}, $self->{type}; 291 $tw, $th, $self->{internalformat}, $self->{format}, $self->{type};
287 } 292 }
288 293
289 $self->{s} = $rw / $tw; 294 $self->{s} = $rw / $tw;
290 $self->{t} = $rh / $th; 295 $self->{t} = $rh / $th;
296
297 if ($self->{tile}) {
298 $::MAP->set_texture ($self->{tile}, @$self{qw(name w h s t)}, @{$self->{minified}})
299 if $::MAP;
300 $::MAPWIDGET->update
301 if $::MAPWIDGET;
302 }
291 } 303 }
292 304
293 $_->($self) 305 $_->($self)
294 for @{ (delete $self->{upload_done}) || [] }; 306 for @{ (delete $self->{upload_done}) || [] };
295} 307}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines