ScreenDump: WindowSystems: add screenId in doScreenShot function
[profile/ivi/layer-management.git] / LayerManagerExamples / EGLX11MockNavigation / include / OpenGLES2App.h
1 /***************************************************************************
2  *
3  * Copyright 2010,2011 BMW Car IT GmbH
4  *
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  ****************************************************************************/
19 #ifndef _OPENGLES2APP_H
20 #define _OPENGLES2APP_H
21
22 #include <GLES2/gl2.h>
23
24 #include "X11/Xlib.h"
25 #include "X11/Xutil.h"
26 #include <EGL/egl.h>
27
28 struct SurfaceConfiguration
29 {
30     unsigned int layerId;
31     unsigned int surfaceId;
32     unsigned int surfaceWidth;
33     unsigned int surfaceHeight;
34     unsigned int surfacePosX;
35     unsigned int surfacePosY;
36     float opacity;
37     bool nosky;
38 };
39
40 class OpenGLES2App
41 {
42 public:
43     OpenGLES2App(float fps, float animationSpeed, SurfaceConfiguration* config);
44     virtual ~OpenGLES2App();
45
46     void mainloop();
47
48 protected:
49     virtual void update(int currentTimeInMs, int elapsedTimeInMs) = 0;
50     virtual void render() = 0;
51         void swapBuffers();
52
53 private:
54         bool createX11Context(SurfaceConfiguration* config);
55         void destroyX11Context();
56
57         bool createEGLContext();
58         void destroyEglContext();
59
60         bool setupLayerMangement(SurfaceConfiguration* config);
61
62         unsigned int GetTickCount();
63
64 protected:
65     float m_framesPerSecond;
66     float m_animationSpeed;
67     unsigned int m_timerIntervalInMs;
68
69     struct EglContextStruct
70     {
71         EGLDisplay eglDisplay;
72         EGLConfig eglConfig;
73         EGLSurface eglSurface;
74         EGLContext eglContext;
75     };
76
77     EglContextStruct m_eglContextStruct;
78
79     struct X11ContextStruct
80     {
81         Window x11Window;
82         Display* x11Display;
83         long x11Screen;
84         XVisualInfo* x11Visual;
85         Colormap x11Colormap;
86     };
87
88     X11ContextStruct m_x11ContextStruct;
89
90 };
91
92 #endif /* _OPENGLES2APP_H */