Jump to content

View more

Image of the Day

Inventory ! Va falloir trouver une autre couleur pour le cadre D: #AzTroScreenshot #screenshotsaturday https://t.co/PvxhGL7cOH
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Need help [ OpenGL / glut ]

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
2 replies to this topic

#1 n0pr0bl3m   Members   

100
Like
0Likes
Like

Posted 04 January 2012 - 04:45 PM

I'm really wondering why my code doesn't work ...

#include <GL\gl.h>
#include <GL\glu.h>
#include <GL\glut.h>


void display(void) {
GLfloat angel = 0.0f;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glRotatef(angel,0.0f,1.0f,0.0f);

glBegin(GL_TRIANGLES);
glColor3f(1.0f,0.0f,0.0f);
glVertex3f(0.0f,0.5f,0.5f);
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(-0.5f,-0.5f,0.0f);
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(0.5f,-0.5f,0.0f);
glEnd();

angel = angel + 0.5f;
glutSwapBuffers();
}



int main(int argc, char* argv[]) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(800, 600);
glutCreateWindow("Test");


glutDisplayFunc(display);

glutMainLoop();
return 0;
}


I want to rotate the triangle I've made... It's just showing the triangle without any rotating :/

#2 RulerOfNothing   Members   

1425
Like
0Likes
Like

Posted 04 January 2012 - 05:36 PM

Because the angel variable is local to the display function, therefore you lose the information in it when the function returns. You need to somehow make that variable outlast the display function's scope, so you should probably put the static keyword before the declaration of the angel variable.

#3 n0pr0bl3m   Members   

100
Like
0Likes
Like

Posted 04 January 2012 - 05:42 PM

I LOVE U <3 !!




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.