]> git.vomp.tv Git - vompclient.git/blob - osdopengl.h
First steps towards Shader MoComp, not displaying properly yet
[vompclient.git] / osdopengl.h
1 /*\r
2     Copyright 2004-2005 Chris Tallon, 2006,2011-2012 Marten Richter\r
3 \r
4     This file is part of VOMP.\r
5 \r
6     VOMP is free software; you can redistribute it and/or modify\r
7     it under the terms of the GNU General Public License as published by\r
8     the Free Software Foundation; either version 2 of the License, or\r
9     (at your option) any later version.\r
10 \r
11     VOMP is distributed in the hope that it will be useful,\r
12     but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14     GNU General Public License for more details.\r
15 \r
16     You should have received a copy of the GNU General Public License\r
17     along with VOMP; if not, write to the Free Software\r
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\r
19 */\r
20 \r
21 #ifndef OSDOPENGL_H\r
22 #define OSDOPENGL_H\r
23 \r
24 #include <stdio.h>\r
25 \r
26 #include <bcm_host.h>\r
27 \r
28 #include <GLES2/gl2.h>\r
29 #include <EGL/egl.h>\r
30 #include <EGL/eglext.h>\r
31 \r
32 #include "osd.h"\r
33 #include "defines.h"\r
34 #include "log.h"\r
35 #include "threadp.h"\r
36 #include "mutex.h"\r
37 #include "videovpeogl.h"\r
38 \r
39 #include "glosdshader.h"\r
40 #include "glyuv400shader.h"\r
41 #include "glyuv444shader.h"\r
42 \r
43 \r
44 \r
45 \r
46 \r
47 \r
48 struct OSDCOLOR{\r
49         GLfloat r;\r
50         GLfloat g;\r
51         GLfloat b;\r
52         GLfloat a;\r
53 };\r
54 \r
55 \r
56 struct OSDVERTEX {\r
57         GLfloat x;\r
58         GLfloat y;\r
59         GLfloat z;\r
60 /*      OSDCOLOR c;*/\r
61         GLfloat u;\r
62         GLfloat v;\r
63 };\r
64 \r
65 \r
66 \r
67 \r
68 \r
69 \r
70 class OsdOpenGL : public Osd, public Thread_TYPE\r
71 {\r
72   public:\r
73     OsdOpenGL();\r
74     virtual ~OsdOpenGL();\r
75 \r
76     int init(void* device);\r
77     int shutdown();\r
78 \r
79     int getFD();\r
80 \r
81     void screenShot(const char* fileName);\r
82 \r
83     Surface * createNewSurface();\r
84 \r
85 \r
86 \r
87 \r
88         // This function is called from the threadMethod function in order to get Screen updates\r
89 /*      void Render();\r
90         void RenderDS(VPEOGLFrame* frame);*/\r
91         void BeginPainting();\r
92         void EndPainting();\r
93 \r
94         void setExternalDriving(/*DsAllocator* dsall,*/ unsigned int width, unsigned int height);\r
95         void Blank();\r
96 \r
97         void getEGLObjs(EGLDisplay *i_egl_display,EGLSurface *i_egl_surface,EGLContext *i_egl_context, EGLConfig *i_egl_config){\r
98                 *i_egl_display=egl_display;\r
99                 *i_egl_surface=egl_surface;\r
100                 *i_egl_context=egl_context;\r
101                 *i_egl_config=egl_ourconfig;\r
102         };\r
103 \r
104         EGLConfig getEGLConfig() {return egl_ourconfig;};\r
105 \r
106         void AdviseAboutNewFrame() {threadSignal();};\r
107 \r
108 \r
109 \r
110 private:\r
111 \r
112         //Maybe move the following stuff to a generic opengl object also for boosting DCT etc.\r
113 \r
114 \r
115 \r
116         void threadMethod();\r
117     void threadPostStopCleanup();\r
118 \r
119         // This indicates, that currently a video is played, thus the osd updates are driven by the Videosystem\r
120         bool external_driving;\r
121         Mutex glmutex;\r
122         long long  lastrendertime;\r
123         void InternalRendering(VPEOGLFrame* frame);\r
124         bool DoLost();\r
125         void InitVertexBuffer(float  scalex,float scaley);\r
126         OSDVERTEX osdvertices[4];\r
127         GLubyte osdindices[6];\r
128 \r
129 \r
130 /*      GLuint osd_shader;\r
131         GLuint gen_shader;\r
132 \r
133         GLuint osd_program;\r
134 \r
135         GLuint frame_shader;\r
136         GLuint frame_program;\r
137 \r
138         GLint frame_sampler_locY;\r
139         GLint frame_sampler_locU;\r
140         GLint frame_sampler_locV;\r
141 \r
142         GLint osd_sampler_loc;*/\r
143         GLOsdShader osd_shader;\r
144         GLYuv400Shader yuv400_shader;\r
145         GLYuv444Shader yuv444_shader;\r
146 \r
147 \r
148 \r
149 \r
150          /* BCM specific */\r
151 \r
152     uint32_t display_height;\r
153         uint32_t display_width;\r
154 \r
155         EGLDisplay egl_display;\r
156         EGLSurface egl_surface;\r
157         EGLContext egl_context;\r
158         EGLConfig egl_ourconfig;\r
159 #ifdef BENCHMARK_FPS\r
160         long long last_benchmark_time;\r
161         unsigned int num_benchmark_frames;\r
162 #endif\r
163 \r
164 };\r
165 \r
166 #endif\r