1
votes

I'm creating an app that only runs in landscape mode. I'm trying to create a background using a textured quad although I'm not going to worry about texturing yet. I've been trying to simply draw a quad that fills the screen from drawOverlay(GL10 gl) with GL_DEPTH_TEST disabled but whenever I do that the quad does not completely fill the screen and I can see bars of the glClearColor on the bottom and top of the screen.

Unable to draw it using the modelview matrix I was using for all the other objects, I tried to draw it using gluOrtho2D and glOrthof but neither of them worked. I don't really understand how the near and far clipping plane work with orthographic drawing. Whenever I tried to draw it using glOrtho2D or glOrthof, the quad wasn't drawn at all(although the rest of the scene was still rendered).

Here is my attempt at drawing using an orthographic matrix

private void drawOverlay(GL10 gl) {
    gl.glDisable(GL10.GL_DEPTH_TEST);
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glPushMatrix();
    gl.glLoadIdentity();
    GLU.gluOrtho2D(gl, 0f, 1f, 1f, 0f);
    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glLoadIdentity();
    background.draw(gl, 1.0f, 1.0f, 1.0f, 1.0f);
    gl.glEnable(GL10.GL_DEPTH_TEST);
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glPopMatrix();
    gl.glMatrixMode(GL10.GL_MODELVIEW);
}

I call that function from the beginning of onDrawFrame - before anything else is drawn:

public void onDrawFrame(GL10 gl) {
    drawOverlay(gl);
    gl.glLoadIdentity
    //...
}

Here is how "background" is created:

background = new ShapePostcard(1f, 1f);

I'm fairly certain I'm not going to be able to get the quad to cover the screen using the normal modelview matrix, but basically all I was doing was drawing "background" in onDrawFrame before everything else with depth testing disabled.

Thanks for any support!

2

2 Answers

0
votes

The easiest way to draw a quad that fills the screen is to set both the projection and model to an identity matrix, and then draw a mesh with coordinates [-1,-1] to [1,1]. Was it this what you were drawing when you saw the borders? I mean,

 (x, y, widht, height) = (-1,-1, 2, 2)
0
votes