GLPrimitiveRenderer.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef _GL_PRIMITIVE_RENDERER_H
  2. #define _GL_PRIMITIVE_RENDERER_H
  3. //#include "OpenGLInclude.h"
  4. struct PrimVec2
  5. {
  6. PrimVec2(float x, float y)
  7. {
  8. p[0] = x;
  9. p[1] = y;
  10. }
  11. float p[2];
  12. };
  13. struct PrimVec4
  14. {
  15. PrimVec4() {}
  16. PrimVec4(float x,float y, float z, float w)
  17. {
  18. p[0] = x;
  19. p[1] = y;
  20. p[2] = z;
  21. p[3] = w;
  22. }
  23. float p[4];
  24. };
  25. typedef struct
  26. {
  27. PrimVec4 position;
  28. PrimVec4 colour;
  29. PrimVec2 uv;
  30. } PrimVertex;
  31. class GLPrimitiveRenderer
  32. {
  33. int m_screenWidth;
  34. int m_screenHeight;
  35. struct PrimInternalData* m_data;
  36. void loadBufferData();
  37. public:
  38. GLPrimitiveRenderer(int screenWidth, int screenHeight);
  39. virtual ~GLPrimitiveRenderer();
  40. void drawRect(float x0, float y0, float x1, float y1, float color[4]);
  41. void drawTexturedRect(float x0, float y0, float x1, float y1, float color[4], float u0,float v0, float u1, float v1, int useRGBA=0);
  42. void drawTexturedRect3D(const PrimVertex& v0,const PrimVertex& v1,const PrimVertex& v2,const PrimVertex& v3,float viewMat[16],float projMat[16], bool useRGBA = true);
  43. void drawLine();//float from[4], float to[4], float color[4]);
  44. void setScreenSize(int width, int height);
  45. PrimInternalData* getData()
  46. {
  47. return m_data;
  48. }
  49. };
  50. #endif//_GL_PRIMITIVE_RENDERER_H