How to configure background image to be at the bottom OpenGL Android
        Posted  
        
            by 
                Maxim Shoustin
            
        on Game Development
        
        See other posts from Game Development
        
            or by Maxim Shoustin
        
        
        
        Published on 2014-08-20T15:29:29Z
        Indexed on 
            2014/08/20
            16:37 UTC
        
        
        Read the original article
        Hit count: 277
        
I have class that draws white line:
public class Line {
    //private FloatBuffer vertexBuffer;
    private FloatBuffer frameVertices;
    ByteBuffer diagIndices;
    float[] vertices = {
            -0.5f, -0.5f, 0.0f,
            -0.5f, 0.5f,  0.0f
    };
    public Line(GL10 gl) {
        // a float has 4 bytes so we allocate for each coordinate 4 bytes
        ByteBuffer vertexByteBuffer = ByteBuffer.allocateDirect(vertices.length * 4);
        vertexByteBuffer.order(ByteOrder.nativeOrder());
        // allocates the memory from the byte buffer
        frameVertices = vertexByteBuffer.asFloatBuffer();
        // fill the vertexBuffer with the vertices
        frameVertices.put(vertices);
        // set the cursor position to the beginning of the buffer
        frameVertices.position(0);
    }
    /** The draw method for the triangle with the GL context */
    public void draw(GL10 gl) {
        gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
        gl.glVertexPointer(2, GL10.GL_FLOAT, 0, frameVertices);
        gl.glColor4f(1.0f, 1.0f, 1.0f, 1f);
        gl.glDrawArrays(GL10.GL_LINE_LOOP , 0, vertices.length / 3);
        gl.glLineWidth(5.0f);
        gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    }
}
It works fine. The problem is: When I add BG image, I don't see the line
glView = new GLSurfaceView(this);           // Allocate a GLSurfaceView
glView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
glView.setRenderer(new mainRenderer(this)); // Use a custom renderer
glView.setBackgroundResource(R.drawable.bg_day); // <- BG
glView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
glView.getHolder().setFormat(PixelFormat.TRANSLUCENT);   
How to get rid of that?
© Game Development or respective owner