| | |
Opengl problem transformation/rotating.
![]() |
I am trying to rotate the object by a input of key.
I dont know why the object is not rotating.
I used glRotatef(x,0,0,1); //where x is declared as float :
here is my code :
I dont know why the object is not rotating.
I used glRotatef(x,0,0,1); //where x is declared as float :
here is my code :
#include<GL/glut.h>
GLfloat x = 10;
void initGL()
{
glEnable(GL_DEPTH);
glDepthFunc(GL_LEQUAL);
glClearDepth(1.0f);
}
void reshape(int width,int height)
{
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0,(float)width/(float)height,5.0,250.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0,0,-10);
glRotatef(x,0,1,0);
glutSolidCube(1.0);
glutSwapBuffers();
glFlush();
glutPostRedisplay();
}
void keyboard(unsigned char key, int x, int y)
{
switch(key)
{
case 27: exit(0);break;
case' ': x++;
}
}
void specialFunc( int key, int x, int y)
{
switch(key)
{
case GLUT_KEY_UP : x+=1;break;
case GLUT_KEY_DOWN:
case GLUT_KEY_LEFT:
case GLUT_KEY_RIGHT:;
}
}
int main(int argc, char ** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA|GLUT_DEPTH);
glutInitWindowSize(500,500);
glutInitWindowPosition(300,200);
glutCreateWindow("OPENGL");
initGL();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutSpecialFunc(specialFunc);
glutMainLoop();
return 0;
}![]() |
Other Threads in the Game Development Forum
- Previous Thread: 3D Sound, calculating pan
- Next Thread: bar graph problem in openGL
| Thread Tools | Search this Thread |
3d advertising ai algorithm ban c++ cambridge camera censorship china competition console development engine fov fpx game gamer games gaming gauntanamo government idaho in-gameadvertisement intellectualproperty laracroft live manhunt math mathematics matrix mercenaries microsoft mmorpg msn naked news nintendo obama palin physics pirate playstation politics projection ps3 rpg search software sony stephenhawking stocks studio technology terrorism tombraider uk videogame web wii world-of-warcraft xbox xbox360






