emulator: opengl: add initLibrary function to render library
This adds an initLibrary() function to libOpenglRender. It will be used by the emulator to fallback on software rendering if the library cannot be initialized properly, e.g. if it is not possible to load the host EGL/GLES libraries. Change-Id: I41e8ad73a315166e4a15cbee1db72c2552370f46
This commit is contained in:
@@ -22,6 +22,16 @@ extern "C" {
|
||||
|
||||
#include "render_api_platform_types.h"
|
||||
|
||||
// initLibrary - initialize the library and tries to load the corresponding
|
||||
// GLES translator libraries. This function must be called before anything
|
||||
// else to ensure that everything works. If it returns an error, then
|
||||
// you cannot use the library at all (this can happen under certain
|
||||
// environments where the desktop GL libraries are not available)
|
||||
//
|
||||
// returns true if the library could be initialized successfully;
|
||||
//
|
||||
bool initLibrary(void);
|
||||
|
||||
//
|
||||
// initOpenGLRenderer - initialize the OpenGL renderer process.
|
||||
// portNum is the tcp port number the renderer is listening to.
|
||||
@@ -31,7 +41,7 @@ extern "C" {
|
||||
// returns true if renderer has been started successfully;
|
||||
//
|
||||
// This function is *NOT* thread safe and should be called first
|
||||
// to initialize the renderer.
|
||||
// to initialize the renderer after initLibrary().
|
||||
//
|
||||
bool initOpenGLRenderer(int width, int height, int portNum);
|
||||
|
||||
|
||||
@@ -107,24 +107,6 @@ bool FrameBuffer::initialize(int width, int height)
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// Load EGL Plugin
|
||||
//
|
||||
if (!init_egl_dispatch()) {
|
||||
// Failed to load EGL
|
||||
printf("Failed to init_egl_dispatch\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Load GLES Plugin
|
||||
//
|
||||
if (!init_gl_dispatch()) {
|
||||
// Failed to load GLES
|
||||
ERR("Failed to init_gl_dispatch\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// allocate space for the FrameBuffer object
|
||||
//
|
||||
@@ -142,7 +124,7 @@ bool FrameBuffer::initialize(int width, int height)
|
||||
fb->m_caps.hasGL2 = false;
|
||||
}
|
||||
else {
|
||||
fb->m_caps.hasGL2 = init_gl2_dispatch();
|
||||
fb->m_caps.hasGL2 = s_gl2_enabled;
|
||||
}
|
||||
#else
|
||||
fb->m_caps.hasGL2 = false;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "osDynLibrary.h"
|
||||
|
||||
gl2_decoder_context_t s_gl2;
|
||||
int s_gl2_enabled;
|
||||
|
||||
static osUtils::dynLibrary *s_gles2_lib = NULL;
|
||||
|
||||
@@ -50,6 +51,7 @@ bool init_gl2_dispatch()
|
||||
// init the GLES dispatch table
|
||||
//
|
||||
s_gl2.initDispatchByName( gl2_dispatch_get_proc_func, NULL );
|
||||
s_gl2_enabled = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ bool init_gl2_dispatch();
|
||||
void *gl2_dispatch_get_proc_func(const char *name, void *userData);
|
||||
|
||||
extern gl2_decoder_context_t s_gl2;
|
||||
extern int s_gl2_enabled;
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
#include "osProcess.h"
|
||||
#include "TimeUtils.h"
|
||||
|
||||
#include "EGLDispatch.h"
|
||||
#include "GLDispatch.h"
|
||||
#include "GL2Dispatch.h"
|
||||
|
||||
static osUtils::childProcess *s_renderProc = NULL;
|
||||
static RenderServer *s_renderThread = NULL;
|
||||
static int s_renderPort = 0;
|
||||
@@ -39,6 +43,32 @@ static IOStream *createRenderThread(int p_stream_buffer_size,
|
||||
#define RENDER_API_USE_THREAD
|
||||
//#endif
|
||||
|
||||
bool initLibrary(void)
|
||||
{
|
||||
//
|
||||
// Load EGL Plugin
|
||||
//
|
||||
if (!init_egl_dispatch()) {
|
||||
// Failed to load EGL
|
||||
printf("Failed to init_egl_dispatch\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Load GLES Plugin
|
||||
//
|
||||
if (!init_gl_dispatch()) {
|
||||
// Failed to load GLES
|
||||
ERR("Failed to init_gl_dispatch\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* failure to init the GLES2 dispatch table is not fatal */
|
||||
init_gl2_dispatch();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool initOpenGLRenderer(int width, int height, int portNum)
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user