SDL: added GLES3 support

This commit is contained in:
Sergii Pylypenko
2016-08-22 21:46:35 +03:00
parent 250f254b5d
commit ee54f13f75
15 changed files with 134 additions and 59 deletions

View File

@@ -0,0 +1,28 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/**
* \file SDL_clipboard.h
*
* Include file for SDL clipboard handling
*/
#include "SDL_screenkeyboard.h" /* SDL2 lololol */

View File

@@ -146,7 +146,6 @@ SDL_Surface *SDL_CurrentVideoSurface = NULL;
static int HwSurfaceCount = 0;
static SDL_Surface ** HwSurfaceList = NULL;
void * glLibraryHandle = NULL;
void * gl2LibraryHandle = NULL;
static Uint32 SDL_VideoThreadID = 0;
int SDL_ANDROID_InsideVideoThread()
@@ -218,13 +217,21 @@ static SDL_VideoDevice *ANDROID_CreateDevice(int devindex)
device->handles_any_size = 1; // Any video mode is OK
glLibraryHandle = dlopen("libGLESv1_CM.so", RTLD_NOW | RTLD_GLOBAL);
if(SDL_ANDROID_UseGles2)
if ( SDL_ANDROID_UseGles3 )
{
gl2LibraryHandle = dlopen("libGLESv2.so", RTLD_NOW | RTLD_GLOBAL);
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Loading libGLESv2.so: %p", gl2LibraryHandle);
glLibraryHandle = dlopen("libGLESv3.so", RTLD_LAZY | RTLD_GLOBAL);
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Loading libGLESv3.so: %p", glLibraryHandle);
}
else if ( SDL_ANDROID_UseGles2 )
{
glLibraryHandle = dlopen("libGLESv2.so", RTLD_LAZY | RTLD_GLOBAL);
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Loading libGLESv2.so: %p", glLibraryHandle);
}
else
{
glLibraryHandle = dlopen("libGLESv1_CM.so", RTLD_LAZY | RTLD_GLOBAL);
}
return device;
}
@@ -1240,11 +1247,9 @@ void SDL_ANDROID_VideoContextRecreated()
static void* ANDROID_GL_GetProcAddress(_THIS, const char *proc)
{
#ifdef USE_GLSHIM
void * func = glXGetProcAddress(proc);
void * func = glXGetProcAddress(proc);
#else
void * func = dlsym(glLibraryHandle, proc);
if(!func && gl2LibraryHandle)
func = dlsym(gl2LibraryHandle, proc);
#endif
__android_log_print(ANDROID_LOG_INFO, "libSDL", "ANDROID_GL_GetProcAddress(\"%s\"): %p", proc, func);
return func;

View File

@@ -99,6 +99,7 @@ int SDL_ANDROID_CompatibilityHacks = 0;
int SDL_ANDROID_BYTESPERPIXEL = 2;
int SDL_ANDROID_BITSPERPIXEL = 16;
int SDL_ANDROID_UseGles2 = 0;
int SDL_ANDROID_UseGles3 = 0;
int SDL_ANDROID_ShowMouseCursor = 0;
SDL_Rect SDL_ANDROID_VideoDebugRect;
SDL_Color SDL_ANDROID_VideoDebugRectColor;
@@ -431,11 +432,12 @@ JAVA_EXPORT_NAME(Settings_nativeSetCompatibilityHacks) (JNIEnv* env, jobject thi
}
JNIEXPORT void JNICALL
JAVA_EXPORT_NAME(Settings_nativeSetVideoDepth) (JNIEnv* env, jobject thiz, jint bpp, jint UseGles2)
JAVA_EXPORT_NAME(Settings_nativeSetVideoDepth) (JNIEnv* env, jobject thiz, jint bpp, jint UseGles2, jint UseGles3)
{
SDL_ANDROID_BITSPERPIXEL = bpp;
SDL_ANDROID_BYTESPERPIXEL = SDL_ANDROID_BITSPERPIXEL / 8;
SDL_ANDROID_UseGles2 = UseGles2;
SDL_ANDROID_UseGles3 = UseGles3;
}
void SDLCALL SDL_ANDROID_GetClipboardText(char * buf, int len)

View File

@@ -55,6 +55,7 @@ extern int SDL_ANDROID_VideoForceSoftwareMode;
extern int SDL_ANDROID_CompatibilityHacks;
extern int SDL_ANDROID_ShowMouseCursor;
extern int SDL_ANDROID_UseGles2;
extern int SDL_ANDROID_UseGles3;
extern int SDL_ANDROID_BYTESPERPIXEL;
extern int SDL_ANDROID_BITSPERPIXEL;
extern void SDL_ANDROID_TextInputInit(char * buffer, int len);