]> git.vomp.tv Git - vompclient.git/blob - osdopengl.h
Preparations for dynamic mode switching
[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 \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 "videoomx.h"\r
38 \r
39 #include "glosdshader.h"\r
40 \r
41 \r
42 \r
43 \r
44 \r
45 \r
46 struct OSDCOLOR{\r
47         GLfloat r;\r
48         GLfloat g;\r
49         GLfloat b;\r
50         GLfloat a;\r
51 };\r
52 \r
53 \r
54 struct OSDVERTEX {\r
55         GLfloat x;\r
56         GLfloat y;\r
57         GLfloat z;\r
58 /*      OSDCOLOR c;*/\r
59         GLfloat u;\r
60         GLfloat v;\r
61 };\r
62 \r
63 \r
64 \r
65 \r
66 \r
67 \r
68 class OsdOpenGL : public Osd, public Thread_TYPE\r
69 {\r
70   public:\r
71     OsdOpenGL();\r
72     virtual ~OsdOpenGL();\r
73 \r
74     int init(void* device);\r
75     int shutdown();\r
76 \r
77     int getFD();\r
78 \r
79     void screenShot(const char* fileName);\r
80 \r
81     Surface * createNewSurface();\r
82 \r
83 \r
84         void BeginPainting();\r
85         void EndPainting();\r
86 \r
87         void Blank();\r
88 \r
89         void getEGLObjs(EGLDisplay *i_egl_display,EGLSurface *i_egl_surface,EGLContext *i_egl_context, EGLConfig *i_egl_config){\r
90                 *i_egl_display=egl_display;\r
91                 *i_egl_surface=egl_surface;\r
92                 *i_egl_context=egl_context;\r
93                 *i_egl_config=egl_ourconfig;\r
94         };\r
95 \r
96         EGLConfig getEGLConfig() {return egl_ourconfig;};\r
97 \r
98         void AdviseAboutNewFrame() {threadSignal();};\r
99 \r
100 \r
101 \r
102 \r
103 private:\r
104 \r
105         //Maybe move the following stuff to a generic opengl object also for boosting DCT etc.\r
106 \r
107 \r
108 \r
109         void threadMethod();\r
110     void threadPostStopCleanup();\r
111 \r
112         // This indicates, that currently a video is played, thus the osd updates are driven by the Videosystem\r
113         bool external_driving;\r
114         Mutex glmutex;\r
115         long long  lastrendertime;\r
116         void InternalRendering();\r
117         void InitVertexBuffer(float  scalex,float scaley);\r
118         OSDVERTEX osdvertices[4];\r
119         GLubyte osdindices[6];\r
120 \r
121         GLOsdShader osd_shader;\r
122 \r
123 \r
124 \r
125 \r
126          /* BCM specific */\r
127 \r
128     uint32_t display_height;\r
129         uint32_t display_width;\r
130         DISPMANX_DISPLAY_HANDLE_T bcm_display;\r
131         DISPMANX_ELEMENT_HANDLE_T bcm_element;\r
132 \r
133         uint32_t mode;\r
134 \r
135 \r
136         EGLDisplay egl_display;\r
137         EGLSurface egl_surface;\r
138         EGLContext egl_context;\r
139         EGLConfig egl_ourconfig;\r
140 #ifdef BENCHMARK_FPS\r
141         long long last_benchmark_time;\r
142         unsigned int num_benchmark_frames;\r
143 #endif\r
144 \r
145 };\r
146 \r
147 #endif\r