Advertisement
chrisasl

setup_opengl

Feb 1st, 2013
691
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.30 KB | None | 0 0
  1. void Setup()
  2. {
  3.     loader(tree);
  4.  
  5.     //Parameter handling
  6.     glShadeModel (GL_SMOOTH);
  7.    
  8.     glEnable(GL_DEPTH_TEST);
  9.     glDepthFunc(GL_LEQUAL);  //renders a fragment if its z value is less or equal of the stored value
  10.     glClearDepth(1);
  11.    
  12.     // polygon rendering mode
  13.     glEnable(GL_COLOR_MATERIAL);
  14.     glColorMaterial( GL_FRONT, GL_AMBIENT_AND_DIFFUSE );
  15.  
  16.     //Set up light source
  17.     GLfloat light_position[] = { 0.0, 30.0, 50.0, 1.0 };
  18.     glLightfv( GL_LIGHT0, GL_POSITION, light_position);
  19.  
  20.     float ambient = 0.45;
  21.     float diffusion = 0.1;
  22.     float specular = 0.55;
  23.     GLfloat ambientLight[] = { ambient, ambient, ambient, 1.0 };
  24.     GLfloat diffuseLight[] = { diffusion, diffusion, diffusion, 1.0 };
  25.     GLfloat specularLight[] = { specular, specular, specular, 1.0 };
  26.  
  27.        
  28.     glLightfv( GL_LIGHT0, GL_AMBIENT, ambientLight );
  29.     glLightfv( GL_LIGHT0, GL_DIFFUSE, diffuseLight );
  30.     glLightfv( GL_LIGHT0, GL_SPECULAR, specularLight);
  31.    
  32.  
  33.     glEnable(GL_LIGHTING);
  34.     glEnable(GL_LIGHT0);
  35.  
  36.     glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
  37.    
  38.     glEnable(GL_CULL_FACE);
  39.     //glEnable(GL_CULL_FACE | GL_CULL_FACE_MODE);
  40.     glFrontFace(GL_CW);
  41.  
  42.     glEnable(GL_BLEND);
  43.                  // incoming //  // stored //
  44.         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  45.  
  46.  
  47.     // Black background
  48.     glClearColor(0.0f,0.0f,0.0f,1.0f);
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement