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.19 by root, Thu Jul 19 22:10:46 2007 UTC vs.
Revision 1.22 by root, Tue Jul 24 00:11:18 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 ($ox, $oy); # area shift to lessen effetc of buggy opengl implementations (nvida, ati)
145 my $render; 146 my $render;
146 147
147 if ($self->{render_cb}) { 148 if ($self->{render_cb}) {
148 # use only part of the texture 149 # use only part of the texture
149 #$rw >>= 1 while $rw > $tw; 150 #$rw >>= 1 while $rw > $tw;
163 ($dw, $dh) = ($tw, $th); 164 ($dw, $dh) = ($tw, $th);
164 } 165 }
165 } 166 }
166 167
167 if ($render) { 168 if ($render) {
169 $ox = int .5 * ($::WIDTH - $tw);
170 $oy = int .5 * ($::HEIGHT - $th);
171
168 glViewport 0, 0, $tw, $th; 172 glViewport $ox, $oy, $tw, $th;
169 glClear 0, 0, 0, 0; 173 #glScissor 0, 0, $tw, $th;
174 #glEnable GL_SCISSOR_TEST;
170 glMatrixMode GL_PROJECTION; 175 glMatrixMode GL_PROJECTION;
171 glLoadIdentity; 176 glLoadIdentity;
172 glOrtho 0, $tw, 0, $th, -10000, 10000; 177 glOrtho 0, $tw, 0, $th, -10000, 10000;
173 glMatrixMode GL_MODELVIEW; 178 glMatrixMode GL_MODELVIEW;
174 glLoadIdentity; 179 glLoadIdentity;
175 180
176 if ($self->{render_cb}) { 181 if ($self->{render_cb}) {
177 glScale $rw / $dw, $rh / $dh; 182 glScale $rw / $dw, $rh / $dh;
178 $self->{render_cb}->($self, $rw, $rh); 183 $self->{render_cb}->($self, $rw, $rh);
179 } else { 184 } else {
185 glClearColor 0, 0, 0, 0;
186 glClear GL_COLOR_BUFFER_BIT;
180 glPixelZoom $tw / $dw, $th / $dh; 187 glPixelZoom $tw / $dw, $th / $dh;
188 glRasterPos 0, 0;
181 glDrawPixels $dw, $dh, 189 glDrawPixels $dw, $dh,
182 $self->{format}, 190 $self->{format},
183 $self->{type}, 191 $self->{type},
184 $data; 192 $data;
185 glPixelZoom 1, 1; 193 glPixelZoom 1, 1;
212 glGetError; 220 glGetError;
213 221
214 if ($render) { 222 if ($render) {
215 glCopyTexImage2D GL_TEXTURE_2D, 0, 223 glCopyTexImage2D GL_TEXTURE_2D, 0,
216 $self->{internalformat}, 224 $self->{internalformat},
217 0, 0, 225 $ox, $oy,
218 $tw, $th, 226 $tw, $th,
219 0; 227 0;
220 gl_check "copying to texture %dx%d if=%x", 228 gl_check "copying to texture %dx%d if=%x",
221 $tw, $th, $self->{internalformat}; 229 $tw, $th, $self->{internalformat};
230
231 #glDisable GL_SCISSOR_TEST;
222 } else { 232 } else {
223 glTexImage2D GL_TEXTURE_2D, 0, 233 glTexImage2D GL_TEXTURE_2D, 0,
224 $self->{internalformat}, 234 $self->{internalformat},
225 $dw, $dh, 235 $dw, $dh,
226 0, 236 0,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines