| 167 | |
| 168 | |
| 169 | void GLFrame::drawTile(int x, int y, int width, int height) |
| 170 | { |
| 171 | if(x < 0 || width < 1 || (x + width) > hdr.framew || y < 0 || height < 1 |
| 172 | || (y + height) > hdr.frameh) |
| 173 | return; |
| 174 | int glFormat = (pf->id == PF_BGR ? GL_BGR : GL_RGB); |
| 175 | |
| 176 | if(!glXMakeCurrent(dpy, win, ctx)) |
| 177 | THROW("Could not bind OpenGL context to window (window may have disappeared)"); |
| 178 | |
| 179 | int e; |
| 180 | e = glGetError(); |
| 181 | while(e != GL_NO_ERROR) e = glGetError(); // Clear previous error |
| 182 | glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 183 | glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch / pf->size); |
| 184 | int oldbuf = -1; |
| 185 | glGetIntegerv(GL_DRAW_BUFFER, &oldbuf); |
| 186 | if(stereo) glDrawBuffer(GL_BACK_LEFT); |
| 187 | glViewport(0, 0, hdr.framew, hdr.frameh); |
| 188 | glRasterPos2f(((float)x / (float)hdr.framew) * 2.0f - 1.0f, |
| 189 | ((float)y / (float)hdr.frameh) * 2.0f - 1.0f); |
| 190 | glDrawPixels(width, height, glFormat, GL_UNSIGNED_BYTE, |
| 191 | &bits[pitch * y + x * pf->size]); |
| 192 | if(stereo) |
| 193 | { |
| 194 | glDrawBuffer(GL_BACK_RIGHT); |
| 195 | glRasterPos2f(((float)x / (float)hdr.framew) * 2.0f - 1.0f, |
| 196 | ((float)y / (float)hdr.frameh) * 2.0f - 1.0f); |
| 197 | glDrawPixels(width, height, glFormat, GL_UNSIGNED_BYTE, |
| 198 | &rbits[pitch * y + x * pf->size]); |
| 199 | glDrawBuffer(oldbuf); |
| 200 | } |
| 201 | |
| 202 | if(glError()) THROW("Could not draw pixels"); |
| 203 | } |
| 204 | |
| 205 | |
| 206 | void GLFrame::sync(void) |
nothing calls this directly
no test coverage detected