diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp index 5895e4257..d019e180b 100644 --- a/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp +++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp @@ -52,11 +52,6 @@ static EGLiface s_eglIface = { /***************************************** supported extentions ***********************************************************************/ //extentions -typedef struct { - const char* name; - __eglMustCastToProperFunctionPointerType address; -} EglExtentionDescriptor; - #define EGL_EXTENTIONS 2 //decleration @@ -64,7 +59,7 @@ EGLImageKHR eglCreateImageKHR(EGLDisplay display, EGLContext context, EGLenum ta EGLBoolean eglDestroyImageKHR(EGLDisplay display, EGLImageKHR image); // extentions descriptors -static EglExtentionDescriptor s_extentions[] = { +static ExtentionDescriptor s_eglExtentions[] = { {"eglCreateImageKHR" ,(__eglMustCastToProperFunctionPointerType)eglCreateImageKHR}, {"eglDestroyImageKHR",(__eglMustCastToProperFunctionPointerType)eglDestroyImageKHR} }; @@ -883,16 +878,21 @@ EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void) { EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress(const char *procname){ + __eglMustCastToProperFunctionPointerType retVal = NULL; if(!strncmp(procname,"egl",3)) { //EGL proc for(int i=0;i < EGL_EXTENSIONS;i++){ - if(strcmp(procname,s_extentions[i].name) == 0){ - return s_extentions[i].address; + if(strcmp(procname,s_eglExtentions[i].name) == 0){ + retVal = s_eglExtentions[i].address; + break; } } } else if (!strncmp(procname,"gl",2)){ //GL proc - //TODO:call glGetProcAdress + retVal = g_eglInfo->getIface(GLES_1_1)->getProcAddress(procname); //try to get it from GLES 1.0 + if(!retVal){ //try to get it from GLES 2.0 + retVal = g_eglInfo->getIface(GLES_2_0)->getProcAddress(procname); + } } - return NULL; + return retVal; } //not supported for now /************************* NOT SUPPORTED FOR NOW ***********************/ diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESimp.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESimp.cpp index f1d6b75fa..3d72c7050 100644 --- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESimp.cpp +++ b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESimp.cpp @@ -28,16 +28,33 @@ #include + + + + + + extern "C" { //decleration static void initContext(GLEScontext* ctx); -static GLEScontext* createGLESContext(); static void deleteGLESContext(GLEScontext* ctx); static void setShareGroup(GLEScontext* ctx,ShareGroupPtr grp); +static GLEScontext* createGLESContext(); +static __translatorMustCastToProperFunctionPointerType getProcAddress(const char* procName); } +/************************************** GLES EXTENSIONS *********************************************************/ +#define GLES_EXTENTIONS 1 +//extensions decleration +void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image); + +//extentions descriptor +static ExtentionDescriptor s_glesExtentions[] = { + {"glEGLImageTargetTexture2DOES",(__translatorMustCastToProperFunctionPointerType)glEGLImageTargetTexture2DOES} + }; +/****************************************************************************************************************/ static EGLiface* s_eglIface = NULL; static GLESiface s_glesIface = { createGLESContext:createGLESContext, @@ -45,7 +62,8 @@ static GLESiface s_glesIface = { deleteGLESContext:deleteGLESContext, flush :glFlush, finish :glFinish, - setShareGroup :setShareGroup + setShareGroup :setShareGroup, + getProcAddress :getProcAddress }; extern "C" { @@ -68,6 +86,14 @@ static void setShareGroup(GLEScontext* ctx,ShareGroupPtr grp) { } } +static __translatorMustCastToProperFunctionPointerType getProcAddress(const char* procName) { + for(int i=0;ishareGroup->getObjectData(TEXTURE,tex); if(!objData.Ptr()){ - TextureData *texData = new TextureData(); + texData = new TextureData(); thrd->shareGroup->setObjectData(TEXTURE, tex, ObjectDataPtr(texData)); } else { texData = (TextureData*)objData.Ptr(); diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h index cf54d9cdd..51ad4b32f 100644 --- a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h +++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h @@ -20,6 +20,16 @@ extern "C" { +/* This is a generic function pointer type, whose name indicates it must + * be cast to the proper type *and calling convention* before use. + */ +typedef void (*__translatorMustCastToProperFunctionPointerType)(void); + +typedef struct { + const char* name; + __translatorMustCastToProperFunctionPointerType address; +}ExtentionDescriptor; + class TextureData : public ObjectData { public: @@ -53,12 +63,13 @@ typedef std::map< unsigned int, ImagePtr> ImagesHndlMap; class GLEScontext; typedef struct { - GLEScontext* (*createGLESContext)(); - void (*initContext)(GLEScontext*); - void (*deleteGLESContext)(GLEScontext*); - void (*flush)(); - void (*finish)(); - void (*setShareGroup)(GLEScontext*,ShareGroupPtr); + GLEScontext* (*createGLESContext)(); + void (*initContext)(GLEScontext*); + void (*deleteGLESContext)(GLEScontext*); + void (*flush)(); + void (*finish)(); + void (*setShareGroup)(GLEScontext*,ShareGroupPtr); + __translatorMustCastToProperFunctionPointerType (*getProcAddress)(const char*); }GLESiface;