summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ae8ec8d)
raw | patch | inline | side by side (parent: ae8ec8d)
author | mittorn <mittorn@sibmail.com> | |
Sat, 17 Jun 2017 11:06:21 +0000 (17:06 +0600) | ||
committer | mittorn <mittorn@sibmail.com> | |
Sat, 17 Jun 2017 11:06:21 +0000 (17:06 +0600) |
GL/gl.h | patch | blob | history | |
GL/glesinterface.h | patch | blob | history | |
nanoWrap.cpp | patch | blob | history | |
nanogl.cpp | patch | blob | history |
index edf91028a413b84a2045ba1421d86f481d599f57..159d671a9b923f7c2b583678a3f97fe9e79f748a 100644 (file)
--- a/GL/gl.h
+++ b/GL/gl.h
#define glVertex3d glVertex3f
//#define glColor4ub(x,y,z,p) glColor4f(x,y,z,p) //nicknekit: wtf???
#define glFogi glFogf
+#define glActiveTextureARB glActiveTexture
+#define glClientActiveTextureARB glClientActiveTexture
//
void glBegin( GLenum mode );
void glDrawArrays( GLenum mode, GLint first, GLsizei count );
+
+void glBindBufferARB( GLuint target, GLuint index );
+
+void glGenBuffersARB( GLuint count, GLuint *indexes );
+
+void glDeleteBuffersARB( GLuint count, GLuint *indexes );
+
+void glBufferDataARB( GLuint target, GLuint size, void *buffer, GLuint type );
+
+void glBufferSubDataARB( GLuint target, GLsizei offset, GLsizei size, void *buffer );
+
#ifdef __cplusplus
}
#endif
diff --git a/GL/glesinterface.h b/GL/glesinterface.h
index 8231fda870bb45aacf681f01954a2e7d57b1201c..ce35d88a84728ce5f8bda1724f829b33b802bc60 100644 (file)
--- a/GL/glesinterface.h
+++ b/GL/glesinterface.h
void( APIENTRY *glDeleteRenderbuffers )( unsigned int n, const unsigned int *renderbuffers ) S;
void( APIENTRY *glDeleteFramebuffers )( unsigned int n, const unsigned int *framebuffers ) S;
void( APIENTRY *glFramebufferRenderbuffer )( unsigned int target, unsigned int attachment, unsigned int renderbuffertarget, unsigned int renderbuffer ) S;
+ void( APIENTRY *glTexGenfvOES )(unsigned int coord, unsigned int pname, const float *params);
+ void( APIENTRY *glTexGeniOES )(unsigned int coord, unsigned int pname, int param);
};
#if !defined( __WINS__ )
#if defined( __TARGET_FPU_VFP )
diff --git a/nanoWrap.cpp b/nanoWrap.cpp
index b46b4c796cf1dff53a3d1beea2b600141a8f48b4..3a6fb389186ffabacd6c7c2f95abab39d0631dd8 100644 (file)
--- a/nanoWrap.cpp
+++ b/nanoWrap.cpp
static GLboolean arraysValid = GL_FALSE;
+static GLboolean skipnanogl;
+
void InitGLStructs( )
{
ptrVertexAttribArray = vertexattribs;
glEsImpl->glMatrixMode( nanoglState.matrixmode );
- glEsImpl->glColor4f( currentVertexAttrib.red, currentVertexAttrib.green, currentVertexAttrib.blue, currentVertexAttrib.alpha );
+ glEsImpl->glColor4f( currentVertexAttrib.red/255.0f, currentVertexAttrib.green/255.0f,
+ currentVertexAttrib.blue/255.0f, currentVertexAttrib.alpha/255.0f );
glEsImpl->glBlendFunc( nanoglState.sfactor, nanoglState.dfactor );
glEsImpl->glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, activetmuState->texture_env_mode.value );
arraysValid = GL_FALSE;
+ skipnanogl = GL_FALSE;
}
void FlushOnStateChange( )
{
+ if( skipnanogl )
+ return;
if ( delayedttmuchange )
{
delayedttmuchange = GL_FALSE;
void glEnable( GLenum cap )
{
+ if( skipnanogl )
+ {
+ glEsImpl->glEnable( cap );
+ return;
+ }
GLboolean statechanged = GL_FALSE;
switch ( cap )
{
case GL_STENCIL_TEST:
{
return;
- /* if (!nanoglState.stencil_test)
+ if (!nanoglState.stencil_test)
{
nanoglState.stencil_test = GL_TRUE;
statechanged = GL_TRUE;
- }*/
+ }
break;
}
case GL_TEXTURE_2D:
}
break;
}
+#if 0 // todo: implement cubemap texgen
+ case GL_TEXTURE_GEN_S:
+ case GL_TEXTURE_GEN_T:
+ case GL_TEXTURE_GEN_R:
+ case GL_TEXTURE_GEN_Q:
+ {
+ FlushOnStateChange( );
+ nanoglState.texgen = true;
+ return;
+ }
+#endif
default:
break;
}
void glDisable( GLenum cap )
{
+ if( skipnanogl )
+ {
+ glEsImpl->glDisable( cap );
+ return;
+ }
GLboolean statechanged = GL_FALSE;
switch ( cap )
{
case GL_STENCIL_TEST:
{
return;
- /* if (nanoglState.stencil_test)
+ if (nanoglState.stencil_test)
{
nanoglState.stencil_test = GL_FALSE;
statechanged = GL_TRUE;
- }*/
+ }
break;
}
case GL_TEXTURE_2D:
}
break;
}
+#if 0
+ case GL_TEXTURE_GEN_S:
+ case GL_TEXTURE_GEN_T:
+ case GL_TEXTURE_GEN_R:
+ case GL_TEXTURE_GEN_Q:
+ {
+ FlushOnStateChange( );
+ nanoglState.texgen = false;
+ return;
+ }
+#endif
default:
break;
}
currentVertexAttrib.blue = (unsigned char)ClampTo255( v[2] * 255.0f );
}
currentVertexAttrib.alpha = (unsigned char)ClampTo255( v[3] * 255.0f );
+ if( skipnanogl )
+ glEsImpl->glColor4f( currentVertexAttrib.red/255.0f, currentVertexAttrib.green/255.0f,
+ currentVertexAttrib.blue/255.0f, currentVertexAttrib.alpha/255.0f );
}
void glColor3ubv( const GLubyte *v )
currentVertexAttrib.green = v[1];
currentVertexAttrib.blue = v[2];
currentVertexAttrib.alpha = 255;
+ if( skipnanogl )
+ glEsImpl->glColor4f( currentVertexAttrib.red/255.0f, currentVertexAttrib.green/255.0f,
+ currentVertexAttrib.blue/255.0f, currentVertexAttrib.alpha/255.0f );
}
void glColor4ubv( const GLubyte *v )
currentVertexAttrib.blue = v[2];
}
currentVertexAttrib.alpha = v[3];
+ if( skipnanogl )
+ glEsImpl->glColor4f( currentVertexAttrib.red/255.0f, currentVertexAttrib.green/255.0f,
+ currentVertexAttrib.blue/255.0f, currentVertexAttrib.alpha/255.0f );
}
void glColor3fv( const GLfloat *v )
currentVertexAttrib.green = (unsigned char)ClampTo255( v[1] * 255.0f );
currentVertexAttrib.blue = (unsigned char)ClampTo255( v[2] * 255.0f );
currentVertexAttrib.alpha = 255;
+ if( skipnanogl )
+ glEsImpl->glColor4f( currentVertexAttrib.red/255.0f, currentVertexAttrib.green/255.0f,
+ currentVertexAttrib.blue/255.0f, currentVertexAttrib.alpha/255.0f );
}
//-- nicknekit: xash3d funcs --
currentVertexAttrib.blue = blue;
}
currentVertexAttrib.alpha = alpha;
+ if( skipnanogl )
+ glEsImpl->glColor4f( currentVertexAttrib.red/255.0f, currentVertexAttrib.green/255.0f,
+ currentVertexAttrib.blue/255.0f, currentVertexAttrib.alpha/255.0f );
}
void glColor3ub( GLubyte red, GLubyte green, GLubyte blue )
currentVertexAttrib.green = green;
currentVertexAttrib.blue = blue;
currentVertexAttrib.alpha = 255;
+ if( skipnanogl )
+ glEsImpl->glColor4f( currentVertexAttrib.red/255.0f, currentVertexAttrib.green/255.0f,
+ currentVertexAttrib.blue/255.0f, currentVertexAttrib.alpha/255.0f );
}
void glNormal3fv( const GLfloat *v )
return glEsImpl->glIsTexture( texture );
}
+// TODO: add native normal/reflection map texgen support
+
void glTexGeni( GLenum coord, GLenum pname, GLint param )
{
- //for mirrors? not needed for original hl?
+ FlushOnStateChange();
+ //glEsImpl->glTexGeniOES( coord, pname, param );
}
void glTexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
{
- //for mirrors? not needed for original hl?
+ FlushOnStateChange();
+ //glEsImpl->glTexGenfvOES( coord, pname, params );
}
//-- --//
void glBlendFunc( GLenum sfactor, GLenum dfactor )
{
+ if( skipnanogl )
+ {
+ glEsImpl->glBlendFunc( sfactor, dfactor );
+ return;
+ }
if ( ( nanoglState.sfactor == sfactor ) && ( nanoglState.dfactor == dfactor ) )
{
return;
void glTexEnvf( GLenum target, GLenum pname, GLfloat param )
{
+ if( skipnanogl )
+ {
+ glEsImpl->glTexEnvf( target, pname, param );
+ return;
+ }
if ( target == GL_TEXTURE_ENV )
{
if ( pname == GL_TEXTURE_ENV_MODE )
void glDepthMask( GLboolean flag )
{
+ if( !skipnanogl )
+ {
if ( nanoglState.depthmask == flag )
{
return;
}
nanoglState.depthmask = flag;
FlushOnStateChange( );
+ }
glEsImpl->glDepthMask( flag );
}
void glBindTexture( GLenum target, GLuint texture )
{
+ if( skipnanogl )
+ {
+ glEsImpl->glBindTexture( target,texture );
+ return;
+ }
if ( activetmuState->boundtexture.value == texture )
{
return;
void glActiveTexture( GLenum texture )
{
+ if( skipnanogl )
+ {
+ glEsImpl->glActiveTexture( texture );
+ return;
+ }
if ( activetmu == texture )
{
return;
void glClientActiveTexture( GLenum texture )
{
+ if( skipnanogl )
+ {
+ glEsImpl->glClientActiveTexture( texture );
+ return;
+ }
clientactivetmu = texture;
}
void glDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices )
{
+ if( skipnanogl )
+ {
+ glEsImpl->glDrawElements( mode, count, type, indices );
+ return;
+ }
// ensure that all primitives specified between glBegin/glEnd pairs
// are rendered first, and that we have correct tmu in use..
FlushOnStateChange( );
@@ -1668,8 +1761,17 @@ void glDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *indi
glEsImpl->glDrawElements( mode, count, type, indices );
}
+bool vboarray;
+
void glEnableClientState( GLenum array )
{
+ if( skipnanogl )
+ {
+ glEsImpl->glEnableClientState( array );
+ if( array == GL_VERTEX_ARRAY )
+ vboarray = true;
+ return;
+ }
struct nanotmuState *clientstate = NULL;
if ( clientactivetmu == GL_TEXTURE0 )
{
}
void glDisableClientState( GLenum array )
{
+ if( skipnanogl )
+ {
+ glEsImpl->glDisableClientState( array );
+ if( array == GL_VERTEX_ARRAY )
+ vboarray = false;
+ return;
+ }
struct nanotmuState *clientstate = NULL;
if ( clientactivetmu == GL_TEXTURE0 )
{
}
void glVertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
{
+
+ if( skipnanogl )
+ {
+ glEsImpl->glVertexPointer( size, type, stride, pointer );
+ return;
+ }
if ( tmuState0.vertex_array.size == size &&
tmuState0.vertex_array.stride == stride &&
tmuState0.vertex_array.type == type &&
@@ -1795,6 +1910,11 @@ void glVertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *poi
}
void glTexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
{
+ if( skipnanogl )
+ {
+ glEsImpl->glTexCoordPointer( size, type, stride, pointer );
+ return;
+ }
struct nanotmuState *clientstate = NULL;
if ( clientactivetmu == GL_TEXTURE0 )
{
void glTexEnvi( GLenum target, GLenum pname, GLint param )
{
+ if( skipnanogl )
+ {
+ glEsImpl->glTexEnvi( target, pname, param );
+ return;
+ }
if ( target == GL_TEXTURE_ENV )
{
if ( pname == GL_TEXTURE_ENV_MODE )
return glMultiTexCoord2fARB( a, b, c );
}
-void glMultiTexCoord2f( GLenum, GLfloat, GLfloat )
+void glMultiTexCoord2f( GLenum a, GLfloat b, GLfloat c )
{
+ glMultiTexCoord2fARB(a,b,c);
}
#endif
void glDrawArrays( GLenum mode, GLint first, GLsizei count )
{
+ if( skipnanogl )
+ {
+ glEsImpl->glDrawArrays( mode, first, count );
+ return;
+ }
// ensure that all primitives specified between glBegin/glEnd pairs
// are rendered first, and that we have correct tmu in use..
if ( mode == GL_QUADS )
@@ -2158,3 +2289,42 @@ void glRenderbufferStorage( GLenum target, GLenum internalformat, GLsizei width,
FlushOnStateChange( );
glEsImpl->glRenderbufferStorage( target, internalformat, width, height );
}
+
+void glBindBufferARB( GLuint target, GLuint index )
+{
+ static int sindex;
+
+ if( index && !sindex && !skipnanogl )
+ FlushOnStateChange();
+ glEsImpl->glDisableClientState( GL_COLOR_ARRAY );
+ glEsImpl->glColor4f( currentVertexAttrib.red/255.0f, currentVertexAttrib.green/255.0f,
+ currentVertexAttrib.blue/255.0f, currentVertexAttrib.alpha/255.0f );
+
+ skipnanogl = (!!index) || vboarray;
+ glEsImpl->glBindBuffer( target, index );
+ if( sindex && !index )
+ {
+ arraysValid = GL_FALSE;
+ }
+ sindex = index;
+}
+
+void glGenBuffersARB( GLuint count, GLuint *indexes )
+{
+ glEsImpl->glGenBuffers( count, indexes );
+}
+
+void glDeleteBuffersARB( GLuint count, GLuint *indexes )
+{
+ glEsImpl->glDeleteBuffers( count, indexes );
+}
+
+void glBufferDataARB( GLuint target, GLuint size, void *buffer, GLuint type )
+{
+ glEsImpl->glBufferData( target, size, buffer, type );
+}
+
+void glBufferSubDataARB( GLuint target, GLsizei offset, GLsizei size, void *buffer )
+{
+ glEsImpl->glBufferSubData( target, offset, size, buffer );
+}
\ No newline at end of file
diff --git a/nanogl.cpp b/nanogl.cpp
index 9af6d1d36a6fdc9f898f4c19809a6052b881024e..b0a525f5819d84f4526bf12afc0207024ea7809b 100644 (file)
--- a/nanogl.cpp
+++ b/nanogl.cpp
*( (void **)&glEsImpl->glDeleteRenderbuffers ) = (void *)glEsImpl->eglGetProcAddress( "glDeleteRenderbuffersOES" );
*( (void **)&glEsImpl->glDeleteFramebuffers ) = (void *)glEsImpl->eglGetProcAddress( "glDeleteFramebuffersOES" );
*( (void **)&glEsImpl->glFramebufferRenderbuffer ) = (void *)glEsImpl->eglGetProcAddress( "glFramebufferRenderbufferOES" );
+ *( (void **)&glEsImpl->glTexGeniOES ) = (void *)glEsImpl->eglGetProcAddress( "glTexGeniOES" );
+ *( (void **)&glEsImpl->glTexGenfvOES ) = (void *)glEsImpl->eglGetProcAddress( "glTexGenfv" );
+
+
#endif
// Init nanoGL