DEADSOFTWARE

Fix typo in nanoGL_GetProcAddress, return 1 in nanoGL_Init() if wrapper already initi...
[nanogl.git] / nanoWrap.cpp
index bfeee743ba0b13f521a55ef3b620f276997348ef..b50f348107cf50b49da8dee55043146290d88996 100644 (file)
@@ -28,6 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "gl.h"
 #include "glesinterface.h"
+#include "nanogl.h"
 
 #define GL_TEXTURE0_ARB                     0x84C0
 #define GL_TEXTURE1_ARB                     0x84C1
@@ -205,7 +206,7 @@ struct VertexAttrib
 #endif
     };
 
-static VertexAttrib vertexattribs[8000];
+static VertexAttrib vertexattribs[40000];
 
 static GLushort indexArray[30000];
 
@@ -259,6 +260,64 @@ void InitGLStructs()
     arraysValid = GL_FALSE;
     }
 
+void ResetNanoState()
+{
+
+       if (tmuState0.color_array.enabled)
+       {
+               glEsImpl->glEnableClientState(GL_COLOR_ARRAY);
+       }
+       else
+       {
+               glEsImpl->glDisableClientState(GL_COLOR_ARRAY);
+       }
+
+       if (tmuState0.vertex_array.enabled)
+       {
+               glEsImpl->glEnableClientState(GL_VERTEX_ARRAY);
+       }
+       else
+       {
+               glEsImpl->glDisableClientState(GL_VERTEX_ARRAY);
+       }
+
+       if (tmuState0.texture_coord_array.enabled)
+       {
+               glEsImpl->glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+       }
+       else
+       {
+               glEsImpl->glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+       }
+       glEsImpl->glVertexPointer(tmuState0.vertex_array.size,
+                       tmuState0.vertex_array.type,
+                       tmuState0.vertex_array.stride,
+                       tmuState0.vertex_array.ptr);
+
+       glEsImpl->glTexCoordPointer(tmuState0.texture_coord_array.size,
+                       tmuState0.texture_coord_array.type,
+                       tmuState0.texture_coord_array.stride,
+                       tmuState0.texture_coord_array.ptr);
+
+       glEsImpl->glColorPointer(tmuState0.color_array.size,
+                       tmuState0.color_array.type,
+                       tmuState0.color_array.stride,
+                       tmuState0.color_array.ptr);
+
+       glEsImpl->glMatrixMode(nanoglState.matrixmode);
+
+
+
+       glEsImpl->glColor4f (currentVertexAttrib.red, currentVertexAttrib.green, currentVertexAttrib.blue, currentVertexAttrib.alpha);
+
+       glEsImpl->glBlendFunc(nanoglState.sfactor, nanoglState.dfactor);
+
+       //glEsImpl->glBindTexture(GL_TEXTURE_2D, stackTextureState);
+
+       glEsImpl->glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, activetmuState->texture_env_mode.value);
+
+       arraysValid = GL_FALSE;
+}
 
 void FlushOnStateChange()
     {
@@ -302,7 +361,14 @@ void FlushOnStateChange()
     ptrIndexArray = indexArray;
     useTexCoordArray = GL_FALSE;
     }
-
+void nanoGL_Flush()
+       {
+       FlushOnStateChange();
+       }
+void nanoGL_Reset()
+{
+       ResetNanoState();
+}
 void glBegin(GLenum mode)
     {
     wrapperPrimitiveMode = mode;
@@ -1110,6 +1176,91 @@ void glColor3fv( const GLfloat *v )
 
 //-- nicknekit: xash3d funcs --
 
+void glGetDoublev( GLenum pname, GLdouble *params)
+    {
+    glGetFloatv( pname, (GLfloat *)params );
+    }
+    
+void glIndexPointer( GLenum type, GLsizei stride, const GLvoid *pointer ) { }
+void glTexCoord1f( GLfloat s )
+{
+    glTexCoord2f( s, 0 );
+}
+
+void glTexCoord3f( GLfloat s, GLfloat t, GLfloat r )
+{
+    glTexCoord2f( s, t );
+}
+
+void glTexCoord4f( GLfloat s, GLfloat t, GLfloat r, GLfloat q)
+{
+    glTexCoord2f( s, t );
+}
+
+void glTexGenf( GLenum coord, GLenum pname, GLfloat param )
+{
+    
+}
+
+void glRasterPos2f( GLfloat x, GLfloat y ) { }
+
+void glPushAttrib( GLbitfield mask ) { }
+
+void glPopAttrib( ) { }
+
+void glLoadMatrixd( GLdouble *m ) 
+{
+    glLoadMatrixf( (GLfloat *)m);
+}
+
+void glMultMatrixd( GLdouble *m ) 
+{
+    glMultMatrixf( (GLfloat *)m );
+}
+
+void glRotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z ) 
+{
+    glRotatef( angle, x, y, z );
+}
+
+void glScaled( GLdouble x, GLdouble y, GLdouble z) 
+{
+    glScalef( x, y, z ); 
+}
+
+void glTranslated( GLdouble x, GLdouble y, GLdouble z ) 
+{
+    glTranslatef( x, y, z);
+}
+
+void glDrawPixels( GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ) { }
+
+GLboolean glIsList( GLuint list ) { }
+
+void glPixelStoref( GLenum pname, GLfloat param ) 
+{
+    glPixelStorei( pname, param ); 
+}
+
+void glCopyTexImage1D( GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border )
+{
+    glCopyTexImage2D( target, level, internalFormat, x, y, width, 0, border );
+}
+
+void glCopyTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width ) 
+{
+       glCopyTexSubImage2D( target, level, xoffset, 0, x, y, width, 0 );
+}
+
+void glPolygonStipple( const GLubyte *mask ) { }
+
+void glGetClipPlane( GLenum plane, const GLdouble *equation ) { }
+
+void glFogi( GLenum pname, GLint param ) 
+{
+    glFogf( pname, param );
+}
+
 void glColor4ub( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
     {
     currentVertexAttrib.red = red;
@@ -1182,6 +1333,56 @@ void glTexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
 //for mirrors? not needed for original hl?
 }
 
+void glTexEnvi( GLenum target, GLenum pname, GLint param )
+{
+       FlushOnStateChange();
+       glEsImpl->glTexEnvi( target, pname, param );
+}
+
+void glTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
+{
+       for( ; params; params++ )
+       {
+               glTexEnvf( target, pname, *params );
+       }
+}
+
+void glCopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height )
+{
+       FlushOnStateChange();
+       glEsImpl->glCopyTexSubImage2D( target, level, xoffset, yoffset, x, y, width, height );
+}
+
+void glGetTexEnviv( GLenum target, GLenum pname, GLint *params )
+{
+       FlushOnStateChange();
+       glEsImpl->glGetTexEnviv( target, pname, params );
+}
+
+void glNormal3f( GLfloat nx, GLfloat ny, GLfloat nz )
+{
+       FlushOnStateChange();
+       glEsImpl->glNormal3f( nx, ny, nz );
+}
+
+void glGetBooleanv( GLenum pname, GLboolean *params )
+{
+       FlushOnStateChange();
+       glEsImpl->glGetBooleanv( pname, params );
+}
+
+void glNormalPointer( GLenum type, GLsizei stride, const GLvoid *pointer )
+{
+       FlushOnStateChange();
+       glEsImpl->glNormalPointer( type, stride, pointer );
+}
+
+void glIsEnabled( GLenum cap )
+{
+       FlushOnStateChange();
+       glEsImpl->glIsEnabled( cap );
+}
+
 //-- --//
 
 void glHint (GLenum target, GLenum mode)
@@ -1354,7 +1555,7 @@ void glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
 
 GLenum glGetError (void)
     {
-    FlushOnStateChange();
+    //FlushOnStateChange();
     return GL_NO_ERROR;//glEsImpl->glGetError();
     }
 
@@ -1661,7 +1862,7 @@ void glColorPointer( GLint size,  GLenum type,  GLsizei stride,  const GLvoid *p
         tmuState0.color_array.type == type &&
         tmuState0.color_array.ptr == pointer)
         {
-        return;
+               return;
         }
     tmuState0.color_array.size = size;
     tmuState0.color_array.stride = stride;
@@ -1682,7 +1883,7 @@ void glClearStencil( GLint s ) {}
 extern "C" void glMultiTexCoord2fARB( GLenum target, GLfloat s, GLfloat t );
 
 void glMultiTexCoord2fARB( GLenum target, GLfloat s, GLfloat t )
-    {
+{
     if (target == GL_TEXTURE0)
         {
         glTexCoord2f(s,t);