DEADSOFTWARE

Fix typo in nanoGL_GetProcAddress, return 1 in nanoGL_Init() if wrapper already initi...
[nanogl.git] / nanogl.cpp
index c16a7a0f1f103acee3b39442752cfce2636f3999..64c5f4da9eb5f8b90faec6a93af1f35590197867 100644 (file)
@@ -64,12 +64,32 @@ static void* glesLib = NULL;
 
 GlESInterface* glEsImpl = NULL;
 
+int initialized = 0;
+
 extern void InitGLStructs();
 
 static void gl_unimplemented() { 
        LOGE ("Called unimplemented OpenGL ES API\n"); 
 }
 
+void *nanoGL_GetProcAddress(const char *procname)
+{
+#if defined(__MULTITEXTURE_SUPPORT__)
+       if (!strcmp(procname, "glMultiTexCoord2fARB"))
+       {
+               return (void*)&glMultiTexCoord2fARB;
+       }
+       else if (!strcmp(procname, "glActiveTextureARB"))
+       {
+               return (void*)&glActiveTexture;
+       }
+       else if (!strcmp(procname, "glClientActiveTextureARB"))
+       {
+               return (void*)&glClientActiveTexture;
+       }
+#endif
+       return dlsym(glesLib, procname);
+}
 
 static int CreateGlEsInterface( const char * name, void * lib, void * lib1, void * default_func )
 {
@@ -92,7 +112,7 @@ static int CreateGlEsInterface( const char * name, void * lib, void * lib1, void
        {
                void * f;
                
-               f = dlsym(lib, *api); // ltry ibGLESxx_CM.so
+               f = dlsym(lib, *api); // try libGLESxx_CM.so
 
                if (f == NULL) {
                        LOGW( "<%s> not found in %s. Trying libEGL.so.", *api, name); //driver);
@@ -135,6 +155,8 @@ static int loadDriver(const char * name) {
  */
 int nanoGL_Init()
 {
+       if( initialized ) return 1;
+
        const char * lib1 = "libGLESv1_CM.so";  // Has both gl* & egl* funcs SDK < 1.5
        const char * lib2 = "libGLESv2.so";     // Only gl* funcs SDK >= 1.5
        const char * lib3 = "libEGL.so";                // Only egl* funcs SDK >= 1.5
@@ -183,6 +205,7 @@ int nanoGL_Init()
 
        // Init nanoGL
        InitGLStructs();
+       initialized = 1;
        return 1;
 }