Jump to content
  • Advertisement
Sign in to follow this  
trippytarka

OpenGL GLSL+SDL_SetVideoMode [RESOLVED]

This topic is 4826 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does anyone know how to deal with this correctly? When I switch video modes I lose my shaders. I've tried all sorts of combinations of recreating them, but I get GL errors when I call any of glDeleteObjectARB, glCreateShaderObjectARB or glShaderSourceARB. This is what I'm currently doing:
for (int i = 0; i < 2; i++) {
    glShaderSourceARB(id, 1, &cbuf, NULL);
    glCompileShaderARB(shader);
}
glLinkProgramARB(program);
EDIT: When you lose the OpenGL context all shader and program objects are destroyed, so they have to be recreated as follows :
// dont use glDeleteObjectARB before glCreate...ARB
program = glCreateProgramObjectARB();
for (int i = 0; i < 2; i++) {
    id = glCreateShaderObjectARB(type);
    glShaderSourceARB(id, 1, &cbuf, NULL);
    glCompileShaderARB(shader);
    glAttachObjectARB(program, id);
}
glLinkProgramARB(program);
The only caveat to this is that glAttachObjectARB will produce a GL_INVALID_OPERATION error due to the shader already being attached. [Edited by - trippytarka on September 24, 2005 10:20:39 AM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!