Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Window.cpp 797B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*!
  2. * \file src/Window.cpp
  3. * \brief windowing implementation
  4. *
  5. * \author xythobuz
  6. */
  7. #include <assert.h>
  8. #ifdef __APPLE__
  9. #include <OpenGL/gl.h>
  10. #include <OpenGL/glu.h>
  11. #else
  12. #include <GL/gl.h>
  13. #include <GL/glu.h>
  14. #endif
  15. #include "math/math.h"
  16. #include "Window.h"
  17. Window::~Window() {
  18. }
  19. void Window::resizeGL(unsigned int w, unsigned int h) {
  20. float fovY = 45.0f;
  21. float clipNear = 4.0f;
  22. float clipFar = 4000.0f;
  23. assert(w > 0);
  24. assert(h > 0);
  25. glViewport(0, 0, w, h);
  26. glMatrixMode(GL_PROJECTION);
  27. glLoadIdentity();
  28. // Adjust clipping
  29. GLfloat fH = tanf(fovY * OR_PI / 360.0f) * clipNear;
  30. GLfloat fW = fH * ((GLfloat)w) / ((GLfloat)h);
  31. glFrustum(-fW, fW, -fH, fH, clipNear, clipFar);
  32. glMatrixMode(GL_MODELVIEW);
  33. glLoadIdentity();
  34. }