Merge "adding support for getting gles proc address from eglGetProcAdress"
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp
index 5895e42..d019e18 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 @@
/***************************************** supported extentions ***********************************************************************/
//extentions
-typedef struct {
- const char* name;
- __eglMustCastToProperFunctionPointerType address;
-} EglExtentionDescriptor;
-
#define EGL_EXTENTIONS 2
//decleration
@@ -64,7 +59,7 @@
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 __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 f1d6b75..3d72c70 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 <cmath>
+
+
+
+
+
+
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 @@
deleteGLESContext:deleteGLESContext,
flush :glFlush,
finish :glFinish,
- setShareGroup :setShareGroup
+ setShareGroup :setShareGroup,
+ getProcAddress :getProcAddress
};
extern "C" {
@@ -68,6 +86,14 @@
}
}
+static __translatorMustCastToProperFunctionPointerType getProcAddress(const char* procName) {
+ for(int i=0;i<GLES_EXTENTIONS;i++){
+ if(strcmp(procName,s_glesExtentions[i].name) == 0){
+ return s_glesExtentions[i].address;
+ }
+ }
+ return NULL;
+}
GLESiface* __translator_getIfaces(EGLiface* eglIface){
s_eglIface = eglIface;
return & s_glesIface;
@@ -1106,7 +1132,7 @@
TextureData *texData = NULL;
ObjectDataPtr objData = thrd->shareGroup->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 cf54d9c..51ad4b3 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 @@
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;