Merge "emulator: opengl: add initLibrary function to render library"

This commit is contained in:
David 'Digit' Turner
2011-08-29 08:01:42 -07:00
committed by Android Code Review
5 changed files with 45 additions and 20 deletions

View File

@@ -22,6 +22,16 @@ extern "C" {
#include "render_api_platform_types.h" #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. // initOpenGLRenderer - initialize the OpenGL renderer process.
// portNum is the tcp port number the renderer is listening to. // 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; // returns true if renderer has been started successfully;
// //
// This function is *NOT* thread safe and should be called first // 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); bool initOpenGLRenderer(int width, int height, int portNum);

View File

@@ -107,24 +107,6 @@ bool FrameBuffer::initialize(int width, int height)
return true; 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 // allocate space for the FrameBuffer object
// //
@@ -142,7 +124,7 @@ bool FrameBuffer::initialize(int width, int height)
fb->m_caps.hasGL2 = false; fb->m_caps.hasGL2 = false;
} }
else { else {
fb->m_caps.hasGL2 = init_gl2_dispatch(); fb->m_caps.hasGL2 = s_gl2_enabled;
} }
#else #else
fb->m_caps.hasGL2 = false; fb->m_caps.hasGL2 = false;

View File

@@ -20,6 +20,7 @@
#include "osDynLibrary.h" #include "osDynLibrary.h"
gl2_decoder_context_t s_gl2; gl2_decoder_context_t s_gl2;
int s_gl2_enabled;
static osUtils::dynLibrary *s_gles2_lib = NULL; static osUtils::dynLibrary *s_gles2_lib = NULL;
@@ -50,6 +51,7 @@ bool init_gl2_dispatch()
// init the GLES dispatch table // init the GLES dispatch table
// //
s_gl2.initDispatchByName( gl2_dispatch_get_proc_func, NULL ); s_gl2.initDispatchByName( gl2_dispatch_get_proc_func, NULL );
s_gl2_enabled = true;
return true; return true;
} }

View File

@@ -24,6 +24,7 @@ bool init_gl2_dispatch();
void *gl2_dispatch_get_proc_func(const char *name, void *userData); void *gl2_dispatch_get_proc_func(const char *name, void *userData);
extern gl2_decoder_context_t s_gl2; extern gl2_decoder_context_t s_gl2;
extern int s_gl2_enabled;
#endif #endif
#endif #endif

View File

@@ -20,6 +20,10 @@
#include "osProcess.h" #include "osProcess.h"
#include "TimeUtils.h" #include "TimeUtils.h"
#include "EGLDispatch.h"
#include "GLDispatch.h"
#include "GL2Dispatch.h"
static osUtils::childProcess *s_renderProc = NULL; static osUtils::childProcess *s_renderProc = NULL;
static RenderServer *s_renderThread = NULL; static RenderServer *s_renderThread = NULL;
static int s_renderPort = 0; static int s_renderPort = 0;
@@ -39,6 +43,32 @@ static IOStream *createRenderThread(int p_stream_buffer_size,
#define RENDER_API_USE_THREAD #define RENDER_API_USE_THREAD
//#endif //#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) bool initOpenGLRenderer(int width, int height, int portNum)
{ {