print_gl_get.h 865 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef PRINT_gl_get_H
  2. #define PRINT_gl_get_H
  3. #if __APPLE__
  4. # include <OpenGL/gl.h>
  5. #else
  6. # include <GL/gl.h>
  7. #endif
  8. namespace igl
  9. {
  10. // Prints the value of pname found by issuing glGet*(pname,*)
  11. // Inputs:
  12. // pname enum key to gl parameter
  13. inline void print_gl_get(GLenum pname);
  14. }
  15. // implementation
  16. #include <cstdio>
  17. inline void igl::print_gl_get(GLenum pname)
  18. {
  19. double dM[16];
  20. int rows = 4;
  21. int cols = 4;
  22. switch(pname)
  23. {
  24. case GL_MODELVIEW_MATRIX:
  25. case GL_PROJECTION_MATRIX:
  26. {
  27. rows = 4;
  28. cols = 4;
  29. glGetDoublev(pname,dM);
  30. for(int i = 0;i<rows;i++)
  31. {
  32. for(int j = 0;j<cols;j++)
  33. {
  34. printf("%lg ",dM[j*rows+i]);
  35. }
  36. printf("\n");
  37. }
  38. break;
  39. }
  40. default:
  41. fprintf(stderr,"ERROR in print_gl_get(), gl enum not recognized.\n");
  42. }
  43. }
  44. #endif