]> git.vomp.tv Git - vompclient.git/blob - osdopengl.h
11 CWFs
[vompclient.git] / osdopengl.h
1 /*
2     Copyright 2004-2005 Chris Tallon, 2006,2011-2012 Marten Richter
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
18 */
19
20 #ifndef OSDOPENGL_H
21 #define OSDOPENGL_H
22
23 #include <stdio.h>
24 #include <mutex>
25
26 #include <GLES2/gl2.h>
27 #include <EGL/egl.h>
28 #include <EGL/eglext.h>
29
30 #include "osd.h"
31 #include "defines.h"
32 #include "log.h"
33 #include "threadp.h"
34 #include "videoomx.h"
35
36 #include "glosdshader.h"
37
38 struct OSDCOLOR{
39         GLfloat r;
40         GLfloat g;
41         GLfloat b;
42         GLfloat a;
43 };
44
45
46 struct OSDVERTEX {
47         GLfloat x;
48         GLfloat y;
49         GLfloat z;
50 /*      OSDCOLOR c;*/
51         GLfloat u;
52         GLfloat v;
53 };
54
55 class OsdOpenGL : public Osd, public Thread_TYPE
56 {
57   public:
58     OsdOpenGL();
59     virtual ~OsdOpenGL();
60
61     int init();
62     int shutdown();
63
64     void screenShot(const char* fileName);
65
66     Surface * createNewSurface();
67
68
69         void BeginPainting();
70         void EndPainting();
71
72         void Blank();
73
74         void getEGLObjs(EGLDisplay *i_egl_display,EGLSurface *i_egl_surface,EGLContext *i_egl_context, EGLConfig *i_egl_config){
75                 *i_egl_display=egl_display;
76                 *i_egl_surface=egl_surface;
77                 *i_egl_context=egl_context;
78                 *i_egl_config=egl_ourconfig;
79         };
80
81         EGLConfig getEGLConfig() {return egl_ourconfig;};
82
83         void AdviseAboutNewFrame() {threadSignal();};
84
85
86
87
88 private:
89
90         //Maybe move the following stuff to a generic opengl object also for boosting DCT etc.
91
92
93
94         void threadMethod();
95
96         // This indicates, that currently a video is played, thus the osd updates are driven by the Videosystem
97         bool external_driving;
98         std::mutex glmutex;
99         long long  lastrendertime;
100         void InternalRendering();
101         void InitVertexBuffer(float  scalex,float scaley);
102         OSDVERTEX osdvertices[4];
103         GLubyte osdindices[6];
104
105         GLOsdShader osd_shader;
106
107          /* BCM specific */
108
109     uint32_t display_height;
110         uint32_t display_width;
111         DISPMANX_DISPLAY_HANDLE_T bcm_display;
112         DISPMANX_ELEMENT_HANDLE_T bcm_element;
113
114         uint32_t mode;
115
116         EGLDisplay egl_display;
117         EGLSurface egl_surface;
118         EGLContext egl_context;
119         EGLConfig egl_ourconfig;
120 #ifdef BENCHMARK_FPS
121         long long last_benchmark_time;
122         unsigned int num_benchmark_frames;
123 #endif
124
125 };
126
127 #endif