Search code examples
openglsdlrenderdoc

RenderDOC and SDL2


I want to debug my program with RenderDoc. I created my context with the standard SDL_GL_CreateContext function. I get this error when running the application using RenderDoc:

Capturing OpenGL. Context not created via CreateContextAttribs. Capturing disabled. Only OpenGL 3.2+ contexts are supported.

I added this argument before I created my context:

SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);

That should force a core profile, yet the error is still there.

What am I doing wrong here?

-----Edit-----

Even after forcing version 3.2 (exact version required) the thing still complaints.

Here is the init block of my window class:

//System init


if(!SDL_WasInit(SDL_INIT_EVERYTHING))
    SDL_Init(SDL_INIT_EVERYTHING);

this->SDL_window = SDL_CreateWindow(title,10,10,w,h,SDL_WINDOW_OPENGL);
if(this->SDL_window!=NULL)
{
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);

    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);

    this->context = SDL_GL_CreateContext(SDL_window);
    if(!this->context)
    {
        SDL_DestroyWindow(SDL_window);
        COUT<<"FAILED TO CREATE CONTEXT. PRINTING ERROR AND THROWING EXCEPTION"<<ENDL;
        COUT<<SDL_GetError()<<ENDL;
        throw "ENGINE::WINDOW::GLCONTEXTERR";
    }
        glewExperimental = GL_TRUE;
        glewInit();
}
else
{
    COUT<<"FAILED TO CREATE WINDOW. PRINTING ERROR AND THROWING EXCEPTION"<<ENDL;
    COUT<<SDL_GetError()<<ENDL;
    throw "ENGINE::WINDOW::SDLWINDOWERR";
}
 

Solution

  • The error message is very clear: Your program doesn't use a OpenGL 3.2+ context.

    Since you only request a specific major version but not a minor version, you most probably get a 3.0 context. To solve the problem add

    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);