1 /***************************************************************************
3 * Copyright 2010, 2011 BMW Car IT GmbH
4 * Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ****************************************************************************/
20 #ifndef _OpenGLES2App_h
21 #define _OpenGLES2App_h
23 #include "wayland-client.h"
24 #include "wayland-egl.h"
25 #include <GLES2/gl2.h>
27 #include "ilm_client.h"
30 struct SurfaceConfiguration
33 unsigned int surfaceId;
34 unsigned int surfaceWidth;
35 unsigned int surfaceHeight;
36 unsigned int surfacePosX;
37 unsigned int surfacePosY;
45 OpenGLES2App(float fps, float animationSpeed, SurfaceConfiguration* config);
46 virtual ~OpenGLES2App();
50 static void serverinfoListener( void *data, struct serverinfo *pServerinfo, uint32_t client_handle );
51 static void display_handle_global(struct wl_display* display, uint32_t id, const char* interface, uint32_t version, void* data);
52 static int event_mask_update(uint32_t mask, void* data);
53 static void frame_listener_func(void *data, struct wl_callback *callback, uint32_t time);
56 virtual void update(int currentTimeInMs, int elapsedTimeInMs) = 0;
57 virtual void render() = 0;
61 bool createWLContext(SurfaceConfiguration* config);
62 void destroyWLContext();
64 bool createEGLContext();
65 void destroyEglContext();
67 bool setupLayerMangement(SurfaceConfiguration* config);
69 unsigned int GetTickCount();
72 float m_framesPerSecond;
73 float m_animationSpeed;
74 unsigned int m_timerIntervalInMs;
76 struct EglContextStruct
78 EGLNativeDisplayType nativeDisplay;
79 EGLNativeWindowType nativeWindow;
80 EGLDisplay eglDisplay;
82 EGLSurface eglSurface;
83 EGLContext eglContext;
86 EglContextStruct m_eglContextStruct;
88 typedef struct t_wlContextStruct
90 struct wl_display* wlDisplay;
91 struct wl_compositor* wlCompositor;
92 struct wl_egl_window* wlNativeWindow;
93 struct wl_surface* wlSurface;
99 struct serverinfo* wlExtServerinfo;
102 WLContextStruct m_wlContextStruct;