mirror of
https://github.com/nillerusr/source-engine.git
synced 2025-02-10 06:04:16 +00:00
Propertly use gl4es
This commit is contained in:
parent
20552cc8b9
commit
6fb7fc1f4f
@ -58,7 +58,7 @@ const int kBogusSwapInterval = INT_MAX;
|
|||||||
|
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
static void *gl4es = NULL;
|
static void *gl4es = NULL;
|
||||||
void *(*_eglGetProcAddress)( const char * );
|
void *(*_glGetProcAddress)( const char * );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -183,8 +183,8 @@ void *VoidFnPtrLookup_GlMgr(const char *fn, bool &okay, const bool bRequired, vo
|
|||||||
|
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
// SDL does the right thing, so we never need to use tier0 in this case.
|
// SDL does the right thing, so we never need to use tier0 in this case.
|
||||||
if( _eglGetProcAddress )
|
if( _glGetProcAddress )
|
||||||
retval = _eglGetProcAddress(fn);
|
retval = _glGetProcAddress(fn);
|
||||||
//printf("CDynamicFunctionOpenGL: SDL_GL_GetProcAddress(\"%s\") returned %p\n", fn, retval);
|
//printf("CDynamicFunctionOpenGL: SDL_GL_GetProcAddress(\"%s\") returned %p\n", fn, retval);
|
||||||
if ((retval == NULL) && (fallback != NULL))
|
if ((retval == NULL) && (fallback != NULL))
|
||||||
{
|
{
|
||||||
@ -764,7 +764,7 @@ bool CSDLMgr::CreateHiddenGameWindow( const char *pTitle, int width, int height
|
|||||||
|
|
||||||
if( gl4es )
|
if( gl4es )
|
||||||
{
|
{
|
||||||
_eglGetProcAddress = dlsym(gl4es, "eglGetProcAddress" );
|
_glGetProcAddress = dlsym(gl4es, "gl4es_GetProcAddress" );
|
||||||
void (*initialize_gl4es)( );
|
void (*initialize_gl4es)( );
|
||||||
initialize_gl4es = dlsym(gl4es, "initialize_gl4es" );
|
initialize_gl4es = dlsym(gl4es, "initialize_gl4es" );
|
||||||
initialize_gl4es();
|
initialize_gl4es();
|
||||||
|
@ -8,14 +8,13 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
|
||||||
#include "tier0/threadtools.h"
|
#include "tier0/threadtools.h"
|
||||||
|
|
||||||
char *LauncherArgv[512];
|
char *LauncherArgv[512];
|
||||||
char java_args[4096];
|
char java_args[4096];
|
||||||
int iLastArgs = 0;
|
int iLastArgs = 0;
|
||||||
|
|
||||||
#define MAX_PATH 2048
|
|
||||||
|
|
||||||
#define TAG "SRCENG"
|
#define TAG "SRCENG"
|
||||||
#define PRIO ANDROID_LOG_DEBUG
|
#define PRIO ANDROID_LOG_DEBUG
|
||||||
#define LogPrintf(...) do { __android_log_print(PRIO, TAG, __VA_ARGS__); printf( __VA_ARGS__); } while( 0 );
|
#define LogPrintf(...) do { __android_log_print(PRIO, TAG, __VA_ARGS__); printf( __VA_ARGS__); } while( 0 );
|
||||||
@ -44,9 +43,6 @@ DLLEXPORT void Java_com_valvesoftware_ValveActivity2_nativeOnActivityResult()
|
|||||||
LogPrintf( "Java_com_valvesoftware_ValveActivity_nativeOnActivityResult" );
|
LogPrintf( "Java_com_valvesoftware_ValveActivity_nativeOnActivityResult" );
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef void (*t_egl_init)();
|
|
||||||
t_egl_init egl_init;
|
|
||||||
|
|
||||||
void parseArgs( char *args )
|
void parseArgs( char *args )
|
||||||
{
|
{
|
||||||
char *pch;
|
char *pch;
|
||||||
@ -72,8 +68,8 @@ DLLEXPORT int LauncherMain( int argc, char **argv );
|
|||||||
|
|
||||||
void SetLauncherArgs()
|
void SetLauncherArgs()
|
||||||
{
|
{
|
||||||
static char binPath[MAX_PATH];
|
static char binPath[2048];
|
||||||
snprintf(binPath, MAX_PATH, "%s/hl2_linux", getenv("APP_DATA_PATH") );
|
snprintf(binPath, sizeof binPath, "%s/hl2_linux", getenv("APP_DATA_PATH") );
|
||||||
LogPrintf(binPath);
|
LogPrintf(binPath);
|
||||||
D(binPath);
|
D(binPath);
|
||||||
|
|
||||||
@ -85,15 +81,61 @@ void SetLauncherArgs()
|
|||||||
D("-insecure");
|
D("-insecure");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *lgles;
|
||||||
|
|
||||||
|
typedef void (*t_set_getprocaddress)(void *(*new_proc_address)(const char *));
|
||||||
|
t_set_getprocaddress gl4es_set_getprocaddress;
|
||||||
|
|
||||||
|
typedef void *(*t_eglGetProcAddress)( const char * );
|
||||||
|
t_eglGetProcAddress eglGetProcAddress;
|
||||||
|
|
||||||
|
void *GetProcAddress( const char *procname )
|
||||||
|
{
|
||||||
|
void *result = dlsym(lgles, procname);
|
||||||
|
if(result)
|
||||||
|
return result;
|
||||||
|
else
|
||||||
|
return eglGetProcAddress(procname);
|
||||||
|
}
|
||||||
|
|
||||||
DLLEXPORT int LauncherMainAndroid( int argc, char **argv )
|
DLLEXPORT int LauncherMainAndroid( int argc, char **argv )
|
||||||
{
|
{
|
||||||
|
|
||||||
SetLauncherArgs();
|
SetLauncherArgs();
|
||||||
|
|
||||||
void *glHandle = dlopen("libgl4es.so", 0);
|
void *lgl4es = dlopen("libgl4es.so", 0);
|
||||||
egl_init = (t_egl_init)dlsym(glHandle, "egl_init");
|
if( !lgl4es )
|
||||||
if( egl_init )
|
{
|
||||||
egl_init();
|
LogPrintf("Failed to dlopen library libgl4es.so: %s\n", dlerror());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *lEGL = dlopen("libEGL.so", 0);
|
||||||
|
if( !lEGL )
|
||||||
|
{
|
||||||
|
LogPrintf("Failed to dlopen library libEGL.so: %s\n", dlerror());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
lgles = dlopen("libGLESv2.so", 0);
|
||||||
|
if( !lgles )
|
||||||
|
{
|
||||||
|
LogPrintf("Failed to dlopen library libGLESv2.so: %s\n", dlerror());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
gl4es_set_getprocaddress = (t_set_getprocaddress)dlsym(lgl4es, "set_getprocaddress");
|
||||||
|
eglGetProcAddress = (t_eglGetProcAddress)dlsym(lEGL, "eglGetProcAddress");
|
||||||
|
|
||||||
|
if( gl4es_set_getprocaddress && eglGetProcAddress )
|
||||||
|
{
|
||||||
|
gl4es_set_getprocaddress( &GetProcAddress );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LogPrintf("Failed to call set_getprocaddress\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
DeclareCurrentThreadIsMainThread(); // Init thread propertly on Android
|
DeclareCurrentThreadIsMainThread(); // Init thread propertly on Android
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user