Hi everyone!
I’m having difficulties in rotating an imported .obj when the key ‘C’ is pressed. I think my problem is with my KeyboardCallback function, but still, I can’t figure out how to do it properly.
First, I declare some static pointes to the .objs that I import:
static Mesh *book, *can, *table;
Then I render the objects:
void Render(void){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
if (book)
{
glPushMatrix();
glTranslatef(0, -2, -8);
book->Render();
glPopMatrix();
}
....
That all works fine. Then my KeyboardCallback:
void KeyboardCallback(unsigned char key, int x, int y){
switch (key)
{
case 27:
exit(0);
break;
case 'c':
case 'C':
RotateBook(book);
break;
And finally, my RotateBook function.
void RotateBook(Mesh *){
glPushMatrix();
glRotatef(45, 0, 1, 0);
book->Render();
glPopMatrix();
}
Can someone please indicate what I’m doing wrong?
Thanks in advance.