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.20 by root, Thu Jul 19 22:38:53 2007 UTC vs.
Revision 1.23 by root, Tue Jul 24 01:24:27 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 - $rw);
170 $oy = int .5 * ($::HEIGHT - $rh);
171
168 glViewport 0, 0, $tw, $th; 172 glViewport $ox, $oy, $tw, $th;
173 #glScissor 0, 0, $tw, $th;
174 #glEnable GL_SCISSOR_TEST;
169 glMatrixMode GL_PROJECTION; 175 glMatrixMode GL_PROJECTION;
170 glLoadIdentity; 176 glLoadIdentity;
171 glOrtho 0, $tw, 0, $th, -10000, 10000; 177 glOrtho 0, $tw, 0, $th, -10000, 10000;
172 glMatrixMode GL_MODELVIEW; 178 glMatrixMode GL_MODELVIEW;
173 glLoadIdentity; 179 glLoadIdentity;
177 $self->{render_cb}->($self, $rw, $rh); 183 $self->{render_cb}->($self, $rw, $rh);
178 } else { 184 } else {
179 glClearColor 0, 0, 0, 0; 185 glClearColor 0, 0, 0, 0;
180 glClear GL_COLOR_BUFFER_BIT; 186 glClear GL_COLOR_BUFFER_BIT;
181 glPixelZoom $tw / $dw, $th / $dh; 187 glPixelZoom $tw / $dw, $th / $dh;
188 glRasterPos 0, 0;
182 glDrawPixels $dw, $dh, 189 glDrawPixels $dw, $dh,
183 $self->{format}, 190 $self->{format},
184 $self->{type}, 191 $self->{type},
185 $data; 192 $data;
186 glPixelZoom 1, 1; 193 glPixelZoom 1, 1;
213 glGetError; 220 glGetError;
214 221
215 if ($render) { 222 if ($render) {
216 glCopyTexImage2D GL_TEXTURE_2D, 0, 223 glCopyTexImage2D GL_TEXTURE_2D, 0,
217 $self->{internalformat}, 224 $self->{internalformat},
218 0, 0, 225 $ox, $oy,
219 $tw, $th, 226 $tw, $th,
220 0; 227 0;
221 gl_check "copying to texture %dx%d if=%x", 228 gl_check "copying to texture %dx%d if=%x",
222 $tw, $th, $self->{internalformat}; 229 $tw, $th, $self->{internalformat};
230
231 #glDisable GL_SCISSOR_TEST;
223 } else { 232 } else {
224 glTexImage2D GL_TEXTURE_2D, 0, 233 glTexImage2D GL_TEXTURE_2D, 0,
225 $self->{internalformat}, 234 $self->{internalformat},
226 $dw, $dh, 235 $dw, $dh,
227 0, 236 0,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines