void glRasterPos3f(GLfloat x, GLfloat y, GLfloat z) { if (state.block.active) { ERROR(GL_INVALID_OPERATION); } PROXY_GLES(glRasterPos3f); raster_state_t *raster = &state.raster; // TODO: glRasterPos4f? // TODO: actually project, and clear the valid bit if we end up outside the viewport raster->pos.x = x; raster->pos.y = y; raster->pos.z = z; raster->valid = 1; GLuint *dst = NULL; GLfloat *color = raster->color; if (pixel_convert(CURRENT->color, (GLvoid **)&dst, 1, 1, GL_RGBA, GL_FLOAT, GL_RGBA, GL_UNSIGNED_BYTE)) { memcpy(color, CURRENT->color, sizeof(GLfloat) * 4); raster->pixel = *dst; free(dst); } else { for (int i = 0; i < 4; i++) { color[i] = 1.0f; } raster->pixel = 0xFFFFFFFF; } }
void glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *data) { GLubyte *pixels, *from, *to; GLvoid *dst = NULL; init_raster(); if (! pixel_convert(data, &dst, width, height, format, type, GL_RGBA, GL_UNSIGNED_BYTE)) { return; } pixels = (GLubyte *)dst; for (int y = 0; y < height; y++) { if(rPos.y - y < 0 || rPos.y - y >= viewport.height) continue; to = raster + 4 * (GLuint)(rPos.x + ((rPos.y - y) * viewport.width)); from = pixels + 4 * (y * width); for (int x = 0; x < width; x++) { if(rPos.x + x < 0 || rPos.x + x >= viewport.width) continue; *to++ = *from++; *to++ = *from++; *to++ = *from++; *to++ = *from++; } } if (pixels != data) free(pixels); }
void glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *data) { raster_state_t *raster = &state.raster; if (! raster->valid) { return; } const GLubyte *from, *pixels = data; GLubyte *to; GLvoid *dst = NULL; PROXY_GLES(glDrawPixels); init_raster(); if (! pixel_convert(data, &dst, width, height, format, type, GL_RGBA, GL_UNSIGNED_BYTE)) { return; } pixels = (GLubyte *)dst; // shrink our pixel ranges to stay inside the viewport int ystart = MAX(0, -raster->pos.y); height = MIN(raster->pos.y, height); int xstart = MAX(0, -raster->pos.x); int screen_width = MIN(state.viewport.width - raster->pos.x, width); for (int y = ystart; y < height; y++) { to = raster->buf + 4 * (GLuint)(raster->pos.x + ((raster->pos.y - y) * state.viewport.nwidth)); from = pixels + 4 * (xstart + y * width); memcpy(to, from, 4 * screen_width); } if (pixels != data) free((void *)pixels); }
void glWindowPos3f(GLfloat x, GLfloat y, GLfloat z) { ERROR_IN_BLOCK(); PUSH_IF_COMPILING(glWindowPos3f); PROXY_GLES(glWindowPos3f); raster_state_t *raster = &state.raster; raster->pos.x = x; raster->pos.y = y; raster->pos.z = z; init_raster(); viewport_state_t *v = &state.viewport; if (x < v->x || x >= v->width || y < v->y || y >= v->height) { raster->valid = 0; } else { raster->valid = 1; } GLuint *dst = NULL; GLfloat *color = raster->color; if (pixel_convert(CURRENT->color, (GLvoid **)&dst, 1, 1, GL_RGBA, GL_FLOAT, GL_RGBA, GL_UNSIGNED_BYTE)) { memcpy(color, CURRENT->color, sizeof(GLfloat) * 4); raster->pixel = *dst; free(dst); } else { for (int i = 0; i < 4; i++) { color[i] = 1.0f; } raster->pixel = 0xFFFFFFFF; } }