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

OS X 10.7.5 - ogl_LoadFunctions() fails when creating a 3.2 context with SDL 2 #26

Closed
miguelmartin75 opened this Issue Nov 8, 2013 · 4 comments

Comments

Projects
2 participants
@miguelmartin75
Contributor

miguelmartin75 commented Nov 8, 2013

When creating a OpenGL 3.2 context, on OS X 10.7.5 with SDL 2.0 (the framework binary, which is downloadable from the website), with the following code (ignore the logs, they are just used for debugging purposes):

LOG(INFO) << "Setting OpenGL context settings";

/* Require an OpenGL 3.2 context */
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);

/* Enable double buffering and 24bt depth buffer */
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);

/* Multisampling */
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, _config.sampleCount > 1 ? 1 : 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, _config.sampleCount);

// Create the Window
LOG(INFO) << "Creating Window...";

_window = SDL_CreateWindow(_windowSettings.title.c_str(),
                                              SDL_WINDOWPOS_CENTERED,
                                              SDL_WINDOWPOS_CENTERED,
                               (_config.windowWidth == Config::DEFAULT_WIDTH ? _windowSettings.defaultWidth : _config.windowWidth),
                               (_config.windowHeight == Config::DEFAULT_HEIGHT ? _windowSettings.defaultHeight : _config.windowHeight),
                               _windowSettings.flags | SDL_WINDOW_OPENGL);

if(!_window)
{
    LOG(FATAL) << "Failed to create Window!";
    LOG(FATAL) << "Reason:" << SDL_GetError();
    getGame().quit(FAILED_TO_CREATE_WINDOW);
    return;
}
LOG(INFO) << "Successfully created Window";

// Create our context
LOG(INFO) << "Creating OpenGL Context";
_context = SDL_GL_CreateContext(_window);
if(!_context)
{
    LOG(FATAL) << "Failed to create OpenGL context";
    LOG(FATAL) << "Reason: " << SDL_GetError();

    getGame().quit(FAILED_TO_CREATE_OPENGL_CONTEXT);
    return;
}

LOG(INFO) << "Successfully created OpenGL Context";

LOG(INFO) << "Creating Magnum Context!\n";

_magnumContext.reset(new Magnum::Context); // make a magnum context

LOG(INFO) << "Successfully created Magnum Context!\n";

// log graphics information
logGraphicsInformation();

It fails due to creating a Magnum context, as ogl_LoadFunctions is called in the constructor of Context. The error is during run-time and only occurs when I have SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); in the code. Without SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);, SDL2 does not create a 3.2 context (it will default to 2.1, in which case I can't use the in-built shaders). The runtime error received is: EXC_BAD_ACCESS in ogl_LoadFunctions() on line 2702 of gl_magnum.c.

@mosra

This comment has been minimized.

Show comment
Hide comment
@mosra

mosra Nov 8, 2013

Owner

I know where the problem is and I hoped this issue will never appear. The gl_magnum.c file is generated by glLoadGen, which currently uses glGetString(GL_EXTENSIONS) for getting extension list. This API is removed from core OpenGL and is replaced with glGetStringi(GL_EXTENSIONS, i). Sadly this change not backed by any extension which could be exposed in older GL, so I had to keep the old one for pre-3.0 drivers (Mesa on Linux) and hoped that it would be supported in newer ones as well. I need to fix that and use the proper one based on GL version.

By the way, what is your LOG(INFO)/LOG(FATAL) macro doing (even that you said I should ignore it)? Is it something else than alias to Debug()/Error()?

Owner

mosra commented Nov 8, 2013

I know where the problem is and I hoped this issue will never appear. The gl_magnum.c file is generated by glLoadGen, which currently uses glGetString(GL_EXTENSIONS) for getting extension list. This API is removed from core OpenGL and is replaced with glGetStringi(GL_EXTENSIONS, i). Sadly this change not backed by any extension which could be exposed in older GL, so I had to keep the old one for pre-3.0 drivers (Mesa on Linux) and hoped that it would be supported in newer ones as well. I need to fix that and use the proper one based on GL version.

By the way, what is your LOG(INFO)/LOG(FATAL) macro doing (even that you said I should ignore it)? Is it something else than alias to Debug()/Error()?

@ghost ghost assigned mosra Nov 8, 2013

@miguelmartin75

This comment has been minimized.

Show comment
Hide comment
@miguelmartin75

miguelmartin75 Nov 9, 2013

Contributor

By the way, what is your LOG(INFO)/LOG(FATAL) macro doing (even that you said I should ignore it)? Is it something else than alias to Debug()/Error()?

It's just printing to stdout and a file; it's easylogging++.

Contributor

miguelmartin75 commented Nov 9, 2013

By the way, what is your LOG(INFO)/LOG(FATAL) macro doing (even that you said I should ignore it)? Is it something else than alias to Debug()/Error()?

It's just printing to stdout and a file; it's easylogging++.

@mosra

This comment has been minimized.

Show comment
Hide comment
@mosra

mosra Nov 9, 2013

Owner

Should be fixed in b916148. The loader now doesn't try to parse extension lists, as this functionality is already available elsewhere. It should now work for both core and compatibility contexts. Please test and report any issues.

Owner

mosra commented Nov 9, 2013

Should be fixed in b916148. The loader now doesn't try to parse extension lists, as this functionality is already available elsewhere. It should now work for both core and compatibility contexts. Please test and report any issues.

@miguelmartin75

This comment has been minimized.

Show comment
Hide comment
@miguelmartin75

miguelmartin75 Nov 19, 2013

Contributor

Seems to be fixed now, sorry for the late reply, I just upgraded to 10.9. :) Thanks.

Contributor

miguelmartin75 commented Nov 19, 2013

Seems to be fixed now, sorry for the late reply, I just upgraded to 10.9. :) Thanks.

@mosra mosra added this to the 2014.01 milestone Feb 15, 2018

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