GLint gl4es_glRenderMode(GLenum mode) { if(glstate->list.compiling) {errorShim(GL_INVALID_OPERATION); return 0;} if(glstate->list.active) flush(); int ret = 0; if ((mode==GL_SELECT) || (mode==GL_RENDER)) { // missing GL_FEEDBACK noerrorShim(); } else { errorShim(GL_INVALID_ENUM); return 0; } if (glstate->render_mode == GL_SELECT) { push_hit(); ret = glstate->selectbuf.count; } if (mode == GL_SELECT) { if (glstate->selectbuf.buffer == NULL) {// error, cannot use Select Mode without select buffer errorShim(GL_INVALID_OPERATION); return 0; } glstate->selectbuf.count = 0; glstate->selectbuf.pos = 0; glstate->selectbuf.overflow = 0; glstate->selectbuf.zmin = 1e10f; glstate->selectbuf.zmax = -1e10f; glstate->selectbuf.zminoverall = 1e10f; glstate->selectbuf.zmaxoverall = -1e10f; glstate->selectbuf.hit = 0; } glstate->render_mode = mode; return ret; }
void gl4es_glBeginQuery(GLenum target, GLuint id) { if(target!=GL_SAMPLES_PASSED) { errorShim(GL_INVALID_ENUM); return; } if (glstate->list.pending) flush(); khint_t k; int ret; glquery_t *query; khash_t(queries) *list = glstate->queries; if (! list) { list = glstate->queries = kh_init(queries); // segfaults if we don't do a single put kh_put(queries, list, 1, &ret); kh_del(queries, list, 1); } k = kh_get(queries, list, id); if (k != kh_end(list)) { query = kh_value(list, k); } else { k = kh_put(queries, list, id, &ret); query = kh_value(list, k) = malloc(sizeof(glquery_t)); } query->target = target; query->num = 0; active_samples_passed = query; noerrorShim(); }
void gl4es_glLightModelfv(GLenum pname, const GLfloat* params) { //printf("%sglLightModelfv(%04X, [%.2f, %.2f, %.2f, %.2f])\n", (state.list.compiling)?"list":"", pname, params[0], params[1], params[2], params[3]); if (glstate->list.compiling && glstate->list.active) { NewStage(glstate->list.active, STAGE_LIGHTMODEL); /* if (glstate->list.active->lightmodel) glstate->list.active = extend_renderlist(glstate->list.active);*/ glstate->list.active->lightmodelparam = pname; glstate->list.active->lightmodel = (GLfloat*)malloc(4*sizeof(GLfloat)); memcpy(glstate->list.active->lightmodel, params, 4*sizeof(GLfloat)); noerrorShim(); return; } LOAD_GLES(glLightModelfv); switch (pname) { case GL_LIGHT_MODEL_AMBIENT: case GL_LIGHT_MODEL_TWO_SIDE: errorGL(); gles_glLightModelfv(pname, params); break; default: errorShim(GL_INVALID_ENUM); //printf("stubbed glLightModelfv(%i, %p [%.2f])\n", pname, params, params[0]); break; } }
void gl4es_glInitNames() { if (glstate->namestack.names == 0) { glstate->namestack.names = (GLuint*)malloc(1024*sizeof(GLuint)); } glstate->namestack.top = 0; noerrorShim(); }
void glInitNames() { if (state.namestack.names == 0) { state.namestack.names = (GLuint*)malloc(1024*sizeof(GLuint)); } state.namestack.top = 0; noerrorShim(); }
void gl4es_glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) { khint_t k; int ret; if (glstate->list.pending) flush(); glquery_t *query = NULL; khash_t(queries) *list = glstate->queries; if (! list) { list = glstate->queries = kh_init(queries); // segfaults if we don't do a single put kh_put(queries, list, 1, &ret); kh_del(queries, list, 1); } k = kh_get(queries, list, id); if (k != kh_end(list)) { query = kh_value(list, k); } if(!query) { errorShim(GL_INVALID_OPERATION); return; } noerrorShim(); switch (pname) { case GL_QUERY_RESULT_AVAILABLE: *params = GL_FALSE; break; case GL_QUERY_RESULT: *params = query->num; break; default: errorShim(GL_INVALID_ENUM); break; } }
void gl4es_glSelectBuffer(GLsizei size, GLuint *buffer) { if (glstate->list.pending) flush(); noerrorShim(); glstate->selectbuf.buffer = buffer; glstate->selectbuf.size = size; }
void glPopName() { noerrorShim(); if (state.render_mode != GL_SELECT) return; push_hit(); if (state.namestack.top>0) state.namestack.top--; else errorShim(GL_STACK_UNDERFLOW); }
void glLoadName(GLuint name) { noerrorShim(); if (state.render_mode != GL_SELECT) return; if (state.namestack.names == 0) return; push_hit(); if (state.namestack.top == 0) return; state.namestack.names[state.namestack.top-1] = name; }
void gl4es_glPushName(GLuint name) { noerrorShim(); if (glstate->render_mode != GL_SELECT) return; if (glstate->namestack.names==0) return; push_hit(); if (glstate->namestack.top < 1024) { glstate->namestack.names[glstate->namestack.top++] = name; } }
void gl4es_glLoadName(GLuint name) { noerrorShim(); if (glstate->render_mode != GL_SELECT) return; if (glstate->namestack.names == 0) return; push_hit(); if (glstate->namestack.top == 0) return; glstate->namestack.names[glstate->namestack.top-1] = name; }
void glPushName(GLuint name) { noerrorShim(); if (state.render_mode != GL_SELECT) return; if (state.namestack.names==0) return; push_hit(); if (state.namestack.top < 1024) { state.namestack.names[state.namestack.top++] = name; } }
void gl4es_glGenQueries(GLsizei n, GLuint * ids) { if (glstate->list.pending) flush(); noerrorShim(); if (n<1) { errorShim(GL_INVALID_VALUE); return; } for (int i=0; i<n; i++) { ids[i] = ++lastquery; } }
void gl4es_glLightfv(GLenum light, GLenum pname, const GLfloat* params) { //printf("%sglLightfv(%04X, %04X, %p=[%.2f, %.2f, %.2f, %.2f])\n", (glstate->list.compiling)?"list":"", light, pname, params, (params)?params[0]:0.0f, (params)?params[1]:0.0f, (params)?params[2]:0.0f, (params)?params[3]:0.0f); if (glstate->list.compiling && glstate->list.active) { NewStage(glstate->list.active, STAGE_LIGHT); rlLightfv(glstate->list.active, light, pname, params); noerrorShim(); return; } LOAD_GLES(glLightfv); gles_glLightfv(light, pname, params); errorGL(); }
void gl4es_glPopClientAttrib() { noerrorShim(); GLuint old_glbatch = glstate->gl_batch; if (glstate->gl_batch) { flush(); glstate->gl_batch = 0; } //LOAD_GLES(glVertexPointer); //LOAD_GLES(glColorPointer); //LOAD_GLES(glNormalPointer); //LOAD_GLES(glTexCoordPointer); if (glstate->clientStack == NULL || glstate->clientStack->len == 0) { errorShim(GL_STACK_UNDERFLOW); return; } glclientstack_t *cur = glstate->clientStack + glstate->clientStack->len-1; if (cur->mask & GL_CLIENT_PIXEL_STORE_BIT) { gl4es_glPixelStorei(GL_PACK_ALIGNMENT, cur->pack_align); gl4es_glPixelStorei(GL_UNPACK_ALIGNMENT, cur->unpack_align); gl4es_glPixelStorei(GL_UNPACK_ROW_LENGTH, cur->unpack_row_length); gl4es_glPixelStorei(GL_UNPACK_SKIP_PIXELS, cur->unpack_skip_pixels); gl4es_glPixelStorei(GL_UNPACK_SKIP_ROWS, cur->unpack_skip_rows); gl4es_glPixelStorei(GL_PACK_ROW_LENGTH, cur->pack_row_length); gl4es_glPixelStorei(GL_PACK_SKIP_PIXELS, cur->pack_skip_pixels); gl4es_glPixelStorei(GL_PACK_SKIP_ROWS, cur->pack_skip_rows); } if (cur->mask & GL_CLIENT_VERTEX_ARRAY_BIT) { if (glstate->vao->vertex_array != cur->vert_enable) enable_disable(GL_VERTEX_ARRAY, cur->vert_enable); if (glstate->vao->normal_array != cur->normal_enable) enable_disable(GL_NORMAL_ARRAY, cur->normal_enable); if (glstate->vao->color_array != cur->color_enable) enable_disable(GL_COLOR_ARRAY, cur->color_enable); if (glstate->vao->secondary_array != cur->secondary_enable) enable_disable(GL_SECONDARY_COLOR_ARRAY, cur->secondary_enable); for (int a=0; a<hardext.maxtex; a++) { if (glstate->vao->tex_coord_array[a] != cur->tex_enable[a]) { gl4es_glClientActiveTexture(GL_TEXTURE0+a); enable_disable(GL_TEXTURE_COORD_ARRAY, cur->tex_enable[a]); } } memcpy(&glstate->vao->pointers, &(cur->pointers), sizeof(pointer_states_t)); if (glstate->texture.client != cur->client) gl4es_glClientActiveTexture(GL_TEXTURE0+cur->client); } glstate->clientStack->len--; glstate->gl_batch = old_glbatch; }
void gl4es_glInitNames() { if(glstate->list.active) { NewStage(glstate->list.active, STAGE_RENDER); glstate->list.active->render_op = 1; return; } //TODO list stuffs if (glstate->namestack.names == 0) { glstate->namestack.names = (GLuint*)malloc(1024*sizeof(GLuint)); } glstate->namestack.top = 0; noerrorShim(); }
GLboolean gl4es_glIsQuery(GLuint id) { if(glstate->list.compiling) {errorShim(GL_INVALID_OPERATION); return GL_FALSE;} if(glstate->list.active) flush(); khash_t(queries) *list = glstate->queries; khint_t k; noerrorShim(); if (list) { k = kh_get(queries, list, id); if (k != kh_end(list)) { return GL_TRUE; } } return GL_FALSE; }
void gl4es_glEndQuery(GLenum target) { if(target!=GL_SAMPLES_PASSED) { errorShim(GL_INVALID_ENUM); return; } if(!active_samples_passed) { errorShim(GL_INVALID_OPERATION); return; } if (glstate->list.pending) flush(); active_samples_passed = NULL; noerrorShim(); }
void gl4es_glPopName() { if(glstate->list.pending) flush(); if(glstate->list.active) { NewStage(glstate->list.active, STAGE_RENDER); glstate->list.active->render_op = 2; return; } noerrorShim(); if (glstate->render_mode != GL_SELECT) return; push_hit(); if (glstate->namestack.top>0) glstate->namestack.top--; else errorShim(GL_STACK_UNDERFLOW); }
void gl4es_glPushClientAttrib(GLbitfield mask) { noerrorShim(); GLuint old_glbatch = glstate->gl_batch; if (glstate->gl_batch) { flush(); glstate->gl_batch = 0; } if (glstate->clientStack == NULL) { glstate->clientStack = (glclientstack_t *)malloc(STACK_SIZE * sizeof(glclientstack_t)); glstate->clientStack->len = 0; glstate->clientStack->cap = STACK_SIZE; } else if (glstate->clientStack->len == glstate->clientStack->cap) { glstate->clientStack->cap += STACK_SIZE; glstate->clientStack = (glclientstack_t *)realloc(glstate->clientStack, glstate->clientStack->cap * sizeof(glclientstack_t)); } glclientstack_t *cur = glstate->clientStack + glstate->clientStack->len; cur->mask = mask; if (mask & GL_CLIENT_PIXEL_STORE_BIT) { gl4es_glGetIntegerv(GL_PACK_ALIGNMENT, &cur->pack_align); gl4es_glGetIntegerv(GL_UNPACK_ALIGNMENT, &cur->unpack_align); cur->unpack_row_length = glstate->texture.unpack_row_length; cur->unpack_skip_pixels = glstate->texture.unpack_skip_pixels; cur->unpack_skip_rows = glstate->texture.unpack_skip_rows; cur->pack_row_length = glstate->texture.pack_row_length; cur->pack_skip_pixels = glstate->texture.pack_skip_pixels; cur->pack_skip_rows = glstate->texture.pack_skip_rows; } if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) { cur->vert_enable = glstate->vao->vertex_array; cur->color_enable = glstate->vao->color_array; cur->secondary_enable = glstate->vao->secondary_array; cur->normal_enable = glstate->vao->normal_array; int a; for (a=0; a<hardext.maxtex; a++) { cur->tex_enable[a] = glstate->vao->tex_coord_array[a]; } memcpy(&(cur->pointers), &glstate->vao->pointers, sizeof(pointer_states_t)); cur->client = glstate->texture.client; } glstate->clientStack->len++; glstate->gl_batch=old_glbatch; }
void gl4es_glLoadName(GLuint name) { if(glstate->list.pending) flush(); if(glstate->list.active) { NewStage(glstate->list.active, STAGE_RENDER); glstate->list.active->render_op = 4; glstate->list.active->render_arg = name; return; } noerrorShim(); if (glstate->render_mode != GL_SELECT) return; if (glstate->namestack.names == 0) return; push_hit(); if (glstate->namestack.top == 0) return; glstate->namestack.names[glstate->namestack.top-1] = name; }
void gl4es_glGetQueryiv(GLenum target, GLenum pname, GLint* params) { if(target!=GL_SAMPLES_PASSED) { errorShim(GL_INVALID_ENUM); return; } if (glstate->list.pending) flush(); noerrorShim(); switch (pname) { case GL_CURRENT_QUERY: *params = (active_samples_passed)?active_samples_passed->id:0; break; case GL_QUERY_COUNTER_BITS: *params = 0; //no counter... break; default: errorShim(GL_INVALID_ENUM); } }
void glPushClientAttrib(GLbitfield mask) { noerrorShim(); if (clientStack == NULL) { clientStack = (glclientstack_t *)malloc(STACK_SIZE * sizeof(glclientstack_t)); clientStack->len = 0; clientStack->cap = STACK_SIZE; } else if (clientStack->len == clientStack->cap) { clientStack->cap += STACK_SIZE; clientStack = (glclientstack_t *)realloc(clientStack, clientStack->cap * sizeof(glclientstack_t)); } glclientstack_t *cur = clientStack + clientStack->len; cur->mask = mask; if (mask & GL_CLIENT_PIXEL_STORE_BIT) { glGetIntegerv(GL_PACK_ALIGNMENT, &cur->pack_align); glGetIntegerv(GL_UNPACK_ALIGNMENT, &cur->unpack_align); cur->unpack_row_length = state.texture.unpack_row_length; cur->unpack_skip_pixels = state.texture.unpack_skip_pixels; cur->unpack_skip_rows = state.texture.unpack_skip_rows; cur->pack_row_length = state.texture.pack_row_length; cur->pack_skip_pixels = state.texture.pack_skip_pixels; cur->pack_skip_rows = state.texture.pack_skip_rows; } if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) { cur->vert_enable = state.enable.vertex_array; cur->color_enable = state.enable.color_array; cur->secondary_enable = state.enable.secondary_array; cur->normal_enable = state.enable.normal_array; int a; for (a=0; a<MAX_TEX; a++) { cur->tex_enable[a] = state.enable.tex_coord_array[a]; } memcpy(&(cur->pointers), &state.pointers, sizeof(pointer_states_t)); cur->client = state.texture.client; } clientStack->len++; }
void gl4es_glDeleteQueries(GLsizei n, const GLuint* ids) { if (glstate->list.pending) flush(); khash_t(queries) *list = glstate->queries; if (list) { khint_t k; glquery_t *query; for (int i = 0; i < n; i++) { GLuint t = ids[i]; if (t) { // don't allow to remove default one k = kh_get(queries, list, t); if (k != kh_end(list)) { query = kh_value(list, k); kh_del(queries, list, k); free(query); if(active_samples_passed==query) active_samples_passed = NULL; } } } } noerrorShim(); }
GLint glRenderMode(GLenum mode) { int ret = 0; if ((mode==GL_SELECT) || (mode==GL_RENDER)) { // missing GL_FEEDBACK noerrorShim(); } else { errorShim(GL_INVALID_ENUM); return 0; } if (state.render_mode == GL_SELECT) { push_hit(); ret = state.selectbuf.count; } if (mode == GL_SELECT) { if (state.selectbuf.buffer == NULL) {// error, cannot use Select Mode without select buffer errorShim(GL_INVALID_OPERATION); return 0; } state.selectbuf.count = 0; state.selectbuf.pos = 0; state.selectbuf.overflow = 0; state.selectbuf.zmin = 1.0f; state.selectbuf.zmax = 0.0f; state.selectbuf.hit = 0; } if((mode==GL_SELECT) && (state.gl_batch)) { state.gl_batch = 0; flush(); } if((mode==GL_RENDER) && (state.gl_batch==0) && (gl_batch==1)) { state.gl_batch = 1; flush(); } state.render_mode = mode; return ret; }
void glPushAttrib(GLbitfield mask) { //printf("glPushAttrib(0x%04X)\n", mask); noerrorShim(); if ((state.list.compiling || state.gl_batch) && state.list.active) { NewStage(state.list.active, STAGE_PUSH); state.list.active->pushattribute = mask; return; } if (stack == NULL) { stack = (glstack_t *)malloc(STACK_SIZE * sizeof(glstack_t)); stack->len = 0; stack->cap = STACK_SIZE; } else if (stack->len == stack->cap) { stack->cap += STACK_SIZE; stack = (glstack_t *)realloc(stack, stack->cap * sizeof(glstack_t)); } glstack_t *cur = stack + stack->len; cur->mask = mask; cur->clip_planes_enabled = NULL; cur->clip_planes = NULL; cur->lights_enabled = NULL; cur->lights = NULL; // TODO: GL_ACCUM_BUFFER_BIT // TODO: will tracking these myself be much faster than glGet? if (mask & GL_COLOR_BUFFER_BIT) { cur->alpha_test = glIsEnabled(GL_ALPHA_TEST); glGetIntegerv(GL_ALPHA_TEST_FUNC, &cur->alpha_test_func); glGetFloatv(GL_ALPHA_TEST_REF, &cur->alpha_test_ref); cur->blend = glIsEnabled(GL_BLEND); glGetIntegerv(GL_BLEND_SRC, &cur->blend_src_func); glGetIntegerv(GL_BLEND_DST, &cur->blend_dst_func); cur->dither = glIsEnabled(GL_DITHER); cur->color_logic_op = glIsEnabled(GL_COLOR_LOGIC_OP); glGetIntegerv(GL_LOGIC_OP_MODE, &cur->logic_op); glGetFloatv(GL_COLOR_CLEAR_VALUE, cur->clear_color); glGetFloatv(GL_COLOR_WRITEMASK, cur->color_mask); } if (mask & GL_CURRENT_BIT) { glGetFloatv(GL_CURRENT_COLOR, cur->color); glGetFloatv(GL_CURRENT_NORMAL, cur->normal); glGetFloatv(GL_CURRENT_TEXTURE_COORDS, cur->tex); } if (mask & GL_DEPTH_BUFFER_BIT) { cur->depth_test = glIsEnabled(GL_DEPTH_TEST); glGetIntegerv(GL_DEPTH_FUNC, &cur->depth_func); glGetFloatv(GL_DEPTH_CLEAR_VALUE, &cur->clear_depth); glGetIntegerv(GL_DEPTH_WRITEMASK, &cur->depth_mask); } if (mask & GL_ENABLE_BIT) { int i; GLint max_clip_planes; cur->alpha_test = glIsEnabled(GL_ALPHA_TEST); cur->autonormal = glIsEnabled(GL_AUTO_NORMAL); cur->blend = glIsEnabled(GL_BLEND); glGetIntegerv(GL_MAX_CLIP_PLANES, &max_clip_planes); cur->clip_planes_enabled = (GLboolean *)malloc(max_clip_planes * sizeof(GLboolean)); for (i = 0; i < max_clip_planes; i++) { *(cur->clip_planes_enabled + i) = glIsEnabled(GL_CLIP_PLANE0 + i); } cur->colormaterial = glIsEnabled(GL_COLOR_MATERIAL); cur->cull_face = glIsEnabled(GL_CULL_FACE); cur->depth_test = glIsEnabled(GL_DEPTH_TEST); cur->dither = glIsEnabled(GL_DITHER); cur->fog = glIsEnabled(GL_FOG); GLint max_lights; glGetIntegerv(GL_MAX_LIGHTS, &max_lights); cur->lights_enabled = (GLboolean *)malloc(max_lights * sizeof(GLboolean)); for (i = 0; i < max_lights; i++) { *(cur->lights_enabled + i) = glIsEnabled(GL_LIGHT0 + i); } cur->lighting = glIsEnabled(GL_LIGHTING); cur->line_smooth = glIsEnabled(GL_LINE_SMOOTH); cur->line_stipple = glIsEnabled(GL_LINE_STIPPLE); cur->color_logic_op = glIsEnabled(GL_COLOR_LOGIC_OP); //TODO: GL_INDEX_LOGIC_OP //TODO: GL_MAP1_x //TODO: GL_MAP2_x cur->multisample = glIsEnabled(GL_MULTISAMPLE); cur->normalize = glIsEnabled(GL_NORMALIZE); cur->point_smooth = glIsEnabled(GL_POINT_SMOOTH); //TODO: GL_POLYGON_OFFSET_LINE cur->polygon_offset_fill = glIsEnabled(GL_POLYGON_OFFSET_FILL); //TODO: GL_POLYGON_OFFSET_POINT //TODO: GL_POLYGON_SMOOTH //TODO: GL_POLYGON_STIPPLE cur->sample_alpha_to_coverage = glIsEnabled(GL_SAMPLE_ALPHA_TO_COVERAGE); cur->sample_alpha_to_one = glIsEnabled(GL_SAMPLE_ALPHA_TO_ONE); cur->sample_coverage = glIsEnabled(GL_SAMPLE_COVERAGE); cur->scissor_test = glIsEnabled(GL_SCISSOR_TEST); cur->stencil_test = glIsEnabled(GL_STENCIL_TEST); int a; for (a=0; a<MAX_TEX; a++) { cur->texture_1d[a] = state.enable.texture_1d[a]; cur->texture_2d[a] = state.enable.texture_2d[a]; cur->texture_3d[a] = state.enable.texture_3d[a]; cur->texgen_s[a] = state.enable.texgen_s[a]; cur->texgen_r[a] = state.enable.texgen_r[a]; cur->texgen_t[a] = state.enable.texgen_t[a]; } } // TODO: GL_EVAL_BIT if (mask & GL_FOG_BIT) { cur->fog = glIsEnabled(GL_FOG); glGetFloatv(GL_FOG_COLOR, cur->fog_color); glGetFloatv(GL_FOG_DENSITY, &cur->fog_density); glGetFloatv(GL_FOG_START, &cur->fog_start); glGetFloatv(GL_FOG_END, &cur->fog_end); glGetIntegerv(GL_FOG_MODE, &cur->fog_mode); } if (mask & GL_HINT_BIT) { glGetIntegerv(GL_PERSPECTIVE_CORRECTION_HINT, &cur->perspective_hint); glGetIntegerv(GL_POINT_SMOOTH_HINT, &cur->point_smooth_hint); glGetIntegerv(GL_LINE_SMOOTH_HINT, &cur->line_smooth_hint); glGetIntegerv(GL_FOG_HINT, &cur->fog_hint); glGetIntegerv(GL_GENERATE_MIPMAP_HINT, &cur->mipmap_hint); } if (mask & GL_LIGHTING_BIT) { cur->lighting = glIsEnabled(GL_LIGHTING); glGetIntegerv(GL_LIGHT_MODEL_AMBIENT, cur->light_model_ambient); glGetIntegerv(GL_LIGHT_MODEL_TWO_SIDE, &cur->light_model_two_side); int i; GLint max_lights; glGetIntegerv(GL_MAX_LIGHTS, &max_lights); cur->lights_enabled = (GLboolean *)malloc(max_lights * sizeof(GLboolean)); cur->lights = (GLfloat *)malloc(max_lights * sizeof(GLfloat)); for (i = 0; i < max_lights; i++) { *(cur->lights_enabled + i) = glIsEnabled(GL_LIGHT0 + i); /* TODO: record all data about the lights glGetFloatv(GL_LIGHT0 + i, cur->lights + i); */ } glGetIntegerv(GL_SHADE_MODEL, &cur->shade_model); } if (mask & GL_LINE_BIT) { cur->line_smooth = glIsEnabled(GL_LINE_SMOOTH); // TODO: stipple stuff here glGetFloatv(GL_LINE_WIDTH, &cur->line_width); } // GL_LIST_BIT if (mask & GL_LIST_BIT) { cur->list_base = state.list.base; } if (mask & GL_MULTISAMPLE_BIT) { cur->multisample = glIsEnabled(GL_MULTISAMPLE); cur->sample_alpha_to_coverage = glIsEnabled(GL_SAMPLE_ALPHA_TO_COVERAGE); cur->sample_alpha_to_one = glIsEnabled(GL_SAMPLE_ALPHA_TO_ONE); cur->sample_coverage = glIsEnabled(GL_SAMPLE_COVERAGE); } // GL_PIXEL_MODE_BIT if (mask & GL_PIXEL_MODE_BIT) { GLenum pixel_name[] = {GL_RED_BIAS, GL_RED_SCALE, GL_GREEN_BIAS, GL_GREEN_SCALE, GL_BLUE_BIAS, GL_BLUE_SCALE, GL_ALPHA_BIAS, GL_ALPHA_SCALE}; int i; for (i=0; i<8; i++) glGetFloatv(pixel_name[i], &cur->pixel_scale_bias[i]); //TODO: GL_DEPTH_BIAS & GL_DEPTH_SCALE (probably difficult) //TODO: GL_INDEX_OFFEST & GL_INDEX_SHIFT //TODO: GL_MAP_COLOR & GL_MAP_STENCIL (probably difficult too) glGetFloatv(GL_ZOOM_X, &cur->pixel_zoomx); glGetFloatv(GL_ZOOM_Y, &cur->pixel_zoomy); } if (mask & GL_POINT_BIT) { cur->point_smooth = glIsEnabled(GL_POINT_SMOOTH); glGetFloatv(GL_POINT_SIZE, &cur->point_size); } // TODO: GL_POLYGON_BIT // TODO: GL_POLYGON_STIPPLE_BIT if (mask & GL_SCISSOR_BIT) { cur->scissor_test = glIsEnabled(GL_SCISSOR_TEST); glGetFloatv(GL_SCISSOR_BOX, cur->scissor_box); } // TODO: GL_STENCIL_BUFFER_BIT if (mask & GL_STENCIL_BUFFER_BIT) { cur->stencil_test = glIsEnabled(GL_STENCIL_TEST); glGetIntegerv(GL_STENCIL_FUNC, &cur->stencil_func); glGetIntegerv(GL_STENCIL_VALUE_MASK, &cur->stencil_mask); glGetIntegerv(GL_STENCIL_REF, &cur->stencil_ref); //TODO: glStencilFuncSeperate //TODO: Stencil value mask glGetIntegerv(GL_STENCIL_FAIL, &cur->stencil_sfail); glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, &cur->stencil_dpfail); glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, &cur->stencil_dppass); //TODO: glStencilOpSeparate glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &cur->stencil_clearvalue); //TODO: Stencil buffer writemask } // GL_TEXTURE_BIT - TODO: incomplete if (mask & GL_TEXTURE_BIT) { cur->active=state.texture.active; int a; for (a=0; a<MAX_TEX; a++) { cur->texgen_r[a] = state.enable.texgen_r[a]; cur->texgen_s[a] = state.enable.texgen_s[a]; cur->texgen_t[a] = state.enable.texgen_t[a]; cur->texgen[a] = state.texgen[a]; // all mode and planes per texture in 1 line cur->texture[a] = (state.texture.bound[a])?state.texture.bound[a]->texture:0; } //glActiveTexture(GL_TEXTURE0+cur->active); } // GL_TRANSFORM_BIT if (mask & GL_TRANSFORM_BIT) { if (!(mask & GL_ENABLE_BIT)) { int i; GLint max_clip_planes; glGetIntegerv(GL_MAX_CLIP_PLANES, &max_clip_planes); cur->clip_planes_enabled = (GLboolean *)malloc(max_clip_planes * sizeof(GLboolean)); for (i = 0; i < max_clip_planes; i++) { *(cur->clip_planes_enabled + i) = glIsEnabled(GL_CLIP_PLANE0 + i); } } glGetIntegerv(GL_MATRIX_MODE, &cur->matrix_mode); cur->rescale_normal_flag = glIsEnabled(GL_RESCALE_NORMAL); cur->normalize_flag = glIsEnabled(GL_NORMALIZE); } // GL_VIEWPORT_BIT if (mask & GL_VIEWPORT_BIT) { glGetIntegerv(GL_VIEWPORT, cur->viewport_size); glGetFloatv(GL_DEPTH_RANGE, cur->depth_range); } stack->len++; }
void glPopAttrib() { //printf("glPopAttrib()\n"); noerrorShim(); if ((state.list.compiling || state.gl_batch) && state.list.active) { NewStage(state.list.active, STAGE_POP); state.list.active->popattribute = true; return; } if (stack == NULL || stack->len == 0) { errorShim(GL_STACK_UNDERFLOW); return; } glstack_t *cur = stack + stack->len-1; if (cur->mask & GL_COLOR_BUFFER_BIT) { enable_disable(GL_ALPHA_TEST, cur->alpha_test); glAlphaFunc(cur->alpha_test_func, cur->alpha_test_ref); enable_disable(GL_BLEND, cur->blend); glBlendFunc(cur->blend_src_func, cur->blend_dst_func); enable_disable(GL_DITHER, cur->dither); enable_disable(GL_COLOR_LOGIC_OP, cur->color_logic_op); glLogicOp(cur->logic_op); GLfloat *c; glClearColor(v4(cur->clear_color)); glColorMask(v4(cur->color_mask)); } if (cur->mask & GL_CURRENT_BIT) { glColor4f(v4(cur->color)); glNormal3f(v3(cur->normal)); glTexCoord2f(v2(cur->tex)); } if (cur->mask & GL_DEPTH_BUFFER_BIT) { enable_disable(GL_DEPTH_TEST, cur->depth_test); glDepthFunc(cur->depth_func); glClearDepth(cur->clear_depth); glDepthMask(cur->depth_mask); } if (cur->mask & GL_ENABLE_BIT) { int i; enable_disable(GL_ALPHA_TEST, cur->alpha_test); enable_disable(GL_AUTO_NORMAL, cur->autonormal); enable_disable(GL_BLEND, cur->blend); GLint max_clip_planes; glGetIntegerv(GL_MAX_CLIP_PLANES, &max_clip_planes); for (i = 0; i < max_clip_planes; i++) { enable_disable(GL_CLIP_PLANE0 + i, *(cur->clip_planes_enabled + i)); } enable_disable(GL_COLOR_MATERIAL, cur->colormaterial); enable_disable(GL_CULL_FACE, cur->cull_face); enable_disable(GL_DEPTH_TEST, cur->depth_test); enable_disable(GL_DITHER, cur->dither); enable_disable(GL_FOG, cur->fog); GLint max_lights; glGetIntegerv(GL_MAX_LIGHTS, &max_lights); for (i = 0; i < max_lights; i++) { enable_disable(GL_LIGHT0 + i, *(cur->lights_enabled + i)); } enable_disable(GL_LIGHTING, cur->lighting); enable_disable(GL_LINE_SMOOTH, cur->line_smooth); enable_disable(GL_LINE_STIPPLE, cur->line_stipple); enable_disable(GL_COLOR_LOGIC_OP, cur->color_logic_op); //TODO: GL_INDEX_LOGIC_OP //TODO: GL_MAP1_x //TODO: GL_MAP2_x enable_disable(GL_MULTISAMPLE, cur->multisample); enable_disable(GL_NORMALIZE, cur->normalize); enable_disable(GL_POINT_SMOOTH, cur->point_smooth); //TODO: GL_POLYGON_OFFSET_LINE enable_disable(GL_POLYGON_OFFSET_FILL, cur->polygon_offset_fill); //TODO: GL_POLYGON_OFFSET_POINT //TODO: GL_POLYGON_SMOOTH //TODO: GL_POLYGON_STIPPLE enable_disable(GL_SAMPLE_ALPHA_TO_COVERAGE, cur->sample_alpha_to_coverage); enable_disable(GL_SAMPLE_ALPHA_TO_ONE, cur->sample_alpha_to_one); enable_disable(GL_SAMPLE_COVERAGE, cur->sample_coverage); enable_disable(GL_SCISSOR_TEST, cur->scissor_test); enable_disable(GL_STENCIL_TEST, cur->stencil_test); int a; int old_tex = state.texture.active; for (a=0; a<MAX_TEX; a++) { if (state.enable.texture_1d[a] != cur->texture_1d[a]) { glActiveTexture(GL_TEXTURE0+a); enable_disable(GL_TEXTURE_1D, cur->texture_1d[a]); } if (state.enable.texture_2d[a] != cur->texture_2d[a]) { glActiveTexture(GL_TEXTURE0+a); enable_disable(GL_TEXTURE_2D, cur->texture_2d[a]); } if (state.enable.texture_3d[a] != cur->texture_3d[a]) { glActiveTexture(GL_TEXTURE0+a); enable_disable(GL_TEXTURE_3D, cur->texture_3d[a]); } state.enable.texgen_r[a] = cur->texgen_r[a]; state.enable.texgen_s[a] = cur->texgen_s[a]; state.enable.texgen_t[a] = cur->texgen_t[a]; } if (state.texture.active != old_tex) glActiveTexture(GL_TEXTURE0+old_tex); } if (cur->mask & GL_FOG_BIT) { enable_disable(GL_FOG, cur->fog); glFogfv(GL_FOG_COLOR, cur->fog_color); glFogf(GL_FOG_DENSITY, cur->fog_density); glFogf(GL_FOG_START, cur->fog_start); glFogf(GL_FOG_END, cur->fog_end); glFogf(GL_FOG_MODE, cur->fog_mode); } if (cur->mask & GL_HINT_BIT) { enable_disable(GL_PERSPECTIVE_CORRECTION_HINT, cur->perspective_hint); enable_disable(GL_POINT_SMOOTH_HINT, cur->point_smooth_hint); enable_disable(GL_LINE_SMOOTH_HINT, cur->line_smooth_hint); enable_disable(GL_FOG_HINT, cur->fog_hint); enable_disable(GL_GENERATE_MIPMAP_HINT, cur->mipmap_hint); } // GL_LIST_BIT if (cur->mask & GL_LIST_BIT) { glListBase(cur->list_base); } if (cur->mask & GL_LINE_BIT) { enable_disable(GL_LINE_SMOOTH, cur->line_smooth); // TODO: stipple stuff here glLineWidth(cur->line_width); } if (cur->mask & GL_MULTISAMPLE_BIT) { enable_disable(GL_MULTISAMPLE, cur->multisample); enable_disable(GL_SAMPLE_ALPHA_TO_COVERAGE, cur->sample_alpha_to_coverage); enable_disable(GL_SAMPLE_ALPHA_TO_ONE, cur->sample_alpha_to_one); enable_disable(GL_SAMPLE_COVERAGE, cur->sample_coverage); } if (cur->mask & GL_POINT_BIT) { enable_disable(GL_POINT_SMOOTH, cur->point_smooth); glPointSize(cur->point_size); } if (cur->mask & GL_SCISSOR_BIT) { enable_disable(GL_SCISSOR_TEST, cur->scissor_test); glScissor(v4(cur->scissor_box)); } if (cur->mask & GL_STENCIL_BUFFER_BIT) { enable_disable(GL_STENCIL_TEST, cur->stencil_test); glStencilFunc(cur->stencil_func, cur->stencil_ref, cur->stencil_mask); //TODO: Stencil value mask glStencilOp(cur->stencil_sfail, cur->stencil_dpfail, cur->stencil_dppass); glClearStencil(cur->stencil_clearvalue); //TODO: Stencil buffer writemask } if (cur->mask & GL_TEXTURE_BIT) { int a; //TODO: Enable bit for the 4 texture coordinates for (a=0; a<MAX_TEX; a++) { state.enable.texgen_r[a] = cur->texgen_r[a]; state.enable.texgen_s[a] = cur->texgen_s[a]; state.enable.texgen_t[a] = cur->texgen_t[a]; state.texgen[a] = cur->texgen[a]; // all mode and planes per texture in 1 line if ((cur->texture[a]==0 && state.texture.bound[a] != 0) || (cur->texture[a]!=0 && state.texture.bound[a]==0)) { glActiveTexture(GL_TEXTURE0+a); glBindTexture(GL_TEXTURE_2D, cur->texture[a]); } } if (state.texture.active!= cur->active) glActiveTexture(GL_TEXTURE0+cur->active); } if (cur->mask & GL_PIXEL_MODE_BIT) { GLenum pixel_name[] = {GL_RED_BIAS, GL_RED_SCALE, GL_GREEN_BIAS, GL_GREEN_SCALE, GL_BLUE_BIAS, GL_BLUE_SCALE, GL_ALPHA_BIAS, GL_ALPHA_SCALE}; int i; for (i=0; i<8; i++) glPixelTransferf(pixel_name[i], cur->pixel_scale_bias[i]); //TODO: GL_DEPTH_BIAS & GL_DEPTH_SCALE (probably difficult) //TODO: GL_INDEX_OFFEST & GL_INDEX_SHIFT //TODO: GL_MAP_COLOR & GL_MAP_STENCIL (probably difficult too) glPixelZoom(cur->pixel_zoomx, cur->pixel_zoomy); } if (cur->mask & GL_TRANSFORM_BIT) { if (!(cur->mask & GL_ENABLE_BIT)) { int i; GLint max_clip_planes; glGetIntegerv(GL_MAX_CLIP_PLANES, &max_clip_planes); for (i = 0; i < max_clip_planes; i++) { enable_disable(GL_CLIP_PLANE0 + i, *(cur->clip_planes_enabled + i)); } } glMatrixMode(cur->matrix_mode); enable_disable(GL_NORMALIZE, cur->normalize_flag); enable_disable(GL_RESCALE_NORMAL, cur->rescale_normal_flag); } if (cur->mask & GL_VIEWPORT_BIT) { glViewport(cur->viewport_size[0], cur->viewport_size[1], cur->viewport_size[2], cur->viewport_size[3]); glDepthRangef(cur->depth_range[0], cur->depth_range[1]); } maybe_free(cur->clip_planes_enabled); maybe_free(cur->clip_planes); maybe_free(cur->lights_enabled); maybe_free(cur->lights); stack->len--; }
void gl4es_glSelectBuffer(GLsizei size, GLuint *buffer) { noerrorShim(); glstate->selectbuf.buffer = buffer; glstate->selectbuf.size = size; }
void gl4es_glPopAttrib() { //printf("glPopAttrib()\n"); noerrorShim(); if ((glstate->list.compiling || glstate->gl_batch) && glstate->list.active) { NewStage(glstate->list.active, STAGE_POP); glstate->list.active->popattribute = true; return; } if (glstate->stack == NULL || glstate->stack->len == 0) { errorShim(GL_STACK_UNDERFLOW); return; } glstack_t *cur = glstate->stack + glstate->stack->len-1; if (cur->mask & GL_COLOR_BUFFER_BIT) { enable_disable(GL_ALPHA_TEST, cur->alpha_test); gl4es_glAlphaFunc(cur->alpha_test_func, cur->alpha_test_ref); enable_disable(GL_BLEND, cur->blend); gl4es_glBlendFunc(cur->blend_src_func, cur->blend_dst_func); enable_disable(GL_DITHER, cur->dither); enable_disable(GL_COLOR_LOGIC_OP, cur->color_logic_op); gl4es_glLogicOp(cur->logic_op); GLfloat *c; gl4es_glClearColor(v4(cur->clear_color)); gl4es_glColorMask(v4(cur->color_mask)); } if (cur->mask & GL_CURRENT_BIT) { gl4es_glColor4f(v4(cur->color)); gl4es_glNormal3f(v3(cur->normal)); gl4es_glTexCoord4f(v4(cur->tex)); } if (cur->mask & GL_DEPTH_BUFFER_BIT) { enable_disable(GL_DEPTH_TEST, cur->depth_test); gl4es_glDepthFunc(cur->depth_func); gl4es_glClearDepth(cur->clear_depth); gl4es_glDepthMask(cur->depth_mask); } if (cur->mask & GL_ENABLE_BIT) { int i; enable_disable(GL_ALPHA_TEST, cur->alpha_test); enable_disable(GL_AUTO_NORMAL, cur->autonormal); enable_disable(GL_BLEND, cur->blend); GLint max_clip_planes; gl4es_glGetIntegerv(GL_MAX_CLIP_PLANES, &max_clip_planes); for (i = 0; i < max_clip_planes; i++) { enable_disable(GL_CLIP_PLANE0 + i, *(cur->clip_planes_enabled + i)); } enable_disable(GL_COLOR_MATERIAL, cur->colormaterial); enable_disable(GL_CULL_FACE, cur->cull_face); enable_disable(GL_DEPTH_TEST, cur->depth_test); enable_disable(GL_DITHER, cur->dither); enable_disable(GL_FOG, cur->fog); for (i = 0; i < hardext.maxlights; i++) { enable_disable(GL_LIGHT0 + i, *(cur->lights_enabled + i)); } enable_disable(GL_LIGHTING, cur->lighting); enable_disable(GL_LINE_SMOOTH, cur->line_smooth); enable_disable(GL_LINE_STIPPLE, cur->line_stipple); enable_disable(GL_COLOR_LOGIC_OP, cur->color_logic_op); //TODO: GL_INDEX_LOGIC_OP //TODO: GL_MAP1_x //TODO: GL_MAP2_x enable_disable(GL_MULTISAMPLE, cur->multisample); enable_disable(GL_NORMALIZE, cur->normalize); enable_disable(GL_POINT_SMOOTH, cur->point_smooth); //TODO: GL_POLYGON_OFFSET_LINE enable_disable(GL_POLYGON_OFFSET_FILL, cur->polygon_offset_fill); //TODO: GL_POLYGON_OFFSET_POINT //TODO: GL_POLYGON_SMOOTH //TODO: GL_POLYGON_STIPPLE enable_disable(GL_SAMPLE_ALPHA_TO_COVERAGE, cur->sample_alpha_to_coverage); enable_disable(GL_SAMPLE_ALPHA_TO_ONE, cur->sample_alpha_to_one); enable_disable(GL_SAMPLE_COVERAGE, cur->sample_coverage); enable_disable(GL_SCISSOR_TEST, cur->scissor_test); enable_disable(GL_STENCIL_TEST, cur->stencil_test); enable_disable(GL_POINT_SPRITE, cur->pointsprite); int a; int old_tex = glstate->texture.active; for (a=0; a<hardext.maxtex; a++) { if(glstate->enable.texture[a] != cur->tex_enabled[a]) { gl4es_glActiveTexture(GL_TEXTURE0+a); for (int j=0; j<ENABLED_TEXTURE_LAST; j++) { const GLuint t = cur->tex_enabled[a] & (1<<j); if ((glstate->enable.texture[a] & (1<<j)) != t) { enable_disable(to_target(j), t); } } } glstate->enable.texgen_r[a] = cur->texgen_r[a]; glstate->enable.texgen_s[a] = cur->texgen_s[a]; glstate->enable.texgen_t[a] = cur->texgen_t[a]; glstate->enable.texgen_q[a] = cur->texgen_q[a]; } if (glstate->texture.active != old_tex) gl4es_glActiveTexture(GL_TEXTURE0+old_tex); } if (cur->mask & GL_FOG_BIT) { enable_disable(GL_FOG, cur->fog); gl4es_glFogfv(GL_FOG_COLOR, cur->fog_color); gl4es_glFogf(GL_FOG_DENSITY, cur->fog_density); gl4es_glFogf(GL_FOG_START, cur->fog_start); gl4es_glFogf(GL_FOG_END, cur->fog_end); gl4es_glFogf(GL_FOG_MODE, cur->fog_mode); } if (cur->mask & GL_HINT_BIT) { gl4es_glHint(GL_PERSPECTIVE_CORRECTION_HINT, cur->perspective_hint); gl4es_glHint(GL_POINT_SMOOTH_HINT, cur->point_smooth_hint); gl4es_glHint(GL_LINE_SMOOTH_HINT, cur->line_smooth_hint); gl4es_glHint(GL_FOG_HINT, cur->fog_hint); gl4es_glHint(GL_GENERATE_MIPMAP_HINT, cur->mipmap_hint); for (int i=GL4ES_HINT_FIRST; i<GL4ES_HINT_LAST; i++) gl4es_glHint(i, cur->gles4_hint[i-GL4ES_HINT_FIRST]); } if (cur->mask & GL_LIGHTING_BIT) { enable_disable(GL_LIGHTING, cur->lighting); gl4es_glLightModelfv(GL_LIGHT_MODEL_AMBIENT, cur->light_model_ambient); gl4es_glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, cur->light_model_two_side); int i; int j=0; for (i = 0; i < hardext.maxlights; i++) { enable_disable(GL_LIGHT0 + i, *(cur->lights_enabled + i)); #define L(A) gl4es_glLightfv(GL_LIGHT0 + i, A, cur->lights+j); j+=4 L(GL_AMBIENT); L(GL_DIFFUSE); L(GL_SPECULAR); L(GL_POSITION); L(GL_SPOT_CUTOFF); L(GL_SPOT_DIRECTION); L(GL_SPOT_EXPONENT); L(GL_CONSTANT_ATTENUATION); L(GL_LINEAR_ATTENUATION); L(GL_QUADRATIC_ATTENUATION); #undef L } j=0; #define M(A) gl4es_glMaterialfv(GL_FRONT_AND_BACK, A, cur->materials+j); j+=4 M(GL_AMBIENT); M(GL_DIFFUSE); M(GL_SPECULAR); M(GL_EMISSION); M(GL_SHININESS); // handle both face at some point? #undef M gl4es_glShadeModel(cur->shade_model); } // GL_LIST_BIT if (cur->mask & GL_LIST_BIT) { gl4es_glListBase(cur->list_base); } if (cur->mask & GL_LINE_BIT) { enable_disable(GL_LINE_SMOOTH, cur->line_smooth); // TODO: stipple stuff here gl4es_glLineWidth(cur->line_width); } if (cur->mask & GL_MULTISAMPLE_BIT) { enable_disable(GL_MULTISAMPLE, cur->multisample); enable_disable(GL_SAMPLE_ALPHA_TO_COVERAGE, cur->sample_alpha_to_coverage); enable_disable(GL_SAMPLE_ALPHA_TO_ONE, cur->sample_alpha_to_one); enable_disable(GL_SAMPLE_COVERAGE, cur->sample_coverage); } if (cur->mask & GL_POINT_BIT) { enable_disable(GL_POINT_SMOOTH, cur->point_smooth); gl4es_glPointSize(cur->point_size); if(hardext.pointsprite) { enable_disable(GL_POINT_SPRITE, cur->pointsprite); int a; for (a=0; a<hardext.maxtex; a++) { if(glstate->texture.pscoordreplace[a]!=cur->pscoordreplace[a]) { gl4es_glActiveTexture(GL_TEXTURE0+a); gl4es_glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, cur->pscoordreplace[a]); } } if (glstate->texture.active!= cur->active) gl4es_glActiveTexture(GL_TEXTURE0+cur->active); } } if (cur->mask & GL_SCISSOR_BIT) { enable_disable(GL_SCISSOR_TEST, cur->scissor_test); gl4es_glScissor(v4(cur->scissor_box)); } if (cur->mask & GL_STENCIL_BUFFER_BIT) { enable_disable(GL_STENCIL_TEST, cur->stencil_test); gl4es_glStencilFunc(cur->stencil_func, cur->stencil_ref, cur->stencil_mask); //TODO: Stencil value mask gl4es_glStencilOp(cur->stencil_sfail, cur->stencil_dpfail, cur->stencil_dppass); gl4es_glClearStencil(cur->stencil_clearvalue); //TODO: Stencil buffer writemask } if (cur->mask & GL_TEXTURE_BIT) { int a; //TODO: Enable bit for the 4 texture coordinates for (a=0; a<hardext.maxtex; a++) { glstate->enable.texgen_r[a] = cur->texgen_r[a]; glstate->enable.texgen_s[a] = cur->texgen_s[a]; glstate->enable.texgen_t[a] = cur->texgen_t[a]; glstate->enable.texgen_q[a] = cur->texgen_q[a]; glstate->texgen[a] = cur->texgen[a]; // all mode and planes per texture in 1 line for (int j=0; j<ENABLED_TEXTURE_LAST; j++) if ((cur->texture[a][j]==0 && glstate->texture.bound[a][j] != 0) || (cur->texture[a][j]!=0 && glstate->texture.bound[a][j]==0)) { gl4es_glActiveTexture(GL_TEXTURE0+a); gl4es_glBindTexture(to_target(j), cur->texture[a][j]); } } if (glstate->texture.active!= cur->active) gl4es_glActiveTexture(GL_TEXTURE0+cur->active); } if (cur->mask & GL_PIXEL_MODE_BIT) { GLenum pixel_name[] = {GL_RED_BIAS, GL_RED_SCALE, GL_GREEN_BIAS, GL_GREEN_SCALE, GL_BLUE_BIAS, GL_BLUE_SCALE, GL_ALPHA_BIAS, GL_ALPHA_SCALE}; int i; for (i=0; i<8; i++) gl4es_glPixelTransferf(pixel_name[i], cur->pixel_scale_bias[i]); //TODO: GL_DEPTH_BIAS & GL_DEPTH_SCALE (probably difficult) //TODO: GL_INDEX_OFFEST & GL_INDEX_SHIFT //TODO: GL_MAP_COLOR & GL_MAP_STENCIL (probably difficult too) gl4es_glPixelZoom(cur->pixel_zoomx, cur->pixel_zoomy); } if (cur->mask & GL_TRANSFORM_BIT) { if (!(cur->mask & GL_ENABLE_BIT)) { int i; GLint max_clip_planes; gl4es_glGetIntegerv(GL_MAX_CLIP_PLANES, &max_clip_planes); for (i = 0; i < max_clip_planes; i++) { enable_disable(GL_CLIP_PLANE0 + i, *(cur->clip_planes_enabled + i)); } } gl4es_glMatrixMode(cur->matrix_mode); enable_disable(GL_NORMALIZE, cur->normalize_flag); enable_disable(GL_RESCALE_NORMAL, cur->rescale_normal_flag); } if (cur->mask & GL_VIEWPORT_BIT) { gl4es_glViewport(cur->viewport_size[0], cur->viewport_size[1], cur->viewport_size[2], cur->viewport_size[3]); gl4es_glDepthRangef(cur->depth_range[0], cur->depth_range[1]); } maybe_free(cur->clip_planes_enabled); maybe_free(cur->clip_planes); maybe_free(cur->lights_enabled); maybe_free(cur->lights); maybe_free(cur->materials); glstate->stack->len--; }
void glSelectBuffer(GLsizei size, GLuint *buffer) { noerrorShim(); state.selectbuf.buffer = buffer; state.selectbuf.size = size; }