Advertisement
Guest User

Untitled

a guest
May 29th, 2012
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.45 KB | None | 0 0
  1. #include <GL/gl.h>
  2. #include <GL/glu.h>
  3. #include <GL/glut.h>
  4.  
  5. float delta=0;
  6.  
  7. void init(void) {
  8.   glClearColor (0.0, 0.0, 0.0, 0.0);
  9.   glShadeModel (GL_FLAT);
  10. }
  11.  
  12. void display(void) {
  13. /* Check this shit out, yo.
  14. http://gamedev.stackexchange.com/questions/12885/help-understanding-glulookat
  15. WhatisthisIdon'teven.*/
  16.   glClear (GL_COLOR_BUFFER_BIT);
  17.   glColor3f (1.0, 1.0, 1.0);
  18.   glLoadIdentity ();             /* clear the matrix */
  19.           /* viewing transformation  */
  20.   gluLookAt (0.0+delta, 0.0-delta, 6.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
  21.   glScalef (1.0, 2.0, 1.0);      /* modeling transformation */
  22.   glutWireCube (1.0);
  23.   glFlush ();
  24. }
  25. void reshape (int w, int h) {
  26.   glViewport (0, 0, (GLsizei) w, (GLsizei) h);
  27.   glMatrixMode (GL_PROJECTION);
  28.   glLoadIdentity ();
  29.   glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0);
  30.   glMatrixMode (GL_MODELVIEW);
  31. }
  32.  
  33. void mousefunc(int button,int state,int x,int y) {
  34.   switch(button) {
  35.     case GLUT_LEFT_BUTTON:
  36.       delta++;
  37.       glutPostRedisplay();
  38.       break;
  39.     case GLUT_RIGHT_BUTTON:
  40.       delta=0;
  41.       glutPostRedisplay();
  42.       break;
  43.   }
  44. }
  45.  
  46. int main(int argc, char** argv) {
  47.   glutInit(&argc, argv);
  48.   glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
  49.   glutInitWindowSize (500, 500);
  50.   glutInitWindowPosition (100, 100);
  51.   glutCreateWindow (argv[0]);
  52.   init ();
  53.   glutDisplayFunc(display);
  54.   glutReshapeFunc(reshape);
  55.   glutMouseFunc(mousefunc);
  56.   glutMainLoop();
  57.   return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement