SHARE
TWEET

Untitled

a guest Jun 18th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. GLfloat light_ambient[] =
  2. { 0.2, 0.2, 0.2, 1.0 };
  3. GLfloat light_diffuse[] =
  4. { 0.8, 0.8, 0.8, 1.0 };
  5. GLfloat light_specular[] =
  6. { 1.0, 1.0, 1.0, 1.0 };
  7. GLfloat light_position[] =
  8. { 15.0, 11.0, 10.0, 1.0 };
  9.  
  10. glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
  11. glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
  12. glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
  13. glLightfv(GL_LIGHT0, GL_POSITION, light_position);
  14.  
  15. glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 0.4);
  16. glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.1);
  17. glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0.0);
  18.  
  19. glEnable(GL_LIGHT0);
  20. glEnable(GL_LIGHTING);
  21.      
  22. glMatrixMode(GL_PROJECTION);
  23. glLoadIdentity();
  24. gluPerspective(60, (double)g_window1Width / g_window1Height, 1.0, 300.0);
  25. glMatrixMode(GL_MODELVIEW);
  26. glLoadIdentity();
  27. glTranslated(0.0, 0.0, -player.camera.Dist);
  28. glRotated(player.camera.Angle-90, 1.0, 0.0, 0.0);
  29. glRotated(player.camera.Rot, 0.0, 0.0, 1.0);
  30. glTranslated(-player.camera.TgtX, player.camera.TgtY, -player.camera.TgtZ);
  31. glScaled(1.0, -1.0, 1.0);
  32. glEnable(GL_POLYGON_OFFSET_LINE);
  33. glPolygonOffset(g_offset[0], g_offset[1]);
  34.  
  35. glClearColor(0.0, 0.0, 0.0, 0.0);
  36. glClearStencil(0);
  37. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
  38.  
  39. glm::vec4 light_position;
  40. light_position.x = player.mouseMapPos.x - 1;
  41. light_position.y = player.mouseMapPos.y - 1;
  42. light_position.z = player.mouseMapPos.z + 0.5;
  43. light_position.w = 1.0f;
  44.  
  45. glLightfv(GL_LIGHT0, GL_POSITION, glm::value_ptr(light_position));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top