I am trying to take a camera preview image and display it in a trapezoid. The image displays fine in a rectangle but when I change one or more corners to make the shape a trapezoid the camera preview image now “bends” where the triangles meet.
Here are the relevant code excerpts.
final static float leftPanCamObjCoords[] = new float[] {
-2.0f, 6.0f, -5.0f, // top-right
-2.0f, 0.0f, -5.0f, // bottom-right
-8.0f, 6.0f, -5.0f, // top-left
-8.0f, -4.0f, -5.0f // bottom-left
};
leftPanCamBuff = makeFloatBuffer(leftPanCamObjCoords);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, leftPanCamBuff);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, texBuff);
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
gl.glEnable(GL10.GL_TEXTURE_2D);
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
GLU.gluLookAt(gl, 0, 0, 5.5f, 0, 0, 0, 0, 1, 0);
gl.glNormal3f(0, 0, 1);
gl.glGenTextures(1, cameraTexture, 0);
gl.glBindTexture(GL10.GL_TEXTURE_2D, cameraTexture[0]);
gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, GL10.GL_LUMINANCE,
frameWidth, frameHeight, 0,
GL10.GL_LUMINANCE, GL10.GL_UNSIGNED_BYTE,
ByteBuffer.wrap(dispBuffer));
gl.glTexParameterf(GL10.GL_TEXTURE_2D,
GL10.GL_TEXTURE_MIN_FILTER,
GL10.GL_LINEAR);
gl.glTexParameterf(GL10.GL_TEXTURE_2D,
GL10.GL_TEXTURE_MAG_FILTER,
GL10.GL_LINEAR);
gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT,
GL10.GL_NICEST);
gl.glDrawElements(GL10.GL_TRIANGLES, 1,
GL10.GL_UNSIGNED_BYTE, rearPanCamBuff);
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
Any hints would be appreciated.
-Dale