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.

openglrenderdevice.cpp 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "openglrenderdevice.h"
  2. #include "GL/gl.h"
  3. #include "GL/glu.h"
  4. OpenGLRenderDevice::OpenGLRenderDevice(QObject *parent) :
  5. AbstractRenderDevice(parent)
  6. {
  7. }
  8. void OpenGLRenderDevice::initialize(int fov, int width, int height)
  9. {
  10. glClearColor((GLfloat)_clearColor.red() / 255.0, (GLfloat)_clearColor.green() / 255.0,
  11. (GLfloat)_clearColor.blue() / 255.0, (GLfloat) _clearColor.alpha() / 255.0);
  12. glEnable(GL_DEPTH_TEST);
  13. glEnable(GL_CULL_FACE);
  14. glShadeModel(GL_SMOOTH);
  15. glEnable(GL_MULTISAMPLE);
  16. glMatrixMode(GL_PROJECTION);
  17. gluPerspective(fov, width/height, 0.1, 100.0);
  18. glMatrixMode(GL_MODELVIEW);
  19. }
  20. void OpenGLRenderDevice::resize(int width, int height)
  21. {
  22. int side = qMin(width, height);
  23. glViewport((width - side) / 2, (height - side) / 2, side, side);
  24. }
  25. void OpenGLRenderDevice::preDraw()
  26. {
  27. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  28. glLoadIdentity();
  29. gluLookAt(_lookEye.getX(), _lookEye.getY(), _lookEye.getZ(),
  30. _lookCenter.getX(), _lookCenter.getY(), _lookCenter.getZ(),
  31. _lookUp.getX(), _lookUp.getY(), _lookUp.getZ());
  32. }
  33. void OpenGLRenderDevice::postDraw()
  34. {
  35. }