GL -> GLES Blank Screen


Rockthesmurf

Advanced Member
Joined
Jul 18, 2003
Messages
1,115
Age
40
Location
Manchester, UK
Website
Visit site
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?

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;
}

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:
You should probably skip glEnableClientState() for GL_TEXTURE_COORD_ARRAY and GL_COLOR_ARRAY if the glBegin/End block didn't include a call to glTexCoord* or glColor*


bool useTex = false;
void glTexCoord2f(GLfloat s, GLfloat t) {
useTex = true;
// etc
}

void glEnd() {
if (useTex) glEnableClientState(GL_VERTEX_ARRAY);
// etc
}

Try dropping a glClearColor at the end of glEnd to see if you can get the screen to change to a full color.

Also, this exact use case is covered perfectly by libGL. If you got past the X errors by swapping to EGL, libGL can still fill in the gaps and give you a working OpenGL wrapper. LIBGL_FB=1 fixes some X issues as well.
 
Last edited by a moderator:
I suggest find a nice minimal example that does work, and modify yours to be similar to it chunk by chunk (like binary search) until it works.

Then modify back chunk by chunk until you find the bug!

Can you post a full, small test program in a single file which shows the "blank screen" bug?

The (maybe too obvious) reasons why the screen might be blank: did you swap the buffers?  wrong transforms?  no color set?  texturing not enabled?
 
Last edited by a moderator:
Thanks. I did try libGL initially, but had some issues, but I may try going back to it again. I guess my original plan is still a good one, find out whether my EGL context is working right, once I have a triangle on screen from my own code, I imagine to at least see something from the game. Watch this space..
 
Back
Top