GLContext.hh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef GL_CONTEXT_HH
  2. #define GL_CONTEXT_HH
  3. #include "GLUtil.hh"
  4. #include "gl_mat.hh"
  5. #include <memory>
  6. namespace openmsx { class GLScaler; }
  7. namespace gl {
  8. struct Context
  9. {
  10. /** Initialize global openGL state
  11. */
  12. Context(int width, int height);
  13. ~Context();
  14. // Simple texture program. It expects
  15. // uniforms:
  16. // unifTexColor: values from texture map are multiplied by this 4D color
  17. // unifTexMvp: Model-View-Projection-matrix
  18. // attributes:
  19. // 0: 4D vertex positions, get multiplied by Model-View-Projection-matrix
  20. // 1: 2D texture coordinates
  21. // textures:
  22. // the to be applied texture must be bound to the 1st texture unit
  23. ShaderProgram progTex;
  24. GLuint unifTexColor;
  25. GLuint unifTexMvp;
  26. // Simple color-fill program. It expects
  27. // uniforms:
  28. // unifFillMvp: Model-View-Projection-matrix
  29. // attributes:
  30. // 0: 4D vertex positions, get multiplied by Model-View-Projection-matrix
  31. // 1: 4D vertex color
  32. ShaderProgram progFill;
  33. GLuint unifFillMvp;
  34. // Model-View-Projection-matrix that maps integer vertex positions to host
  35. // display pixel positions. (0,0) is the top-left pixel, (width-1,height-1) is
  36. // the bottom-right pixel.
  37. mat4 pixelMvp;
  38. // Fallback scaler
  39. openmsx::GLScaler& getFallbackScaler();
  40. private:
  41. std::unique_ptr<openmsx::GLScaler> fallbackScaler;
  42. };
  43. extern std::unique_ptr<Context> context;
  44. } // namespace gl
  45. #endif