Android OpenGL support( for tegra gpu's )
This commit is contained in:
parent
6e5ef80a0e
commit
7a69af7b00
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "tier1/utllinkedlist.h"
|
#include "tier1/utllinkedlist.h"
|
||||||
#include "tier1/convar.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)
|
// NOTE: This has to be the last file included! (turned off below, since this is included like a header)
|
||||||
#include "tier0/memdbgon.h"
|
#include "tier0/memdbgon.h"
|
||||||
@ -57,8 +58,14 @@ COpenGLEntryPoints *gGL = NULL;
|
|||||||
const int kBogusSwapInterval = INT_MAX;
|
const int kBogusSwapInterval = INT_MAX;
|
||||||
|
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
static void *gl4es = NULL;
|
static void *l_gl4es = NULL;
|
||||||
void *(*_glGetProcAddress)( const char * );
|
static void *l_egl = NULL;
|
||||||
|
|
||||||
|
typedef void *(*t_glGetProcAddress)( const char * );
|
||||||
|
t_glGetProcAddress _glGetProcAddress;
|
||||||
|
|
||||||
|
typedef EGLBoolean (*t_eglBindAPI)(EGLenum api);
|
||||||
|
t_eglBindAPI _eglBindAPI;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -238,7 +245,7 @@ public:
|
|||||||
|
|
||||||
virtual void IncWindowRefCount();
|
virtual void IncWindowRefCount();
|
||||||
virtual void DecWindowRefCount();
|
virtual void DecWindowRefCount();
|
||||||
|
|
||||||
// Get the next N events. The function returns the number of events that were filled into your array.
|
// Get the next N events. The function returns the number of events that were filled into your array.
|
||||||
virtual int GetEvents( CCocoaEvent *pEvents, int nMaxEventsToReturn, bool debugEvents = false );
|
virtual int GetEvents( CCocoaEvent *pEvents, int nMaxEventsToReturn, bool debugEvents = false );
|
||||||
#ifdef LINUX
|
#ifdef LINUX
|
||||||
@ -374,7 +381,7 @@ private:
|
|||||||
Uint32 m_MouseButtonDownTimeStamp;
|
Uint32 m_MouseButtonDownTimeStamp;
|
||||||
int m_MouseButtonDownX;
|
int m_MouseButtonDownX;
|
||||||
int m_MouseButtonDownY;
|
int m_MouseButtonDownY;
|
||||||
|
|
||||||
double m_flPrevGLSwapWindowTime;
|
double m_flPrevGLSwapWindowTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -544,23 +551,51 @@ InitReturnVal_t CSDLMgr::Init()
|
|||||||
m_MouseButtonDownTimeStamp = 0;
|
m_MouseButtonDownTimeStamp = 0;
|
||||||
m_MouseButtonDownX = 0;
|
m_MouseButtonDownX = 0;
|
||||||
m_MouseButtonDownY = 0;
|
m_MouseButtonDownY = 0;
|
||||||
|
|
||||||
m_bExpectSyntheticMouseMotion = false;
|
m_bExpectSyntheticMouseMotion = false;
|
||||||
m_nMouseTargetX = 0;
|
m_nMouseTargetX = 0;
|
||||||
m_nMouseTargetY = 0;
|
m_nMouseTargetY = 0;
|
||||||
m_nWarpDelta = 0;
|
m_nWarpDelta = 0;
|
||||||
m_bRawInput = false;
|
m_bRawInput = false;
|
||||||
|
|
||||||
m_flPrevGLSwapWindowTime = 0.0f;
|
m_flPrevGLSwapWindowTime = 0.0f;
|
||||||
|
|
||||||
memset(m_pixelFormatAttribs, '\0', sizeof (m_pixelFormatAttribs));
|
memset(m_pixelFormatAttribs, '\0', sizeof (m_pixelFormatAttribs));
|
||||||
|
|
||||||
int *attCursor = m_pixelFormatAttribs;
|
int *attCursor = m_pixelFormatAttribs;
|
||||||
|
|
||||||
#define SET_GL_ATTR(key,value) \
|
#define SET_GL_ATTR(key,value) \
|
||||||
*(attCursor++) = (int) (key); \
|
*(attCursor++) = (int) (key); \
|
||||||
*(attCursor++) = (int) (value);
|
*(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_RED_SIZE, 8);
|
||||||
SET_GL_ATTR(SDL_GL_GREEN_SIZE, 8);
|
SET_GL_ATTR(SDL_GL_GREEN_SIZE, 8);
|
||||||
SET_GL_ATTR(SDL_GL_BLUE_SIZE, 8);
|
SET_GL_ATTR(SDL_GL_BLUE_SIZE, 8);
|
||||||
@ -586,9 +621,9 @@ InitReturnVal_t CSDLMgr::Init()
|
|||||||
// to really actually make a window, we just resize the one we built here.
|
// to really actually make a window, we just resize the one we built here.
|
||||||
if ( !CreateHiddenGameWindow( "", 640, 480 ) )
|
if ( !CreateHiddenGameWindow( "", 640, 480 ) )
|
||||||
Error( "CreateGameWindow failed" );
|
Error( "CreateGameWindow failed" );
|
||||||
|
|
||||||
SDL_HideWindow( m_Window );
|
SDL_HideWindow( m_Window );
|
||||||
|
|
||||||
return INIT_OK;
|
return INIT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -724,7 +759,7 @@ bool CSDLMgr::CreateHiddenGameWindow( const char *pTitle, int width, int height
|
|||||||
#if defined( DX_TO_GL_ABSTRACTION )
|
#if defined( DX_TO_GL_ABSTRACTION )
|
||||||
flags |= SDL_WINDOW_OPENGL;
|
flags |= SDL_WINDOW_OPENGL;
|
||||||
#endif
|
#endif
|
||||||
m_Window = SDL_CreateWindow( pTitle, x, y, width, height, flags );
|
m_Window = SDL_CreateWindow( pTitle, x, y, width, height, flags );
|
||||||
|
|
||||||
if (m_Window == NULL)
|
if (m_Window == NULL)
|
||||||
Error( "Failed to create SDL window: %s", SDL_GetError() );
|
Error( "Failed to create SDL window: %s", SDL_GetError() );
|
||||||
@ -760,13 +795,11 @@ bool CSDLMgr::CreateHiddenGameWindow( const char *pTitle, int width, int height
|
|||||||
SDL_GL_MakeCurrent(m_Window, m_GLContext);
|
SDL_GL_MakeCurrent(m_Window, m_GLContext);
|
||||||
|
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
gl4es = dlopen("libgl4es.so", RTLD_LAZY);
|
if( l_gl4es )
|
||||||
|
|
||||||
if( gl4es )
|
|
||||||
{
|
{
|
||||||
_glGetProcAddress = dlsym(gl4es, "gl4es_GetProcAddress" );
|
_glGetProcAddress = (t_glGetProcAddress)dlsym(l_gl4es, "gl4es_GetProcAddress" );
|
||||||
void (*initialize_gl4es)( );
|
void (*initialize_gl4es)( );
|
||||||
initialize_gl4es = dlsym(gl4es, "initialize_gl4es" );
|
initialize_gl4es = (void(*)())dlsym(l_gl4es, "initialize_gl4es" );
|
||||||
initialize_gl4es();
|
initialize_gl4es();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user