Android OpenGL support( for tegra gpu's )

This commit is contained in:
nillerusr 2021-10-26 21:30:11 +03:00
parent 6e5ef80a0e
commit 7a69af7b00

View File

@ -19,6 +19,7 @@
#include "tier1/utllinkedlist.h"
#include "tier1/convar.h"
#include <EGL/egl.h>
// NOTE: This has to be the last file included! (turned off below, since this is included like a header)
#include "tier0/memdbgon.h"
@ -57,8 +58,14 @@ COpenGLEntryPoints *gGL = NULL;
const int kBogusSwapInterval = INT_MAX;
#ifdef ANDROID
static void *gl4es = NULL;
void *(*_glGetProcAddress)( const char * );
static void *l_gl4es = NULL;
static void *l_egl = NULL;
typedef void *(*t_glGetProcAddress)( const char * );
t_glGetProcAddress _glGetProcAddress;
typedef EGLBoolean (*t_eglBindAPI)(EGLenum api);
t_eglBindAPI _eglBindAPI;
#endif
/*
@ -561,6 +568,34 @@ InitReturnVal_t CSDLMgr::Init()
*(attCursor++) = (int) (key); \
*(attCursor++) = (int) (value);
#ifdef ANDROID
bool m_bOGL = false;
l_egl = dlopen("libEGL.so", RTLD_LAZY);
if( l_egl )
{
_eglBindAPI = (t_eglBindAPI)dlsym(l_egl, "eglBindAPI");
if( _eglBindAPI && _eglBindAPI(EGL_OPENGL_API) )
{
Msg("OpenGL support found!\n");
m_bOGL = true;
}
}
if( m_bOGL )
{
_glGetProcAddress = (t_glGetProcAddress)dlsym(l_egl, "eglGetProcAddress");
SET_GL_ATTR(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
}
else
{
l_gl4es = dlopen("libgl4es.so", RTLD_LAZY);
_glGetProcAddress = (t_glGetProcAddress)dlsym(l_gl4es, "gl4es_glGetProcAddress");
}
#endif
SET_GL_ATTR(SDL_GL_RED_SIZE, 8);
SET_GL_ATTR(SDL_GL_GREEN_SIZE, 8);
SET_GL_ATTR(SDL_GL_BLUE_SIZE, 8);
@ -760,13 +795,11 @@ bool CSDLMgr::CreateHiddenGameWindow( const char *pTitle, int width, int height
SDL_GL_MakeCurrent(m_Window, m_GLContext);
#ifdef ANDROID
gl4es = dlopen("libgl4es.so", RTLD_LAZY);
if( gl4es )
if( l_gl4es )
{
_glGetProcAddress = dlsym(gl4es, "gl4es_GetProcAddress" );
_glGetProcAddress = (t_glGetProcAddress)dlsym(l_gl4es, "gl4es_GetProcAddress" );
void (*initialize_gl4es)( );
initialize_gl4es = dlsym(gl4es, "initialize_gl4es" );
initialize_gl4es = (void(*)())dlsym(l_gl4es, "initialize_gl4es" );
initialize_gl4es();
}
#endif