Skip to content
Permalink
Browse files

video: Let video targets optionally decide their default OpenGL configs.

This is necessary because the Raspberry Pi is a strange beast, that believes
it has OpenGL support (through glX?) but generally has GLES2 support.

So when using the raspberry video target, we need to force this to default
to a GLES2 context, or by default SDL_CreateWindow() will fail, deep down
when it tries to load the proper GL library.

Fixes testsprite2 (and basically everything else that wasn't testgles2) when
run on a Raspberry Pi without a X server.

Please note that other targets might also need this filled in, the Raspberry
Pi is just the most prominent and readily-available System-On-A-Chip style
thing on my desk.  :)
  • Loading branch information
icculus committed Sep 2, 2017
1 parent 3267398 commit 167398b363241015996d80567f8a8a4bd99fa619
@@ -261,6 +261,7 @@ struct SDL_VideoDevice
int (*GL_GetSwapInterval) (_THIS);
int (*GL_SwapWindow) (_THIS, SDL_Window * window);
void (*GL_DeleteContext) (_THIS, SDL_GLContext context);
void (*GL_DefaultProfileConfig) (_THIS, int *mask, int *major, int *minor);

/* * * */
/*
@@ -2987,19 +2987,27 @@ SDL_GL_ResetAttributes()
_this->gl_config.multisamplesamples = 0;
_this->gl_config.retained_backing = 1;
_this->gl_config.accelerated = -1; /* accelerated or not, both are fine */
_this->gl_config.profile_mask = 0;

if (_this->GL_DefaultProfileConfig) {
_this->GL_DefaultProfileConfig(_this, &_this->gl_config.profile_mask,
&_this->gl_config.major_version,
&_this->gl_config.minor_version);
} else {
#if SDL_VIDEO_OPENGL
_this->gl_config.major_version = 2;
_this->gl_config.minor_version = 1;
_this->gl_config.major_version = 2;
_this->gl_config.minor_version = 1;
_this->gl_config.profile_mask = 0;
#elif SDL_VIDEO_OPENGL_ES2
_this->gl_config.major_version = 2;
_this->gl_config.minor_version = 0;
_this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
_this->gl_config.major_version = 2;
_this->gl_config.minor_version = 0;
_this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
#elif SDL_VIDEO_OPENGL_ES
_this->gl_config.major_version = 1;
_this->gl_config.minor_version = 1;
_this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
_this->gl_config.major_version = 1;
_this->gl_config.minor_version = 1;
_this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
#endif
}

_this->gl_config.flags = 0;
_this->gl_config.framebuffer_srgb_capable = 0;
_this->gl_config.no_error = 0;
@@ -27,6 +27,14 @@

/* EGL implementation of SDL OpenGL support */

void
RPI_GLES_DefaultProfileConfig(_THIS, int *mask, int *major, int *minor)
{
*mask = SDL_GL_CONTEXT_PROFILE_ES;
*major = 2;
*minor = 0;
}

int
RPI_GLES_LoadLibrary(_THIS, const char *path) {
return SDL_EGL_LoadLibrary(_this, path, EGL_DEFAULT_DISPLAY, 0);
@@ -40,6 +40,7 @@ extern int RPI_GLES_LoadLibrary(_THIS, const char *path);
extern SDL_GLContext RPI_GLES_CreateContext(_THIS, SDL_Window * window);
extern int RPI_GLES_SwapWindow(_THIS, SDL_Window * window);
extern int RPI_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context);
extern void RPI_GLES_DefaultProfileConfig(_THIS, int *mask, int *major, int *minor);

#endif /* SDL_VIDEO_DRIVER_RPI && SDL_VIDEO_OPENGL_EGL */

@@ -123,6 +123,7 @@ RPI_Create()
device->GL_GetSwapInterval = RPI_GLES_GetSwapInterval;
device->GL_SwapWindow = RPI_GLES_SwapWindow;
device->GL_DeleteContext = RPI_GLES_DeleteContext;
device->GL_DefaultProfileConfig = RPI_GLES_DefaultProfileConfig;

device->PumpEvents = RPI_PumpEvents;

0 comments on commit 167398b

Please sign in to comment.