Hi cNoob, thank you for your reply :)
I've modified my rendering function to include the call to glTranslatef(), but this hasn't yielded the results i was expecting :(
It seems that my texture is still being rotated incorrectly around the top left origin of the rect i am passing to my rendering function. I've pasted the function below for reference:
//draw texture in rect with rotation- (void)drawInRect:(CGRect)rect withOrigin:(CGPoint)origin withRotation:(GLfloat)rotation{ //calculate texture coordinates GLfloat coordinates[] = {0.0, textureMaxT, textureMaxS, textureMaxT, 0.0, 0.0, textureMaxS, 0.0}; //calculate texture vertices GLfloat vertices[] = {rect.origin.x, rect.origin.y, 0.0, rect.origin.x + rect.size.width, rect.origin.y, 0.0, rect.origin.x, rect.origin.y + rect.size.height, 0.0, rect.origin.x + rect.size.width, rect.origin.y + rect.size.height, 0.0,}; //push the matrix onto the stack glPushMatrix(); //load identity glLoadIdentity(); //translate the verticies glTranslatef(rect.origin.x - origin.x, rect.origin.y - origin.y, 0.0); //rotate texture around the z axis glRotatef(rotation, 0.0, 0.0, 1.0); //bind the texture to the target glBindTexture(GL_TEXTURE_2D, textureName); //set the texture verticies glVertexPointer(3, GL_FLOAT, 0, vertices); //set the texture coordinates glTexCoordPointer(2, GL_FLOAT, 0, coordinates); //render primitive from texture data glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); //pop the matrix off of the stack glPopMatrix();}
My projection is set to use the coordinate system (0.0, 0.0, 480.0, 320.0) where (0.0, 0.0) is the top left of the screen and (480.0, 320.0) is the bottom right.
When calling the function, i am passing a rect which matches the screen dimensions (as above), a 2D point and a rotation value as such:
[MyImageManager drawImage:myImage inRect:CGRectMake(0.0, 0.0, 480.0, 320.0) withOrigin:CGPointMake(240.0, 160.0) withRotation:10.0];
What i currently see on screen in only 1/4 of my rect/texture with the other 3/4's rendered off the top left hand corners of the screen (if that makes sense?) but it also seems that the rotation is still taking place around the top left origin (0.0, 0.0) of the rect itself, rather than the coords i passed through the origin variable.
Perhaps i should be modifying my vertices array to include the origin values? I'm currently drawing blanks on this one, perhaps you can advise?
if i can figure out the syntax for this forum, i will try to post a screen shot to further illustrate my problem.
Thanks again for reading and thanks for your previous reply.