Skip to content
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
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
@@ -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
Copy link

@Gillou68310 Gillou68310 commented on 5a63f1e May 13, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copy link

@Gillou68310 Gillou68310 commented on 5a63f1e May 13, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

@littleguy77 littleguy77 commented on 5a63f1e May 13, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

@Gillou68310 Gillou68310 commented on 5a63f1e May 13, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep temp commit ;-)

@gonetz
Copy link

@gonetz gonetz commented on 5a63f1e May 14, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Gillou68310
Copy link

@Gillou68310 Gillou68310 commented on 5a63f1e May 14, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @gonetz ;-)

Please sign in to comment.