… | |
… | |
164 | } |
164 | } |
165 | } |
165 | } |
166 | |
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, |