diff --git a/tools/emulator/opengl/host/include/libOpenglRender/render_api.h b/tools/emulator/opengl/host/include/libOpenglRender/render_api.h index 0ac931a81..97a229245 100644 --- a/tools/emulator/opengl/host/include/libOpenglRender/render_api.h +++ b/tools/emulator/opengl/host/include/libOpenglRender/render_api.h @@ -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); diff --git a/tools/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp b/tools/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp index acc472a03..ef38bec6c 100644 --- a/tools/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp +++ b/tools/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp @@ -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; diff --git a/tools/emulator/opengl/host/libs/libOpenglRender/GL2Dispatch.cpp b/tools/emulator/opengl/host/libs/libOpenglRender/GL2Dispatch.cpp index a1b22d773..b461807d7 100644 --- a/tools/emulator/opengl/host/libs/libOpenglRender/GL2Dispatch.cpp +++ b/tools/emulator/opengl/host/libs/libOpenglRender/GL2Dispatch.cpp @@ -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; } diff --git a/tools/emulator/opengl/host/libs/libOpenglRender/GL2Dispatch.h b/tools/emulator/opengl/host/libs/libOpenglRender/GL2Dispatch.h index 7ad19bbec..89f36516f 100644 --- a/tools/emulator/opengl/host/libs/libOpenglRender/GL2Dispatch.h +++ b/tools/emulator/opengl/host/libs/libOpenglRender/GL2Dispatch.h @@ -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 diff --git a/tools/emulator/opengl/host/libs/libOpenglRender/render_api.cpp b/tools/emulator/opengl/host/libs/libOpenglRender/render_api.cpp index 70d28769c..eeaa631e9 100644 --- a/tools/emulator/opengl/host/libs/libOpenglRender/render_api.cpp +++ b/tools/emulator/opengl/host/libs/libOpenglRender/render_api.cpp @@ -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) {