Rockthesmurf
Advanced Member
Anyone have any debugging tips when getting a black screen when trying to port from GL code to GLES? I typically just prod around with various states, matrices, vertex streams until something comes on screen. But I wondered if these was anything more useful? In this particular case there is quite a thin wrapper that I've put in, maybe someone can spot the errors in it?
It isn't intended to be a complete wrapper of any description, just wrapping up the calls which would otherwise cause a linking error. Running against the mesa GL I had the game appearing on screen, but since I attempted some GLES conversion I am getting a blank screen. At the moment, the next thing on my TODO list is just to render a triangle in the middle of the screen in glEnd to ensure my EGL set up at least is giving me proper buffers which are being swapped etc.
typedef struct
{
float x, y, z;
float s, t;
unsigned char r, g, b, a;
} GLVertex;
static GLVertex g_GLVertices[ 16 * 1024 ];
static int g_GLVertexIx = 0;
GLenum g_GLMode;
void glBegin(GLenum mode)
{
// This asset passes, so it appears we are using GLES compatible modes.
assert( mode == GL_POINTS || mode == GL_LINES || mode == GL_LINE_LOOP || mode == GL_LINE_STRIP || mode == GL_TRIANGLES || mode == GL_TRIANGLE_STRIP || mode == GL_TRIANGLE_FAN );
g_GLMode = mode;
}
void glTexCoord2f(GLfloat s, GLfloat t)
{
g_GLVertices[ g_GLVertexIx ].s = s;
g_GLVertices[ g_GLVertexIx ].t = t;
}
void glColor4ubv( const GLubyte * rgba )
{
g_GLVertices[ g_GLVertexIx ].r = rgba[ 0 ];
g_GLVertices[ g_GLVertexIx ].g = rgba[ 1 ];
g_GLVertices[ g_GLVertexIx ].b = rgba[ 2 ];
g_GLVertices[ g_GLVertexIx ].a = rgba[ 3 ];
}
void glVertex2f( GLfloat x, GLfloat y )
{
glVertex3f( x, y, 0.f );
}
void glVertex3f( GLfloat x, GLfloat y, GLfloat z )
{
g_GLVertices[ g_GLVertexIx ].x = x;
g_GLVertices[ g_GLVertexIx ].y = y;
g_GLVertices[ g_GLVertexIx ].z = z;
g_GLVertexIx++;
}
void glEnd( )
{
glColorPointer( 4, GL_UNSIGNED_BYTE, sizeof( GLVertex ), &g_GLVertices[ 0 ].r );
glTexCoordPointer( 2, GL_FLOAT, sizeof( GLVertex ), &g_GLVertices[ 0 ].s );
glVertexPointer( 3, GL_FLOAT, sizeof( GLVertex ), &g_GLVertices[ 0 ].x );
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glDrawArrays( g_GLMode, 0, g_GLVertexIx );
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
g_GLVertexIx = 0;
}
{
float x, y, z;
float s, t;
unsigned char r, g, b, a;
} GLVertex;
static GLVertex g_GLVertices[ 16 * 1024 ];
static int g_GLVertexIx = 0;
GLenum g_GLMode;
void glBegin(GLenum mode)
{
// This asset passes, so it appears we are using GLES compatible modes.
assert( mode == GL_POINTS || mode == GL_LINES || mode == GL_LINE_LOOP || mode == GL_LINE_STRIP || mode == GL_TRIANGLES || mode == GL_TRIANGLE_STRIP || mode == GL_TRIANGLE_FAN );
g_GLMode = mode;
}
void glTexCoord2f(GLfloat s, GLfloat t)
{
g_GLVertices[ g_GLVertexIx ].s = s;
g_GLVertices[ g_GLVertexIx ].t = t;
}
void glColor4ubv( const GLubyte * rgba )
{
g_GLVertices[ g_GLVertexIx ].r = rgba[ 0 ];
g_GLVertices[ g_GLVertexIx ].g = rgba[ 1 ];
g_GLVertices[ g_GLVertexIx ].b = rgba[ 2 ];
g_GLVertices[ g_GLVertexIx ].a = rgba[ 3 ];
}
void glVertex2f( GLfloat x, GLfloat y )
{
glVertex3f( x, y, 0.f );
}
void glVertex3f( GLfloat x, GLfloat y, GLfloat z )
{
g_GLVertices[ g_GLVertexIx ].x = x;
g_GLVertices[ g_GLVertexIx ].y = y;
g_GLVertices[ g_GLVertexIx ].z = z;
g_GLVertexIx++;
}
void glEnd( )
{
glColorPointer( 4, GL_UNSIGNED_BYTE, sizeof( GLVertex ), &g_GLVertices[ 0 ].r );
glTexCoordPointer( 2, GL_FLOAT, sizeof( GLVertex ), &g_GLVertices[ 0 ].s );
glVertexPointer( 3, GL_FLOAT, sizeof( GLVertex ), &g_GLVertices[ 0 ].x );
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glDrawArrays( g_GLMode, 0, g_GLVertexIx );
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
g_GLVertexIx = 0;
}
It isn't intended to be a complete wrapper of any description, just wrapping up the calls which would otherwise cause a linking error. Running against the mesa GL I had the game appearing on screen, but since I attempted some GLES conversion I am getting a blank screen. At the moment, the next thing on my TODO list is just to render a triangle in the middle of the screen in glEnd to ensure my EGL set up at least is giving me proper buffers which are being swapped etc.
Last edited by a moderator: