Since glPushAttrib/glPopAttrib are deprecated, what is the new way to save attributes like GL_DEPTH_FUNC?
c, deprecated, opengl, opengl-3, shader
Solution
I think this forum post on opengl.org pretty much sums it up: http://www.opengl.org/discussion_boards/showthread.php/173957-glPushAttrib-depreciated-replace-by
Basically OpenGL state is expected to be handled by the client, because with the move to shaders most of the attributes will be stored in your program anyway. It's part of the push to remove the old fixed-function pipeline from OpenGL.
Problem
I'm trying to write modern OpenGL, but have hit something that bugs me. I have this bit of code: ``` glUseProgram(skybox_program->id); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_CUBE_MAP, skybox->id); glUniform1i(get_program_uniform(skybox_program, "cubemap_tex"), 1); //From here GLint save_cull_mode, save_depth_mode; glGetIntegerv(GL_CULL_FACE_MODE, &save_cull_mode); glGetIntegerv(GL_DEPTH_FUNC, &save_depth_mode); glCullFace(GL_FRONT); glDepthFunc(GL_LEQUAL); //To here glUniformMatrix4fv(get_program_uniform(skybox_program, "camera"), 1, GL_FALSE, cam_rot.mat); glBindVertexArray(skybox_vao); glDrawArrays(GL_TRIANGLES, 0, 6 * 2 * 3); //And these next 2 lines glCullFace(save_cull_mode); glDepthFunc(save_depth_mode); glUseProgram(0); ``` This code, as you probably realized, draws a skybox. Part of this is disabling culling (so we can see the box while inside it) and changing the depth func (basically an optimization, part of which is in the shader and part here). I want to save and restore these values, but because I can't use `gl[Push/Pop]Attrib`, I have to do it myself. This isn't a big deal with just two attributes, but if I used more this would quickly become a huge pain (and, as I understand, slow, since `glGet*` isn't very fast). I read that the push/pop functions were deprecated because they were mostly used to handle FFP state, but this obviously isn't FFP state and yet the push/pop functions would be a good fit to use. What should I use instead? Or do I have to just deal with it?