void glPopClientAttrib() { glclientstack_t *cur = tack_pop(&state.stack.client); if (cur == NULL) { ERROR(GL_STACK_UNDERFLOW); } if (cur->mask & GL_CLIENT_PIXEL_STORE_BIT) { glPixelStorei(GL_PACK_ALIGNMENT, cur->pack_align); glPixelStorei(GL_UNPACK_ALIGNMENT, cur->unpack_align); glPixelStorei(GL_UNPACK_ROW_LENGTH, cur->unpack_row_length); glPixelStorei(GL_UNPACK_SKIP_PIXELS, cur->unpack_skip_pixels); glPixelStorei(GL_UNPACK_SKIP_ROWS, cur->unpack_skip_rows); } if (cur->mask & GL_CLIENT_VERTEX_ARRAY_BIT) { enable_disable(GL_VERTEX_ARRAY, cur->vert_enable); enable_disable(GL_NORMAL_ARRAY, cur->normal_enable); enable_disable(GL_COLOR_ARRAY, cur->color_enable); for (int i = 0; i < MAX_TEX; i++) { GLboolean bit = cur->tex_enable[i]; if (bit != state.enable.tex_coord_array[i]) { enable_disable(GL_TEXTURE_COORD_ARRAY, bit); } } memcpy(&state.pointers.vertex, &cur->verts, sizeof(pointer_state_t)); memcpy(&state.pointers.color, &cur->color, sizeof(pointer_state_t)); memcpy(&state.pointers.normal, &cur->normal, sizeof(pointer_state_t)); memcpy(&state.pointers.tex_coord, &cur->tex, sizeof(pointer_state_t) * MAX_TEX); } free(cur); }
void glPopName() { ERROR_IN_BLOCK(); if (state.render.mode != GL_SELECT) { return; } if (tack_pop(&state.select.names) == NULL) { ERROR(GL_STACK_UNDERFLOW); } }
void glPopAttrib() { ERROR_IN_BLOCK(); glstack_t *cur = tack_pop(&state.stack.attrib); if (cur == NULL) { ERROR(GL_STACK_UNDERFLOW); } if (cur->mask & GL_COLOR_BUFFER_BIT) { #ifndef USE_ES2 enable_disable(GL_ALPHA_TEST, cur->alpha_test); glAlphaFunc(cur->alpha_test_func, cur->alpha_test_ref); #endif enable_disable(GL_BLEND, cur->blend); glBlendFunc(cur->blend_src_func, cur->blend_dst_func); enable_disable(GL_DITHER, cur->dither); #ifndef USE_ES2 enable_disable(GL_COLOR_LOGIC_OP, cur->color_logic_op); glLogicOp(cur->logic_op); #endif GLfloat *c; glClearColor(v4(cur->clear_color)); glColorMask(v4(cur->color_mask)); } if (cur->mask & GL_CURRENT_BIT) { glColor4f(v4(cur->color)); #ifndef USE_ES2 glNormal3f(v3(cur->normal)); #endif for (int i = 0; i < MAX_TEX; i++) { glMultiTexCoord2f(GL_TEXTURE0 + i, v2(cur->tex[i])); } } 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; 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)); } 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_ALPHA_TEST, cur->alpha_test); enable_disable(GL_BLEND, cur->blend); 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); 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); enable_disable(GL_MULTISAMPLE, cur->multisample); enable_disable(GL_NORMALIZE, cur->normalize); enable_disable(GL_POINT_SMOOTH, cur->point_smooth); enable_disable(GL_POLYGON_OFFSET_FILL, cur->polygon_offset_fill); 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_TEXTURE_2D, cur->texture_2d); } #ifndef USE_ES2 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); } #endif 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); } 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); } #ifndef USE_ES2 if (cur->mask & GL_POINT_BIT) { enable_disable(GL_POINT_SMOOTH, cur->point_smooth); glPointSize(cur->point_size); } #endif if (cur->mask & GL_SCISSOR_BIT) { enable_disable(GL_SCISSOR_TEST, cur->scissor_test); glScissor(v4(cur->scissor_box)); } if (cur->mask & GL_TEXTURE_BIT) { glBindTexture(GL_TEXTURE_2D, cur->texture); } free(cur->clip_planes_enabled); free(cur->clip_planes); free(cur->lights_enabled); free(cur->lights); free(cur); }