MythTV  master
mythrender_opengl2.h
Go to the documentation of this file.
1 #ifndef MYTHRENDEROPENGL2_H
2 #define MYTHRENDEROPENGL2_H
3 
4 #include <QStack>
5 #include <QHash>
6 #include <QMatrix4x4>
7 
8 #include "mythrender_opengl.h"
10 
11 typedef enum
12 {
21 
22 class MythGLShaderObject;
23 
25 {
26  public:
27  MythRenderOpenGL2(const MythRenderFormat& format, QPaintDevice* device,
30 
31  uint CreateShaderObject(const QString &vert, const QString &frag) override; // MythRenderOpenGL
32  void DeleteShaderObject(uint obj) override; // MythRenderOpenGL
33  void EnableShaderObject(uint obj) override; // MythRenderOpenGL
34  void SetShaderParams(uint obj, const QMatrix4x4 &m, const char* uniform) override; // MythRenderOpenGL
35 
36  bool RectanglesAreAccelerated(void) override // MythRenderOpenGL
37  { return true; }
38 
39  void PushTransformation(const UIEffects &fx, QPointF &center) override; // MythRenderOpenGL
40  void PopTransformation(void) override; // MythRenderOpenGL
41 
42  protected:
43  virtual ~MythRenderOpenGL2();
44  void DrawBitmapPriv(uint tex, const QRect *src, const QRect *dst,
45  uint prog, int alpha,
46  int red, int green, int blue) override; // MythRenderOpenGL
47  void DrawBitmapPriv(uint *textures, uint texture_count,
48  const QRectF *src, const QRectF *dst,
49  uint prog) override; // MythRenderOpenGL
50  void DrawRectPriv(const QRect &area, const QBrush &fillBrush,
51  const QPen &linePen, int alpha) override; // MythRenderOpenGL
52  void DrawRoundRectPriv(const QRect &area, int cornerRadius,
53  const QBrush &fillBrush, const QPen &linePen,
54  int alpha) override; // MythRenderOpenGL
55 
56  void Init2DState(void) override; // MythRenderOpenGL
57  void InitProcs(void) override; // MythRenderOpenGL
58  void DeleteShaders(void) override; // MythRenderOpenGL
59  bool InitFeatures(void) override; // MythRenderOpenGL
60  void ResetVars(void) override; // MythRenderOpenGL
61  void ResetProcs(void) override; // MythRenderOpenGL
62  void DeleteOpenGLResources(void) override; // MythRenderOpenGL
63  void SetMatrixView(void) override; // MythRenderOpenGL
64 
65  void CreateDefaultShaders(void);
66  void DeleteDefaultShaders(void);
67  uint CreateShader(int type, const QString &source);
68  bool ValidateShaderObject(uint obj);
69  bool CheckObjectStatus(uint obj);
70  void OptimiseShaderSource(QString &source);
71 
72  // Resources
73  QHash<GLuint, MythGLShaderObject> m_shader_objects;
74  uint m_shaders[kShaderCount];
75 
76  // State
77  uint m_active_obj {0};
78  QMatrix4x4 m_projection;
79  QStack<QMatrix4x4> m_transforms;
80  QMatrix4x4 m_parameters;
81  QString m_qualifiers;
82  QString m_GLSLVersion;
83 
84  typedef QHash<QString,QMatrix4x4> map_t;
86 
87  // Procs
88  MYTH_GLGETSHADERIVPROC m_glGetShaderiv {nullptr};
89  MYTH_GLCREATESHADERPROC m_glCreateShader {nullptr};
90  MYTH_GLSHADERSOURCEPROC m_glShaderSource {nullptr};
91  MYTH_GLCOMPILESHADERPROC m_glCompileShader {nullptr};
92  MYTH_GLATTACHSHADERPROC m_glAttachShader {nullptr};
93  MYTH_GLGETSHADERINFOLOGPROC m_glGetShaderInfoLog {nullptr};
94  MYTH_GLDETACHSHADERPROC m_glDetachShader {nullptr};
95  MYTH_GLDELETESHADERPROC m_glDeleteShader {nullptr};
96 
97  MYTH_GLCREATEPROGRAMPROC m_glCreateProgram {nullptr};
98  MYTH_GLLINKPROGRAMPROC m_glLinkProgram {nullptr};
99  MYTH_GLUSEPROGRAMPROC m_glUseProgram {nullptr};
100  MYTH_GLDELETEPROGRAMPROC m_glDeleteProgram {nullptr};
101  MYTH_GLGETPROGRAMINFOLOGPROC m_glGetProgramInfoLog {nullptr};
102  MYTH_GLGETPROGRAMIVPROC m_glGetProgramiv {nullptr};
103 
104  MYTH_GLGETUNIFORMLOCATIONPROC m_glGetUniformLocation {nullptr};
105  MYTH_GLUNIFORM1IPROC m_glUniform1i {nullptr};
106  MYTH_GLUNIFORMMATRIX4FVPROC m_glUniformMatrix4fv {nullptr};
107  MYTH_GLVERTEXATTRIBPOINTERPROC m_glVertexAttribPointer {nullptr};
108  MYTH_GLENABLEVERTEXATTRIBARRAYPROC m_glEnableVertexAttribArray {nullptr};
109  MYTH_GLDISABLEVERTEXATTRIBARRAYPROC m_glDisableVertexAttribArray {nullptr};
110  MYTH_GLBINDATTRIBLOCATIONPROC m_glBindAttribLocation {nullptr};
111  MYTH_GLVERTEXATTRIB4FPROC m_glVertexAttrib4f {nullptr};
112 
113  // Prevent compiler complaints about using 0 as a null pointer.
114  inline void m_glVertexAttribPointerI(GLuint index, GLint size, GLenum type,
115  GLboolean normalize, GLsizei stride,
116  const GLuint value);
117 };
118 
119 #endif // MYTHRENDEROPENGL2_H
QStack< QMatrix4x4 > m_transforms
void(* MYTH_GLUSEPROGRAMPROC)(GLuint program)
void(* MYTH_GLDISABLEVERTEXATTRIBARRAYPROC)(GLuint index)
virtual void SetShaderParams(uint prog, const QMatrix4x4 &m, const char *uniform)=0
void(* MYTH_GLBINDATTRIBLOCATIONPROC)(GLuint program, GLuint index, const GLcharARB *name)
void(* MYTH_GLSHADERSOURCEPROC)(GLuint shader, int numOfStrings, const char **strings, const int *lenOfStrings)
virtual void DeleteShaders(void)=0
unsigned int uint
Definition: compat.h:140
void(* MYTH_GLVERTEXATTRIBPOINTERPROC)(GLuint index, GLint size, GLenum type, GLboolean normalize, GLsizei stride, const GLvoid *ptr)
virtual void DrawRoundRectPriv(const QRect &area, int cornerRadius, const QBrush &fillBrush, const QPen &linePen, int alpha)=0
void(* MYTH_GLVERTEXATTRIB4FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
virtual void PopTransformation(void)=0
void(* MYTH_GLLINKPROGRAMPROC)(GLuint program)
virtual uint CreateShaderObject(const QString &vert, const QString &frag)=0
QHash< GLuint, MythGLShaderObject > m_shader_objects
GLuint(* MYTH_GLCREATESHADERPROC)(GLenum shaderType)
virtual void PushTransformation(const UIEffects &fx, QPointF &center)=0
void(* MYTH_GLGETSHADERINFOLOGPROC)(GLuint shader, GLint maxlength, GLint *length, GLchar *infolog)
virtual bool InitFeatures(void)
void(* MYTH_GLDELETESHADERPROC)(GLuint id)
void(* MYTH_GLGETSHADERIVPROC)(GLuint shader, GLenum pname, GLint *params)
DefaultShaders
class QGLFormat MythRenderFormat
GLint(* MYTH_GLGETUNIFORMLOCATIONPROC)(GLuint program, const char *name)
virtual void DrawRectPriv(const QRect &area, const QBrush &fillBrush, const QPen &linePen, int alpha)=0
virtual void SetMatrixView(void)=0
void(* MYTH_GLATTACHSHADERPROC)(GLuint program, GLuint shader)
void(* MYTH_GLENABLEVERTEXATTRIBARRAYPROC)(GLuint index)
GLuint(* MYTH_GLCREATEPROGRAMPROC)(void)
void(* MYTH_GLGETPROGRAMINFOLOGPROC)(GLuint object, int maxLen, int *len, char *log)
virtual void EnableShaderObject(uint obj)=0
#define MUI_PUBLIC
Definition: mythuiexp.h:9
void(* MYTH_GLCOMPILESHADERPROC)(GLuint shader)
void(* MYTH_GLUNIFORM1IPROC)(GLint location, GLint)
void(* MYTH_GLDETACHSHADERPROC)(GLuint program, GLuint shader)
virtual void ResetVars(void)
RenderType
void(* MYTH_GLUNIFORMMATRIX4FVPROC)(GLint location, GLint size, GLboolean transpose, const GLfloat *values)
virtual void Init2DState(void)
virtual void ResetProcs(void)
bool RectanglesAreAccelerated(void) override
void(* MYTH_GLDELETEPROGRAMPROC)(GLuint shader)
void(* MYTH_GLGETPROGRAMIVPROC)(GLuint object, GLenum type, int *param)
virtual void DeleteShaderObject(uint obj)=0
QHash< QString, QMatrix4x4 > map_t
virtual void DrawBitmapPriv(uint tex, const QRect *src, const QRect *dst, uint prog, int alpha, int red, int green, int blue)=0
virtual void DeleteOpenGLResources(void)
virtual void InitProcs(void)