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.18 by root, Thu Jul 19 21:02:02 2007 UTC vs.
Revision 1.21 by root, Thu Jul 19 23:29:17 2007 UTC

140 $th >>= 1; 140 $th >>= 1;
141 } 141 }
142 142
143 # decide the amount of space used in the texture 143 # decide the amount of space used in the texture
144 my ($rw, $rh); 144 my ($rw, $rh);
145 my $render;
145 146
146 if ($self->{render_cb}) { 147 if ($self->{render_cb}) {
147 # use only part of the texture 148 # use only part of the texture
148 #$rw >>= 1 while $rw > $tw; 149 #$rw >>= 1 while $rw > $tw;
149 #$rh >>= 1 while $rh > $th; 150 #$rh >>= 1 while $rh > $th;
150 $rw = min $dw, $tw; 151 $rw = min $dw, $tw;
151 $rh = min $dh, $th; 152 $rh = min $dh, $th;
153 ++$render;
152 } else { 154 } else {
153 if ($self->{wrap} || $tw < $dw || $th < $dh) { 155 if ($self->{wrap} || $tw < $dw || $th < $dh) {
154 # scale to the full texture size 156 # scale to the full texture size
155 ($rw, $rh) = ($tw, $th); 157 ($rw, $rh) = ($tw, $th);
158 ++$render;
156 } else { 159 } else {
157 # pad 160 # pad
158 pad $data, $dw, $dh, $tw, $th; 161 pad $data, $dw, $dh, $tw, $th;
159 ($rw, $rh) = ($dw, $dh); 162 ($rw, $rh) = ($dw, $dh);
160 ($dw, $dh) = ($tw, $th); 163 ($dw, $dh) = ($tw, $th);
161 } 164 }
162 } 165 }
163 166
164 # rendering means we need to scale in some way
165 my $render = $self->{render_cb} || $rw != $dw || $th != $dh;
166
167 if ($render) { 167 if ($render) {
168 glViewport 0, 0, $tw, $th; 168 glViewport 0, 0, $tw, $th;
169 glClear 0, 0, 0, 0; 169 #glScissor 0, 0, $tw, $th;
170 #glEnable GL_SCISSOR_TEST;
170 glMatrixMode GL_PROJECTION; 171 glMatrixMode GL_PROJECTION;
171 glLoadIdentity; 172 glLoadIdentity;
172 glOrtho 0, $tw, 0, $th, -10000, 10000; 173 glOrtho 0, $tw, 0, $th, -10000, 10000;
173 glMatrixMode GL_MODELVIEW; 174 glMatrixMode GL_MODELVIEW;
174 glLoadIdentity; 175 glLoadIdentity;
175 176
176 if ($self->{render_cb}) { 177 if ($self->{render_cb}) {
177 glScale $rw / $dw, $rh / $dh; 178 glScale $rw / $dw, $rh / $dh;
178 $self->{render_cb}->($self, $rw, $rh); 179 $self->{render_cb}->($self, $rw, $rh);
179 } else { 180 } else {
181 glClearColor 0, 0, 0, 0;
182 glClear GL_COLOR_BUFFER_BIT;
180 glPixelZoom $tw / $dw, $th / $dh; 183 glPixelZoom $tw / $dw, $th / $dh;
181 glDrawPixels $dw, $dh, 184 glDrawPixels $dw, $dh,
182 $self->{format}, 185 $self->{format},
183 $self->{type}, 186 $self->{type},
184 $data; 187 $data;
217 0, 0, 220 0, 0,
218 $tw, $th, 221 $tw, $th,
219 0; 222 0;
220 gl_check "copying to texture %dx%d if=%x", 223 gl_check "copying to texture %dx%d if=%x",
221 $tw, $th, $self->{internalformat}; 224 $tw, $th, $self->{internalformat};
225
226 #glDisable GL_SCISSOR_TEST;
222 } else { 227 } else {
223 glTexImage2D GL_TEXTURE_2D, 0, 228 glTexImage2D GL_TEXTURE_2D, 0,
224 $self->{internalformat}, 229 $self->{internalformat},
225 $dw, $dh, 230 $dw, $dh,
226 0, 231 0,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines