]> git.vomp.tv Git - vompclient.git/blob - osdopengl.h
Reorganizing Shader, Creatinng GLShader framework
[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 \r
42 \r
43 \r
44 \r
45 \r
46 \r
47 struct OSDCOLOR{\r
48         GLfloat r;\r
49         GLfloat g;\r
50         GLfloat b;\r
51         GLfloat a;\r
52 };\r
53 \r
54 \r
55 struct OSDVERTEX {\r
56         GLfloat x;\r
57         GLfloat y;\r
58         GLfloat z;\r
59 /*      OSDCOLOR c;*/\r
60         GLfloat u;\r
61         GLfloat v;\r
62 };\r
63 \r
64 \r
65 \r
66 \r
67 \r
68 \r
69 class OsdOpenGL : public Osd, public Thread_TYPE\r
70 {\r
71   public:\r
72     OsdOpenGL();\r
73     virtual ~OsdOpenGL();\r
74 \r
75     int init(void* device);\r
76     int shutdown();\r
77 \r
78     int getFD();\r
79 \r
80     void screenShot(const char* fileName);\r
81 \r
82     Surface * createNewSurface();\r
83 \r
84 \r
85 \r
86 \r
87         // This function is called from the threadMethod function in order to get Screen updates\r
88 /*      void Render();\r
89         void RenderDS(VPEOGLFrame* frame);*/\r
90         void BeginPainting();\r
91         void EndPainting();\r
92 \r
93         void setExternalDriving(/*DsAllocator* dsall,*/ unsigned int width, unsigned int height);\r
94         void Blank();\r
95 \r
96         void getEGLObjs(EGLDisplay *i_egl_display,EGLSurface *i_egl_surface,EGLContext *i_egl_context, EGLConfig *i_egl_config){\r
97                 *i_egl_display=egl_display;\r
98                 *i_egl_surface=egl_surface;\r
99                 *i_egl_context=egl_context;\r
100                 *i_egl_config=egl_ourconfig;\r
101         };\r
102 \r
103         EGLConfig getEGLConfig() {return egl_ourconfig;};\r
104 \r
105         void AdviseAboutNewFrame() {threadSignal();};\r
106 \r
107 \r
108 \r
109 private:\r
110 \r
111         //Maybe move the following stuff to a generic opengl object also for boosting DCT etc.\r
112 \r
113 \r
114 \r
115         void threadMethod();\r
116     void threadPostStopCleanup();\r
117 \r
118         // This indicates, that currently a video is played, thus the osd updates are driven by the Videosystem\r
119         bool external_driving;\r
120         Mutex glmutex;\r
121         long long  lastrendertime;\r
122         void InternalRendering(VPEOGLFrame* frame);\r
123         bool DoLost();\r
124         void InitVertexBuffer(float  scalex,float scaley);\r
125         OSDVERTEX osdvertices[4];\r
126         GLubyte osdindices[6];\r
127 \r
128 \r
129 /*      GLuint osd_shader;\r
130         GLuint gen_shader;\r
131 \r
132         GLuint osd_program;\r
133 \r
134         GLuint frame_shader;\r
135         GLuint frame_program;\r
136 \r
137         GLint frame_sampler_locY;\r
138         GLint frame_sampler_locU;\r
139         GLint frame_sampler_locV;\r
140 \r
141         GLint osd_sampler_loc;*/\r
142         GLOsdShader osd_shader;\r
143         GLYuv400Shader yuv400_shader;\r
144 \r
145 \r
146 \r
147 \r
148          /* BCM specific */\r
149 \r
150     uint32_t display_height;\r
151         uint32_t display_width;\r
152 \r
153         EGLDisplay egl_display;\r
154         EGLSurface egl_surface;\r
155         EGLContext egl_context;\r
156         EGLConfig egl_ourconfig;\r
157 #ifdef BENCHMARK_FPS\r
158         long long last_benchmark_time;\r
159         unsigned int num_benchmark_frames;\r
160 #endif\r
161 \r
162 };\r
163 \r
164 #endif\r