Drawing code:
Code: Select all
- (void)drawView:(GLView*)view;
{
glClearColor(0.7, 0.7, 0.7, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
CGPoint point = CGPointMake(100.0, 100.0);
[texture drawAtPoint:point rot: rotat];
rotat++;
}
Code: Select all
- (void) drawAtPoint:(CGPoint)point rot:(GLfloat)rota
{
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
GLfloat coordinates[] = { 0, _maxT,
_maxS, _maxT,
0, 0,
_maxS, 0 };
GLfloat width = (GLfloat)_width * _maxS,
height = (GLfloat)_height * _maxT;
GLfloat vertices[] = { -width / 2 + point.x, -height / 2 + point.y, -1.0,
width / 2 + point.x, -height / 2 + point.y, -1.0,
-width / 2 + point.x, height / 2 + point.y, -1.0,
width / 2 + point.x, height / 2 + point.y, -1.0 };
glLoadIdentity();
glRotatef(rota, 0.0, 0.0, 1.0);
glBindTexture(GL_TEXTURE_2D, _name);
glVertexPointer(3, GL_FLOAT, 0, vertices);
glTexCoordPointer(2, GL_FLOAT, 0, coordinates);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
Any help?
EDIT: All the other tutorials involving rotation that Ive seen, the object is at 0.0,0.0,0.0 maybe glRotatef rotates the entire 3D world? Is there a way to just rotate one object?