I want to set the background image for 320 * 70 EAGLView (using openGL). I set
glOrthof(0, backingWidth, 0, backingHeight, -1.0f, 1.0f);
where backingWidth = 320; backingHeight = 70;
Sorry if my issue is obvious or some of the points are incorrect. The question is how to make the coordinates in a vertices array to set background properly. I'm new to openGL, but as far as I know these coordinates should be having degrees of 2. How should I set these coordinates to 320 and 70. I've investigated Apple's sample code of GLImageProcessing and they have 512 * 512 vertex array that covered 320 * 480 of the view. How can I relate 512 * 512 vertex array of ImageCoordinate on the screen to real coordinates?
This is my code, and now part of image is now shown:
// Clear the view
glClear(GL_COLOR_BUFFER_BIT);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glColor4f(1., 1., 1., 1.);
glPushMatrix();
glEnable(GL_TEXTURE_2D);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
{
// Draw our background oscilloscope screen
const GLfloat vertices[] = {
0., 0.,
512., 0.,
0., 256.,
512., 256.,
};
const GLshort texCoords[] = {
0, 0,
1, 0,
0, 1,
1, 1,
};
glBindTexture(GL_TEXTURE_2D, bgTexture);
glVertexPointer(2, GL_FLOAT, 0, vertices);
glTexCoordPointer(2, GL_SHORT, 0, texCoords);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}