Permalink
Browse files

SDL: Let the video plugin choose the major opengl version

  • Loading branch information...
Gillou68310 committed May 13, 2015
1 parent 8be0b4c commit 5a63f1ea46f393f066815beb8f6b85d09d91c194
@@ -1631,10 +1631,14 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
#endif
Uint32 windowFlags;
GLint window_framebuffer;
int major, minor;
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &major);
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &minor);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_EGL, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, major);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, minor);
windowFlags = SDL_GetWindowFlags(window);
if (!(windowFlags & SDL_WINDOW_OPENGL)) {
@@ -418,8 +418,8 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
#else // !USE_GLES
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
//SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
//SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
#endif // !USE_GLES
/* Create a new window */

6 comments on commit 5a63f1e

@Gillou68310

This comment has been minimized.

Show comment
Hide comment
@Gillou68310

Gillou68310 May 13, 2015

Contributor

@gonetz These lines should be added to the _setAttributes method in the OGLVideoMupenPlus class in order to request the appropriate context.

#ifdef GLES2
    CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MAJOR_VERSION, 2);
    CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MINOR_VERSION, 0);
#elif defined(GLES3)
    CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MAJOR_VERSION, 3);
    CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MINOR_VERSION, 0);
#elif defined(GLES3_1)
    CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MAJOR_VERSION, 3);
    CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MINOR_VERSION, 1);
#else
    // Do nothing
#endif

Also M64P_GL_CONTEXT_MAJOR_VERSION and M64P_GL_CONTEXT_MINOR_VERSION are missing from the m64p_GLattr enumeration in /src/inc/m64p_types.h

Contributor

Gillou68310 replied May 13, 2015

@gonetz These lines should be added to the _setAttributes method in the OGLVideoMupenPlus class in order to request the appropriate context.

#ifdef GLES2
    CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MAJOR_VERSION, 2);
    CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MINOR_VERSION, 0);
#elif defined(GLES3)
    CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MAJOR_VERSION, 3);
    CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MINOR_VERSION, 0);
#elif defined(GLES3_1)
    CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MAJOR_VERSION, 3);
    CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MINOR_VERSION, 1);
#else
    // Do nothing
#endif

Also M64P_GL_CONTEXT_MAJOR_VERSION and M64P_GL_CONTEXT_MINOR_VERSION are missing from the m64p_GLattr enumeration in /src/inc/m64p_types.h

@Gillou68310

This comment has been minimized.

Show comment
Hide comment
@Gillou68310

Gillou68310 May 13, 2015

Contributor

Actually setting major and minor version for GLES2 isn't necessary as they are set by default in SDL (SDL_video.c) ;-)

#if SDL_VIDEO_OPENGL
    _this->gl_config.major_version = 2;
    _this->gl_config.minor_version = 1;
    _this->gl_config.use_egl = 0;
#elif SDL_VIDEO_OPENGL_ES
    _this->gl_config.major_version = 1;
    _this->gl_config.minor_version = 1;
    _this->gl_config.use_egl = 1;
#elif SDL_VIDEO_OPENGL_ES2
    _this->gl_config.major_version = 2;
    _this->gl_config.minor_version = 0;
    _this->gl_config.use_egl = 1;
#endif
Contributor

Gillou68310 replied May 13, 2015

Actually setting major and minor version for GLES2 isn't necessary as they are set by default in SDL (SDL_video.c) ;-)

#if SDL_VIDEO_OPENGL
    _this->gl_config.major_version = 2;
    _this->gl_config.minor_version = 1;
    _this->gl_config.use_egl = 0;
#elif SDL_VIDEO_OPENGL_ES
    _this->gl_config.major_version = 1;
    _this->gl_config.minor_version = 1;
    _this->gl_config.use_egl = 1;
#elif SDL_VIDEO_OPENGL_ES2
    _this->gl_config.major_version = 2;
    _this->gl_config.minor_version = 0;
    _this->gl_config.use_egl = 1;
#endif
@littleguy77

This comment has been minimized.

Show comment
Hide comment
@littleguy77

littleguy77 May 13, 2015

Member

Thanks @Gillou68310
Just to clarify, this is just a temporary commit until GLideN64 is ported to GLES 2.0, correct? Be careful if this branch is synced with upstream core, because the temporary modification you made to vidext_sdl2_compat.h will be overwritten.

Member

littleguy77 replied May 13, 2015

Thanks @Gillou68310
Just to clarify, this is just a temporary commit until GLideN64 is ported to GLES 2.0, correct? Be careful if this branch is synced with upstream core, because the temporary modification you made to vidext_sdl2_compat.h will be overwritten.

@Gillou68310

This comment has been minimized.

Show comment
Hide comment
@Gillou68310

Gillou68310 May 13, 2015

Contributor

Yep temp commit ;-)

Contributor

Gillou68310 replied May 13, 2015

Yep temp commit ;-)

@gonetz

This comment has been minimized.

Show comment
Hide comment
@Gillou68310

This comment has been minimized.

Show comment
Hide comment
@Gillou68310

Gillou68310 May 14, 2015

Contributor

Thanks @gonetz ;-)

Contributor

Gillou68310 replied May 14, 2015

Thanks @gonetz ;-)

Please sign in to comment.