views:

357

answers:

1

I have a very simple GLRenderer subclass that draws a bunch of polygons on the screen. On my Nexus One with 2.1 installed, I see exactly what I expect. On my G1 with 1.6 installed, I only get the glClearColor displayed. I can alter the color, and see that my onDrawFrame function is at least partially functioning.

I can't fathom a good explanation, so I'm pasting my onDrawFrame code:

public void onDrawFrame(GL10 gl) {
    gl.glClearColor(1.0f, 1.00f, 1.0f, 1.0f);
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

    gl.glLoadIdentity();
    gl.glScalef(zoomLevel, zoomLevel, 1.0f);
    gl.glTranslatef(offsetX, offsetY, -1);
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, boothVerticies);
    int i = 0;
    for (Polygon b : allPolygons) {
        if (b.indicies != null) {
            gl.glColor4f(0.6f, 0.6f, 0.6f, 1.0f);
            gl.glDrawElements(GL10.GL_TRIANGLE_FAN, b.numberOfVerticies, GL10.GL_UNSIGNED_SHORT, b.indicies);
            gl.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
            gl.glDrawElements(GL10.GL_LINE_LOOP, b.numberOfVerticies, GL10.GL_UNSIGNED_SHORT, b.indicies);
            if (i++ > 20) break;
        }
    }
}

My Polygon structure has a ShortBuffer called indicies, and numberOfVerticies tracks the number of points in the polygon.

Does anyone have any ideas why this might work well on my Nexus One, but not on the G1?

+1  A: 

The problem was caused in that by default, GL_VERTEX_ARRAY is enabled on the Nexus One (or 2.1/2.2), but it is disabled by default on the G1. To fix, I simply added this call:

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
NilObject