Guarded EGL code with SDL_VIDEO_OPENGL_EGL

This commit is contained in:
Sam Lantinga 2017-09-22 08:30:37 -07:00
parent 499f928c33
commit ad86eff1a8
3 changed files with 24 additions and 0 deletions

View File

@ -32,6 +32,16 @@ VIVANTE_SetupPlatform(_THIS)
return 0; return 0;
} }
char *VIVANTE_GetDisplayName(_THIS)
{
return NULL;
}
void
VIVANTE_UpdateDisplayScale(_THIS)
{
}
void void
VIVANTE_CleanupPlatform(_THIS) VIVANTE_CleanupPlatform(_THIS)
{ {

View File

@ -36,6 +36,8 @@
#endif #endif
extern int VIVANTE_SetupPlatform(_THIS); extern int VIVANTE_SetupPlatform(_THIS);
extern char *VIVANTE_GetDisplayName(_THIS);
extern void VIVANTE_UpdateDisplayScale(_THIS);
extern void VIVANTE_CleanupPlatform(_THIS); extern void VIVANTE_CleanupPlatform(_THIS);
#endif /* SDL_VIDEO_DRIVER_VIVANTE */ #endif /* SDL_VIDEO_DRIVER_VIVANTE */

View File

@ -97,6 +97,7 @@ VIVANTE_Create()
device->DestroyWindow = VIVANTE_DestroyWindow; device->DestroyWindow = VIVANTE_DestroyWindow;
device->GetWindowWMInfo = VIVANTE_GetWindowWMInfo; device->GetWindowWMInfo = VIVANTE_GetWindowWMInfo;
#if SDL_VIDEO_OPENGL_EGL
device->GL_LoadLibrary = VIVANTE_GLES_LoadLibrary; device->GL_LoadLibrary = VIVANTE_GLES_LoadLibrary;
device->GL_GetProcAddress = VIVANTE_GLES_GetProcAddress; device->GL_GetProcAddress = VIVANTE_GLES_GetProcAddress;
device->GL_UnloadLibrary = VIVANTE_GLES_UnloadLibrary; device->GL_UnloadLibrary = VIVANTE_GLES_UnloadLibrary;
@ -106,6 +107,7 @@ VIVANTE_Create()
device->GL_GetSwapInterval = VIVANTE_GLES_GetSwapInterval; device->GL_GetSwapInterval = VIVANTE_GLES_GetSwapInterval;
device->GL_SwapWindow = VIVANTE_GLES_SwapWindow; device->GL_SwapWindow = VIVANTE_GLES_SwapWindow;
device->GL_DeleteContext = VIVANTE_GLES_DeleteContext; device->GL_DeleteContext = VIVANTE_GLES_DeleteContext;
#endif
device->PumpEvents = VIVANTE_PumpEvents; device->PumpEvents = VIVANTE_PumpEvents;
@ -152,6 +154,9 @@ VIVANTE_AddVideoDisplays(_THIS)
switch (bpp) switch (bpp)
{ {
default: /* Is another format used? */ default: /* Is another format used? */
case 32:
current_mode.format = SDL_PIXELFORMAT_ARGB8888;
break;
case 16: case 16:
current_mode.format = SDL_PIXELFORMAT_RGB565; current_mode.format = SDL_PIXELFORMAT_RGB565;
break; break;
@ -160,6 +165,7 @@ VIVANTE_AddVideoDisplays(_THIS)
current_mode.refresh_rate = 60; current_mode.refresh_rate = 60;
SDL_zero(display); SDL_zero(display);
display.name = VIVANTE_GetDisplayName(_this);
display.desktop_mode = current_mode; display.desktop_mode = current_mode;
display.current_mode = current_mode; display.current_mode = current_mode;
display.driverdata = data; display.driverdata = data;
@ -208,6 +214,8 @@ VIVANTE_VideoInit(_THIS)
return -1; return -1;
} }
VIVANTE_UpdateDisplayScale(_this);
#ifdef SDL_INPUT_LINUXEV #ifdef SDL_INPUT_LINUXEV
if (SDL_EVDEV_Init() < 0) { if (SDL_EVDEV_Init() < 0) {
return -1; return -1;
@ -281,6 +289,7 @@ VIVANTE_CreateWindow(_THIS, SDL_Window * window)
return SDL_SetError("VIVANTE: Can't create native window"); return SDL_SetError("VIVANTE: Can't create native window");
} }
#if SDL_VIDEO_OPENGL_EGL
if (window->flags & SDL_WINDOW_OPENGL) { if (window->flags & SDL_WINDOW_OPENGL) {
data->egl_surface = SDL_EGL_CreateSurface(_this, data->native_window); data->egl_surface = SDL_EGL_CreateSurface(_this, data->native_window);
if (data->egl_surface == EGL_NO_SURFACE) { if (data->egl_surface == EGL_NO_SURFACE) {
@ -289,6 +298,7 @@ VIVANTE_CreateWindow(_THIS, SDL_Window * window)
} else { } else {
data->egl_surface = EGL_NO_SURFACE; data->egl_surface = EGL_NO_SURFACE;
} }
#endif
/* Window has been successfully created */ /* Window has been successfully created */
return 0; return 0;
@ -302,9 +312,11 @@ VIVANTE_DestroyWindow(_THIS, SDL_Window * window)
data = window->driverdata; data = window->driverdata;
if (data) { if (data) {
#if SDL_VIDEO_OPENGL_EGL
if (data->egl_surface != EGL_NO_SURFACE) { if (data->egl_surface != EGL_NO_SURFACE) {
SDL_EGL_DestroySurface(_this, data->egl_surface); SDL_EGL_DestroySurface(_this, data->egl_surface);
} }
#endif
if (data->native_window) { if (data->native_window) {
#if SDL_VIDEO_DRIVER_VIVANTE_VDK #if SDL_VIDEO_DRIVER_VIVANTE_VDK