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.21 by root, Thu Jul 19 23:29:17 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 #glScissor 0, 0, $tw, $th; 173 #glScissor 0, 0, $tw, $th;
170 #glEnable GL_SCISSOR_TEST; 174 #glEnable GL_SCISSOR_TEST;
171 glMatrixMode GL_PROJECTION; 175 glMatrixMode GL_PROJECTION;
172 glLoadIdentity; 176 glLoadIdentity;
173 glOrtho 0, $tw, 0, $th, -10000, 10000; 177 glOrtho 0, $tw, 0, $th, -10000, 10000;
179 $self->{render_cb}->($self, $rw, $rh); 183 $self->{render_cb}->($self, $rw, $rh);
180 } else { 184 } else {
181 glClearColor 0, 0, 0, 0; 185 glClearColor 0, 0, 0, 0;
182 glClear GL_COLOR_BUFFER_BIT; 186 glClear GL_COLOR_BUFFER_BIT;
183 glPixelZoom $tw / $dw, $th / $dh; 187 glPixelZoom $tw / $dw, $th / $dh;
188 glRasterPos 0, 0;
184 glDrawPixels $dw, $dh, 189 glDrawPixels $dw, $dh,
185 $self->{format}, 190 $self->{format},
186 $self->{type}, 191 $self->{type},
187 $data; 192 $data;
188 glPixelZoom 1, 1; 193 glPixelZoom 1, 1;
215 glGetError; 220 glGetError;
216 221
217 if ($render) { 222 if ($render) {
218 glCopyTexImage2D GL_TEXTURE_2D, 0, 223 glCopyTexImage2D GL_TEXTURE_2D, 0,
219 $self->{internalformat}, 224 $self->{internalformat},
220 0, 0, 225 $ox, $oy,
221 $tw, $th, 226 $tw, $th,
222 0; 227 0;
223 gl_check "copying to texture %dx%d if=%x", 228 gl_check "copying to texture %dx%d if=%x",
224 $tw, $th, $self->{internalformat}; 229 $tw, $th, $self->{internalformat};
225 230

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines