DEADSOFTWARE

Make XashXT renderer work
authormittorn <mittorn@sibmail.com>
Sun, 24 Jul 2016 20:27:51 +0000 (20:27 +0000)
committermittorn <mittorn@sibmail.com>
Sun, 24 Jul 2016 20:27:51 +0000 (20:27 +0000)
Android.mk
GL/gl.h
GL/gl_entries.in
nanoWrap.cpp
nanogl.cpp

index 70c563406f9e9769b2fea70adefc69c82bf44e4f..7cba0426a4286406c5bf5ef2fe7cb88152de5dec 100644 (file)
@@ -20,7 +20,7 @@ LOCAL_MODULE    := NanoGL
 
 include $(XASH3D_CONFIG)
 
-LOCAL_CFLAGS +=
+LOCAL_CFLAGS += -D__MULTITEXTURE_SUPPORT__
 
 LOCAL_C_INCLUDES := $(LOCAL_PATH)/GL
 
diff --git a/GL/gl.h b/GL/gl.h
index 48fb508121d87303a14b54b4497dfd61fc1632c7..37a2a8426020a9b2084e94f54b5fd6e59e026200 100644 (file)
--- a/GL/gl.h
+++ b/GL/gl.h
@@ -718,10 +718,11 @@ void glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderb
 
 void glNormalPointer(GLenum type, GLsizei stride, const void *ptr);
 
-void pglMultiTexCoord3f(GLenum, GLfloat, GLfloat, GLfloat);
+void glMultiTexCoord3f(GLenum, GLfloat, GLfloat, GLfloat);
 
-void pglMultiTexCoord2f(GLenum, GLfloat, GLfloat);
+void glMultiTexCoord2f(GLenum, GLfloat, GLfloat);
 
+void glDrawArrays( GLenum mode, GLint first, GLsizei count );
 
 #ifdef __cplusplus
 }
index 70b1fb3a65d2ce29f13c0122209b90281ec8f46f..19220c2532bae8c7dd50f73eb71e4f898d6d5fac 100644 (file)
 #endif
 
 // fbo
-GL_ENTRY(void, glGenFramebuffers, GLsizei n, GLuint* framebuffers)
-GL_ENTRY(void, glGenRenderbuffers, GLsizei n, GLuint* renderbuffers)
-GL_ENTRY(void, glRenderbufferStorage, GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
-GL_ENTRY(void, glBindFramebuffer, GLenum target, GLuint framebuffer)
-GL_ENTRY(void, glBindRenderbuffer, GLenum target, GLuint renderbuffer)
-GL_ENTRY(void, glFramebufferTexture2D, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
-GL_ENTRY(void, glDeleteRenderbuffers, GLsizei n, const GLuint* renderbuffers)
-GL_ENTRY(void, glDeleteFramebuffers, GLsizei n, const GLuint* framebuffers)
-GL_ENTRY(void, glFramebufferRenderbuffer, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
+GL_ENTRY(void,glGenFramebuffersOES, GLsizei n, GLuint* framebuffers)
+GL_ENTRY(void,glGenRenderbuffersOES, GLsizei n, GLuint* renderbuffers)
+GL_ENTRY(void,glRenderbufferStorageOES, GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
+GL_ENTRY(void,glBindFramebufferOES, GLenum target, GLuint framebuffer)
+GL_ENTRY(void,glBindRenderbufferOES, GLenum target, GLuint renderbuffer)
+GL_ENTRY(void,glFramebufferTexture2DOES, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
+GL_ENTRY(void,glDeleteRenderbuffersOES, GLsizei n, const GLuint* renderbuffers)
+GL_ENTRY(void,glDeleteFramebuffersOES, GLsizei n, const GLuint* framebuffers)
+GL_ENTRY(void,glFramebufferRenderbufferOES, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
index 5ea8acf7ac6060b1f1c28f5ca5c793603a942c92..a2189f3164bffae87fe64c65efb5f2022da995fe 100644 (file)
@@ -1839,11 +1839,11 @@ void glMultiTexCoord2fARB( GLenum target, GLfloat s, GLfloat t )
 #endif
 
 /* Vladimir  */
-void glDrawArrays( GLenum mode, int first, int count)
+/*void glDrawArrays( GLenum mode, int first, int count)
 {
     FlushOnStateChange();
     glEsImpl->glDrawArrays(mode, first , count);
-}
+}*/
 void glMultMatrixf (const GLfloat *m)
 {
     FlushOnStateChange();
@@ -1942,16 +1942,114 @@ void glTexEnvi (GLenum target, GLenum pname, GLint param)
     glEsImpl->glTexEnvi(target, pname, param);
     }
 
-void pglMultiTexCoord3f(GLenum, GLfloat, GLfloat, GLfloat)
+void glMultiTexCoord3fARB(GLenum, GLfloat, GLfloat, GLfloat)
 {
 
 }
 
-void pglMultiTexCoord2f(GLenum, GLfloat, GLfloat)
+void glMultiTexCoord2f(GLenum, GLfloat, GLfloat)
 {
 
 }
+void glDrawArrays( GLenum mode, GLint first, GLsizei count )
+       {
+       // ensure that all primitives specified between glBegin/glEnd pairs
+       // are rendered first, and that we have correct tmu in use..
+       if( mode == GL_QUADS ) mode = GL_TRIANGLE_FAN;
+       FlushOnStateChange();
+       // setup correct vertex/color/texcoord pointers
+       if (arraysValid ||
+               tmuState0.vertex_array.changed ||
+               tmuState0.color_array.changed ||
+               tmuState0.texture_coord_array.changed || tmuState0.normal_array.changed)
+               {
+               glEsImpl->glClientActiveTexture(GL_TEXTURE0);
+               }
+       if (arraysValid || tmuState0.vertex_array.changed)
+               {
+               if (tmuState0.vertex_array.enabled)
+                       {
+                       glEsImpl->glEnableClientState(GL_VERTEX_ARRAY);
+                       }
+               else
+                       {
+                       glEsImpl->glDisableClientState(GL_VERTEX_ARRAY);
+                       }
+               glEsImpl->glVertexPointer(tmuState0.vertex_array.size,
+                                                                 tmuState0.vertex_array.type,
+                                                                 tmuState0.vertex_array.stride,
+                                                                 tmuState0.vertex_array.ptr);
+               tmuState0.vertex_array.changed = GL_FALSE;
+               }
+       if (arraysValid || tmuState0.color_array.changed)
+               {
+               if (tmuState0.color_array.enabled)
+                       {
+                       glEsImpl->glEnableClientState(GL_COLOR_ARRAY);
+                       }
+               else
+                       {
+                       glEsImpl->glDisableClientState(GL_COLOR_ARRAY);
+                       }
+               glEsImpl->glColorPointer(tmuState0.color_array.size,
+                                                                tmuState0.color_array.type,
+                                                                tmuState0.color_array.stride,
+                                                                tmuState0.color_array.ptr);
+               tmuState0.color_array.changed = GL_FALSE;
+               }
+       if (arraysValid || tmuState0.normal_array.changed)
+               {
+               if (tmuState0.normal_array.enabled)
+                       {
+                       glEsImpl->glEnableClientState(GL_NORMAL_ARRAY);
+                       }
+               else
+                       {
+                       glEsImpl->glDisableClientState(GL_NORMAL_ARRAY);
+                       }
+               glEsImpl->glNormalPointer(tmuState0.normal_array.type,
+                                                                tmuState0.normal_array.stride,
+                                                                tmuState0.normal_array.ptr);
+               tmuState0.normal_array.changed = GL_FALSE;
+               }
+       if (arraysValid || tmuState0.texture_coord_array.changed)
+               {
+               tmuState0.texture_coord_array.changed = GL_FALSE;
+               if (tmuState0.texture_coord_array.enabled)
+                       {
+                       glEsImpl->glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+                       }
+               else
+                       {
+                       glEsImpl->glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+                       }
+               glEsImpl->glTexCoordPointer(tmuState0.texture_coord_array.size,
+                                                                               tmuState0.texture_coord_array.type,
+                                                                               tmuState0.texture_coord_array.stride,
+                                                                               tmuState0.texture_coord_array.ptr);
+               }
+
+       if (arraysValid || tmuState1.texture_coord_array.changed)
+               {
+               tmuState1.texture_coord_array.changed = GL_FALSE;
+               glEsImpl->glClientActiveTexture(GL_TEXTURE1);
+               if (tmuState1.texture_coord_array.enabled)
+                       {
+                       glEsImpl->glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+                       }
+               else
+                       {
+                       glEsImpl->glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+                       }
+               glEsImpl->glTexCoordPointer(tmuState1.texture_coord_array.size,
+                                                                               tmuState1.texture_coord_array.type,
+                                                                               tmuState1.texture_coord_array.stride,
+                                                                               tmuState1.texture_coord_array.ptr);
+               }
 
+       arraysValid = GL_FALSE;
+       glEsImpl->glDrawArrays(mode, first, count);
+       }
 /*void glNormalPointer(GLenum type, GLsizei stride, const void *ptr)
 {
     glEsImpl->glNormalPointer( type, stride, ptr );
@@ -1973,7 +2071,7 @@ void glGenFramebuffers (GLsizei n, GLuint* framebuffers)
 void glGenRenderbuffers( GLsizei n, GLuint* renderbuffers )
 {
     FlushOnStateChange();
-    glEsImpl->glGenFramebuffers( n, renderbuffers );
+       glEsImpl->glGenRenderbuffers( n, renderbuffers );
 }
 
 void glBindRenderbuffer(GLenum target, GLuint renderbuffer)
index 5f97fedb31343614e90665792f708383dcebe332..c8454b079163a82e5796de264ea3f41f5bdd6314 100644 (file)
@@ -144,9 +144,9 @@ static int CreateGlEsInterface( const char * name, void * lib, void * lib1, void
                                if ( f == NULL ) {
                                        LOGE ( "<%s> not found in libEGL.so", *api);
                     if( glEsImpl->eglGetProcAddress && ( (void*)glEsImpl->eglGetProcAddress != (void*)gl_unimplemented ) )
-                        f = glEsImpl->eglGetProcAddress( *api );
+                        f = (void*)glEsImpl->eglGetProcAddress( *api );
                     if(f == NULL)
-                        f = default_func; //(void*)gl_unimplemented;
+                        f = (void*)default_func; //(void*)gl_unimplemented;
 
                                }
                                else {
@@ -157,9 +157,9 @@ static int CreateGlEsInterface( const char * name, void * lib, void * lib1, void
                        {
                                LOGE ( "libEGL.so not loaded!");
                             if( glEsImpl->eglGetProcAddress && ( (void*)glEsImpl->eglGetProcAddress != (void*)gl_unimplemented ) )
-                                f = glEsImpl->eglGetProcAddress( *api );
+                                f = (void*)glEsImpl->eglGetProcAddress( *api );
                 if( !f )
-                               f = default_func;
+                               f = (void*)default_func;
                        }
                }
                else {
@@ -285,6 +285,19 @@ int nanoGL_Init()
            return 0;
     }
 
+#ifdef __ANDROID__
+       // somewhy it does not initialize correctly
+       *((void**)&glEsImpl->glGenFramebuffers) = (void*)glEsImpl->eglGetProcAddress( "glGenFramebuffersOES" );
+       *((void**)&glEsImpl->glGenRenderbuffers) = (void*)glEsImpl->eglGetProcAddress( "glGenRenderbuffersOES" );
+       *((void**)&glEsImpl->glRenderbufferStorage) = (void*)glEsImpl->eglGetProcAddress( "glRenderbufferStorageOES" );
+       *((void**)&glEsImpl->glBindFramebuffer) = (void*)glEsImpl->eglGetProcAddress( "glBindFramebufferOES" );
+       *((void**)&glEsImpl->glBindRenderbuffer) = (void*)glEsImpl->eglGetProcAddress( "glBindRenderbufferOES" );
+       *((void**)&glEsImpl->glFramebufferTexture2D) = (void*)glEsImpl->eglGetProcAddress( "glFramebufferTexture2DOES" );
+       *((void**)&glEsImpl->glDeleteRenderbuffers) = (void*)glEsImpl->eglGetProcAddress( "glDeleteRenderbuffersOES" );
+       *((void**)&glEsImpl->glDeleteFramebuffers) = (void*)glEsImpl->eglGetProcAddress( "glDeleteFramebuffersOES" );
+       *((void**)&glEsImpl->glFramebufferRenderbuffer) = (void*)glEsImpl->eglGetProcAddress( "glFramebufferRenderbufferOES" );
+#endif
+
        // Init nanoGL
        InitGLStructs();
        return 1;