diff --git a/nanoWrap.cpp b/nanoWrap.cpp
index a30a009de2421771b32292914fa1ae480c96ed7a..cdb9313f3469cf920bb09db177a782b42543931e 100644 (file)
--- a/nanoWrap.cpp
+++ b/nanoWrap.cpp
struct ptrstate vertex_array;
struct ptrstate color_array;
struct ptrstate texture_coord_array;
struct ptrstate vertex_array;
struct ptrstate color_array;
struct ptrstate texture_coord_array;
+ struct ptrstate normal_array;
+
};
static struct nanotmuState tmuState0;
};
static struct nanotmuState tmuState0;
{4,GL_FLOAT,0, NULL, GL_FALSE, GL_FALSE},
{4,GL_FLOAT,0, NULL, GL_FALSE, GL_FALSE},
{4,GL_FLOAT,0, NULL, GL_FALSE, GL_FALSE},
{4,GL_FLOAT,0, NULL, GL_FALSE, GL_FALSE},
{4,GL_FLOAT,0, NULL, GL_FALSE, GL_FALSE},
{4,GL_FLOAT,0, NULL, GL_FALSE, GL_FALSE},
+ {3,GL_FLOAT,0, NULL, GL_FALSE, GL_FALSE},
};
static struct nanotmuState* activetmuState = &tmuState0;
};
static struct nanotmuState* activetmuState = &tmuState0;
#endif
};
#endif
};
-static VertexAttrib vertexattribs[40000];
+static VertexAttrib vertexattribs[60000];
-static GLushort indexArray[30000];
+static GLushort indexArray[50000];
static GLuint vertexCount = 0;
static GLuint indexCount = 0;
static GLuint vertexCount = 0;
static GLuint indexCount = 0;
{
glEsImpl->glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
{
glEsImpl->glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
+
+ if (tmuState0.normal_array.enabled)
+ {
+ glEsImpl->glEnableClientState(GL_NORMAL_ARRAY);
+ }
+ else
+ {
+ glEsImpl->glDisableClientState(GL_NORMAL_ARRAY);
+ }
glEsImpl->glVertexPointer(tmuState0.vertex_array.size,
tmuState0.vertex_array.type,
tmuState0.vertex_array.stride,
glEsImpl->glVertexPointer(tmuState0.vertex_array.size,
tmuState0.vertex_array.type,
tmuState0.vertex_array.stride,
tmuState0.color_array.stride,
tmuState0.color_array.ptr);
tmuState0.color_array.stride,
tmuState0.color_array.ptr);
+ glEsImpl->glNormalPointer(
+ tmuState0.normal_array.type,
+ tmuState0.normal_array.stride,
+ tmuState0.normal_array.ptr);
+
glEsImpl->glMatrixMode(nanoglState.matrixmode);
glEsImpl->glMatrixMode(nanoglState.matrixmode);
if (delayedttmuchange)
{
delayedttmuchange = GL_FALSE;
if (delayedttmuchange)
{
delayedttmuchange = GL_FALSE;
+#ifndef USE_CORE_PROFILE
glEsImpl->glActiveTexture(delayedtmutarget);
glEsImpl->glActiveTexture(delayedtmutarget);
+#endif
}
if (!vertexCount)
}
if (!vertexCount)
default:
break;
}
default:
break;
}
+ if( ptrVertexAttribArray - vertexattribs > 20000 * sizeof(VertexAttrib) ||
+ ptrIndexArray - indexArray > 15000 * sizeof(GLushort) )
+ FlushOnStateChange();
}
void glEnable (GLenum cap)
}
void glEnable (GLenum cap)
void glOrtho (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
{
FlushOnStateChange();
void glOrtho (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
{
FlushOnStateChange();
+#ifdef USE_CORE_PROFILE
+ glEsImpl->glOrtho(left,right,bottom,top, zNear,zFar);
+#else
glEsImpl->glOrthof(left,right,bottom,top, zNear,zFar);
glEsImpl->glOrthof(left,right,bottom,top, zNear,zFar);
+#endif
}
void glMatrixMode (GLenum mode)
}
void glMatrixMode (GLenum mode)
nanoglState.depth_range_far = zFar;
}
FlushOnStateChange();
nanoglState.depth_range_far = zFar;
}
FlushOnStateChange();
+#ifdef USE_CORE_PROFILE
+ glEsImpl->glDepthRange(zNear, zFar);
+#else
glEsImpl->glDepthRangef(zNear, zFar);
glEsImpl->glDepthRangef(zNear, zFar);
+#endif
}
void glDepthFunc (GLenum func)
}
void glDepthFunc (GLenum func)
@@ -1514,7 +1544,7 @@ void glDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *indi
if (arraysValid ||
tmuState0.vertex_array.changed ||
tmuState0.color_array.changed ||
if (arraysValid ||
tmuState0.vertex_array.changed ||
tmuState0.color_array.changed ||
- tmuState0.texture_coord_array.changed)
+ tmuState0.texture_coord_array.changed || tmuState0.normal_array.changed)
{
glEsImpl->glClientActiveTexture(GL_TEXTURE0);
}
{
glEsImpl->glClientActiveTexture(GL_TEXTURE0);
}
@@ -1550,6 +1580,21 @@ void glDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *indi
tmuState0.color_array.ptr);
tmuState0.color_array.changed = GL_FALSE;
}
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 (arraysValid || tmuState0.texture_coord_array.changed)
{
tmuState0.texture_coord_array.changed = GL_FALSE;
clientstate->color_array.enabled = GL_TRUE;
clientstate->color_array.changed = GL_TRUE;
clientstate->color_array.enabled = GL_TRUE;
clientstate->color_array.changed = GL_TRUE;
+ break;
+ case GL_NORMAL_ARRAY:
+ if (clientstate->normal_array.enabled)
+ {
+ return;
+ }
+ clientstate->normal_array.enabled = GL_TRUE;
+ clientstate->normal_array.changed = GL_TRUE;
+
break;
case GL_TEXTURE_COORD_ARRAY:
if (clientstate->texture_coord_array.enabled)
break;
case GL_TEXTURE_COORD_ARRAY:
if (clientstate->texture_coord_array.enabled)
clientstate->color_array.enabled = GL_FALSE;
clientstate->color_array.changed = GL_TRUE;
clientstate->color_array.enabled = GL_FALSE;
clientstate->color_array.changed = GL_TRUE;
+ break;
+ case GL_NORMAL_ARRAY:
+ if (!clientstate->normal_array.enabled)
+ {
+ return;
+ }
+ clientstate->normal_array.enabled = GL_FALSE;
+ clientstate->normal_array.changed = GL_TRUE;
+
break;
case GL_TEXTURE_COORD_ARRAY:
if (!clientstate->texture_coord_array.enabled)
break;
case GL_TEXTURE_COORD_ARRAY:
if (!clientstate->texture_coord_array.enabled)
@@ -1735,6 +1798,23 @@ void glColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *p
tmuState0.color_array.ptr = (GLvoid*)pointer;
tmuState0.color_array.changed = GL_TRUE;
}
tmuState0.color_array.ptr = (GLvoid*)pointer;
tmuState0.color_array.changed = GL_TRUE;
}
+
+void glNormalPointer( GLenum type, GLsizei stride, const GLvoid *pointer )
+ {
+ int size = 0;
+ if (tmuState0.normal_array.size == size &&
+ tmuState0.normal_array.stride == stride &&
+ tmuState0.normal_array.type == type &&
+ tmuState0.normal_array.ptr == pointer)
+ {
+ return;
+ }
+ tmuState0.normal_array.size = size;
+ tmuState0.normal_array.stride = stride;
+ tmuState0.normal_array.type = type;
+ tmuState0.normal_array.ptr = (GLvoid*)pointer;
+ tmuState0.normal_array.changed = GL_TRUE;
+ }
void glPolygonOffset( GLfloat factor, GLfloat units )
{
FlushOnStateChange();
void glPolygonOffset( GLfloat factor, GLfloat units )
{
FlushOnStateChange();
#endif
/* Vladimir */
#endif
/* Vladimir */
-void glDrawArrays( GLenum mode, int first, int count)
+/*void glDrawArrays( GLenum mode, int first, int count)
{
FlushOnStateChange();
glEsImpl->glDrawArrays(mode, first , count);
{
FlushOnStateChange();
glEsImpl->glDrawArrays(mode, first , count);
-}
+}*/
void glMultMatrixf (const GLfloat *m)
{
FlushOnStateChange();
void glMultMatrixf (const GLfloat *m)
{
FlushOnStateChange();
FlushOnStateChange();
glEsImpl->glFrontFace(mode);
}
FlushOnStateChange();
glEsImpl->glFrontFace(mode);
}
+// End Vladimir
+void glTexEnvi (GLenum target, GLenum pname, GLint param)
+ {
+ if (target == GL_TEXTURE_ENV)
+ {
+ if (pname == GL_TEXTURE_ENV_MODE)
+ {
+ if (param == activetmuState->texture_env_mode.value)
+ {
+ return;
+ }
+ else
+ {
+ FlushOnStateChange();
+ glEsImpl->glTexEnvi(target, pname, param);
+ activetmuState->texture_env_mode.value = param;
+ return;
+ }
+ }
+ }
+ FlushOnStateChange();
+ glEsImpl->glTexEnvi(target, pname, param);
+ }
+void glMultiTexCoord3fARB(GLenum a, GLfloat b, GLfloat c, GLfloat)
+{
+ return glMultiTexCoord2fARB(a, b, c);
+}
-// End Vladimir
+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 );
+}*/
+
+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 glGenFramebuffers (GLsizei n, GLuint* framebuffers)
+{
+ FlushOnStateChange();
+ glEsImpl->glGenFramebuffers( n, framebuffers );
+}
+
+
+void glGenRenderbuffers( GLsizei n, GLuint* renderbuffers )
+{
+ FlushOnStateChange();
+ glEsImpl->glGenRenderbuffers( n, renderbuffers );
+}
+void glBindRenderbuffer(GLenum target, GLuint renderbuffer)
+{
+ FlushOnStateChange();
+ glEsImpl->glBindRenderbuffer( target, renderbuffer );
+}
+
+void glBindFramebuffer(GLenum target, GLuint framebuffer)\
+{
+ FlushOnStateChange();
+ glEsImpl->glBindFramebuffer( target, framebuffer );
+}
+
+void glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
+{
+ FlushOnStateChange();
+ glEsImpl->glFramebufferRenderbuffer( target, attachment, renderbuffertarget, renderbuffer );
+}
+
+void glDeleteFramebuffers(GLsizei n, const GLuint *framebuffers)
+{
+ FlushOnStateChange();
+ glEsImpl->glDeleteFramebuffers(n, framebuffers);
+}
+
+void glDeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers)
+{
+ FlushOnStateChange();
+ glEsImpl->glDeleteRenderbuffers( n, renderbuffers );
+}
+void glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
+{
+ FlushOnStateChange();
+ glEsImpl->glFramebufferTexture2D(target, attachment,textarget,texture,level);
+}
+
+void glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
+{
+ FlushOnStateChange();
+ glEsImpl->glRenderbufferStorage(target, internalformat, width, height );
+}