I am having trouble understanding something.
I am working through several different tutorials. My favorite right now is NeHe. I am working through the 1-5 tutorials.
THe problem I’m experiencing is around the coordinates provided for the shapes. All the examples show vertices with 0.0, 1.0 values etc.
The only way I can get my polygons to show up is to use the actual coordinates of my view. My view is 320/480. So, I’m using 50, 75, etc. If I use translate, I can move the shape. I understand that. However, the sizes of my shapes are very small if I use the coordinates in the examples.
Anyone know what I’m doing wrong…
All the examples draw a polygon like this:
glBegin(GL_TRIANGLES);
glVertex3f( 0.0f, 1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glEnd();
Because, I’m learning on the iphone with OpenGL ES, I’ve translated this to:
const GLfloat kTriangleVertices []= {
0.0f, 0.0f, 0.0f,
spriteWidth / 2, spriteHeight, 0.0f,
spriteWidth, 0.0f, 0.0f
};
glEnableClientState (GL_VERTEX_ARRAY);
glVertexPointer (3, GL_FLOAT , 0, kTriangleVertices);
glDrawArrays (GL_TRIANGLES, 0, 3);
I had to init my view with code like this before I could get anything:
glViewport(0, 0, backingWidth, backingHeight);
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity();
glOrthof(0.0f, width, 0.0f, height, -1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity();