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.30 by root, Wed Apr 12 21:35:10 2006 UTC vs.
Revision 1.33 by root, Sat Apr 15 01:13:45 2006 UTC

115 115
116 $self 116 $self
117} 117}
118 118
119sub new_from_image { 119sub new_from_image {
120 my ($class, $image) = @_; 120 my ($class, $image, %arg) = @_;
121 121
122 $class->new (image => $image) 122 $class->new (image => $image, %arg)
123} 123}
124 124
125sub new_from_file { 125sub new_from_file {
126 my ($class, $path) = @_; 126 my ($class, $path) = @_;
127 127
179 if (exists $self->{data}) { 179 if (exists $self->{data}) {
180 $data = $self->{data}; 180 $data = $self->{data};
181 181
182 } elsif (exists $self->{render_cb}) { 182 } elsif (exists $self->{render_cb}) {
183 glViewport 0, 0, $self->{w}, $self->{h}; 183 glViewport 0, 0, $self->{w}, $self->{h};
184 glOrtho 0, $self->{w}, 0, $self->{h}, -10000, 10000;
185 glMatrixMode GL_PROJECTION; 184 glMatrixMode GL_PROJECTION;
186 glLoadIdentity; 185 glLoadIdentity;
186 glOrtho 0, $self->{w}, 0, $self->{h}, -10000, 10000;
187 glMatrixMode GL_MODELVIEW; 187 glMatrixMode GL_MODELVIEW;
188 glLoadIdentity; 188 glLoadIdentity;
189 glClear GL_COLOR_BUFFER_BIT;
190 $self->{render_cb}->($self, $self->{w}, $self->{h}); 189 $self->{render_cb}->($self, $self->{w}, $self->{h});
191 190
192 } else { 191 } else {
193 ($self->{w}, $self->{h}, $data, $self->{internalformat}, $self->{format}, $self->{type}) 192 ($self->{w}, $self->{h}, $data, $self->{internalformat}, $self->{format}, $self->{type})
194 = CFClient::load_image_inline $self->{image}; 193 = CFClient::load_image_inline $self->{image};
198 197
199 unless ($tw && $th) { 198 unless ($tw && $th) {
200 $tw = $th = 1; 199 $tw = $th = 1;
201 $data = "\x00" x 64; 200 $data = "\x00" x 64;
202 } 201 }
202
203 $self->{minified} = [CFClient::average $tw, $th, $data]
204 if $self->{minify};
203 205
204 unless ($GL_NPOT) { 206 unless ($GL_NPOT) {
205 # TODO: does not work for zero-sized textures 207 # TODO: does not work for zero-sized textures
206 $tw = topot $tw; 208 $tw = topot $tw;
207 $th = topot $th; 209 $th = topot $th;
239 glCopyTexImage2D GL_TEXTURE_2D, 0, 241 glCopyTexImage2D GL_TEXTURE_2D, 0,
240 $self->{internalformat}, 242 $self->{internalformat},
241 0, 0, 243 0, 0,
242 $tw, $th, 244 $tw, $th,
243 0; 245 0;
244 glGetError and die; 246 glGetError and die "glCopyTexImage2D $tw,$th";
245 } 247 }
246} 248}
247 249
248sub DESTROY { 250sub DESTROY {
249 my ($self) = @_; 251 my ($self) = @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines