Basically, I am being forced to use OpenGL to do my drawing (by a 3rd party application that I cannot avoid).
I need to be able to draw in image from a png file. I need to be able to rotate that image. Both of these, I have working. What I need help with it figuring out how to clip the image. Basically, the image is large and I want to have a small viewport with the image moving/rotating inside it. The viewport would stay fixed (a small square) and the image I am drawing would pan/rotate behind the viewport square and be clipped to fit within the viewport square (I hope that made sense)
I am currently loading the file and drawing the image as a texture as follows:
(I modified example code to get to here, so please let me know if I am doing this part incorrectly as well)
m_imageList = gl.glGenLists(1);
gl.glNewList(m_imageList, gl.GL_COMPILE);
gl.glPushMatrix();
gl.glTranslatef(-0.5, -0.5, 0.0);
gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_MODULATE);
gl.glEnable(gl.GL_TEXTURE_2D);
gl.glBindTexture(gl.GL_TEXTURE_2D, textureID);
gl.glBegin(gl.GL_QUADS);
gl.glTexCoord2f(0.0, 0.0);
gl.glVertex2f(0.0, 0.0);
gl.glTexCoord2f(1.0, 0.0);
gl.glVertex2f(1.0, 0.0);
gl.glTexCoord2f(1.0, 1.0);
gl.glVertex2f(1.0, 1.0);
gl.glTexCoord2f(0.0, 1.0);
gl.glVertex2f(0.0, 1.0);
gl.glEnd();
gl.glPopMatrix();
gl.glEndList();
//later, the drawing....
gl.glPushMatrix();
gl.glLoadIdentity();
gl.glPushMatrix();
gl.glTranslate(x, y, 0.0);
gl.glScalef(256.0, 32.0, 0.0); //actual image size
gl.glColor4f(1.0, 1.0, 1.0, 0.5); //50% transparent
gl.glCallList(m_imageList);
gl.glPopMatrix();