Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDL2 OpenGL3 example not working on OSX 10.11.2 / Geforce 9400M #468

Closed
spate opened this issue Jan 2, 2016 · 5 comments
Closed

SDL2 OpenGL3 example not working on OSX 10.11.2 / Geforce 9400M #468

spate opened this issue Jan 2, 2016 · 5 comments

Comments

@spate
Copy link

spate commented Jan 2, 2016

The SDL + OpenGL 3 example app isn't working on OSX 10.11.2 on my Geforce 9400M. The SDL + OpenGL (compatibility) example app is working fine. (Using top of tree.)

@Erkaman
Copy link

Erkaman commented Jan 3, 2016

Same thing happens for me on OS X 10.10.3. sdl_opengl_example works fine, but in sdl_opengl3_example no windows are drawn:

screen shot 2016-01-03 at 22 40 34

@ocornut
Copy link
Owner

ocornut commented Jan 3, 2016

Issue was reported recently in #463 but not solved. I haven't personally tried this code on a Mac.

Could you try: a/ the suggestions in that other thread? b/ disabling scissoring in the render function and see if it makes a difference?

Otherwise have a look at whatever error reporting SDL2 offers, it may give a clue. The core profile version looks definitively wrong to me but the poster of the other thread said it didn't fix the issue.

@Erkaman
Copy link

Erkaman commented Jan 3, 2016

I have been able to solve the problem: Go to sdl_opengl3_example/main.cpp and replace this code:

    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
    SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);

With this:

    SDL_GL_SetAttribute (SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG);
    SDL_GL_SetAttribute (SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
    SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);

The problem with the original code was that an OpenGL context of version 2.2(a compability profile) was created. However, the shaders in imgui_impl_sdl_gl3.cpp were using shader version 330, and this version can only be used in a core profile. Thus they would not compile.

So a core profile had to be created instead. However, you must be very careful when creating a core profile on mac. You have to set SDL_GL_CONTEXT_FLAGS to SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG and set SDL_GL_CONTEXT_PROFILE_MASK to SDL_GL_CONTEXT_PROFILE_CORE. Otherwise, it will fail.

@ocornut
Copy link
Owner

ocornut commented Jan 4, 2016

Thanks for looking into it
It looks like SDL_GL_SetAttribute (SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); was missing from my proposed fix in #463
I will merge the fix in master shortly!

@ocornut
Copy link
Owner

ocornut commented Jan 5, 2016

Closing, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants