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 registry_handle_global(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version);
52 static void frame_listener_func(void *data, struct wl_callback *callback, uint32_t time);
55 virtual void update(int currentTimeInMs, int elapsedTimeInMs) = 0;
56 virtual void render() = 0;
60 bool createWLContext(SurfaceConfiguration* config);
61 void destroyWLContext();
63 bool createEGLContext();
64 void destroyEglContext();
66 bool setupLayerMangement(SurfaceConfiguration* config);
68 unsigned int GetTickCount();
71 float m_framesPerSecond;
72 float m_animationSpeed;
73 unsigned int m_timerIntervalInMs;
75 struct EglContextStruct
77 EGLNativeDisplayType nativeDisplay;
78 EGLNativeWindowType nativeWindow;
79 EGLDisplay eglDisplay;
81 EGLSurface eglSurface;
82 EGLContext eglContext;
85 EglContextStruct m_eglContextStruct;
87 typedef struct t_wlContextStruct
89 struct wl_display* wlDisplay;
90 struct wl_registry* wlRegistry;
91 struct wl_compositor* wlCompositor;
92 struct wl_egl_window* wlNativeWindow;
93 struct wl_surface* wlSurface;
97 struct serverinfo* wlExtServerinfo;
100 WLContextStruct m_wlContextStruct;