Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef __APPLE__
- #include <GLUT/glut.h>
- #else
- #include <GL/glut.h>
- #endif
- #include <stdio.h>
- #include <stdlib.h>
- int angle = 0;
- int rotating = 0;
- GLfloat rotate_y = 0;
- void display(void)
- {
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
- glLoadIdentity();
- if(rotating == 1){
- rotate_y += 0.2;
- }
- glRotatef(rotate_y, 0.0, 0.0, 1.0 );
- glTranslatef(-0.5,-0.5,0);
- glScalef(0.5f,0.5f,0.5f);
- glLineWidth(4.0);
- glBegin(GL_LINE_STRIP);
- glColor3f(1.0f,0.0f,1.0f);
- glVertex3i(0,0,0);
- glVertex3i(0,2,0);
- glVertex3i(1,1,0);
- glVertex3i(2,2,0);
- glVertex3i(2,0,0);
- glEnd();
- glLoadIdentity();
- glutSwapBuffers();
- }
- //gwa mouse handler while loop
- //global var bool y3ne b rotat wla la2 w n3'yro gwa mouse handler 1 right 0 left
- void mouse(int button, int state, int x, int y) {
- switch (button) {
- case GLUT_LEFT_BUTTON:
- rotating = 1;
- break;
- case GLUT_RIGHT_BUTTON:
- if(state == GLUT_DOWN)
- rotating = 0;
- break;
- }
- }
- void keyboard(unsigned char key, int x,int y)
- {}
- static void idle(void)
- {
- glutPostRedisplay();
- }
- int main(int argc, char *argv[])
- {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
- glutInitWindowSize(900, 900);
- glutInitWindowPosition (100, 100);
- glutCreateWindow("Rotating Letter");
- glutDisplayFunc(display);
- glutMouseFunc(mouse);
- glutKeyboardFunc(keyboard);
- glutIdleFunc(idle);
- glutMainLoop();
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment