--- /dev/null
+############################################################################
+#
+# Copyright 2010, 2011 BMW Car IT GmbH
+# Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+############################################################################
+
+cmake_minimum_required (VERSION 2.6)
+
+find_package(GLESv2 REQUIRED)
+find_package(EGL REQUIRED)
+find_package(Wayland REQUIRED)
+
+include_directories(
+ ${GLESv2_INCLUDE_DIR}
+ ${EGL_INCLUDE_DIR}
+ ${WAYLAND_CLIENT_INCLUDE_DIR}
+ ${FFI_INCLUDE_DIR}
+ "include"
+ "../../LayerManagerClient/ilmClient/include"
+ "../LayerSceneDescriptionExample/include"
+ "../../LayerManagerUtils/include"
+)
+
+link_directories(
+ "${PROJECT_SOURCE_DIR}/LayerManagerUtils/bin"
+)
+
+set (HEADER_FILES
+
+ include/Camera.h
+ include/Car.h
+ include/Argument.h
+ include/OpenGLES2App.h
+ include/Ground.h
+ include/House.h
+ include/IRenderable.h
+ include/IUpdateable.h
+ include/MockNavi.h
+ include/Street.h
+ include/ShaderBase.h
+ include/ShaderLighting.h
+)
+
+set (SRC_FILES
+
+ src/Camera.cpp
+ src/Car.cpp
+ src/Argument.cpp
+ src/OpenGLES2App.cpp
+ src/Ground.cpp
+ src/House.cpp
+ src/MockNavi.cpp
+ src/Street.cpp
+ src/ShaderBase.cpp
+ src/ShaderLighting.cpp
+ src/main.cpp
+ src/WaylandServerinfoProtocol.cpp
+)
+
+add_executable(EGLWLMockNavigation
+ ${SRC_FILES}
+ ${HEADER_FILES}
+)
+
+add_dependencies(EGLWLMockNavigation
+ ilmClient
+ EGLWLMockNavigation LayerManagerUtils wayland-client
+)
+
+set(LIBS
+ ${LIBS}
+ ${GLESv2_LIBRARIES}
+ ${WAYLAND_CLIENT_LIBRARIES}
+ ${FFI_LIBRARIES}
+ ${EGL_LIBRARY}
+ LayerManagerUtils
+ ilmClient
+)
+
+#target_link_libraries(EGLWLMockNavigation ${LIBS} wayland-client -ldl)
+target_link_libraries(EGLWLMockNavigation ${LIBS} wayland-client wayland-egl -static-libstdc++ -ldl)
+
+install (TARGETS EGLWLMockNavigation DESTINATION bin)
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2010,2011 BMW Car IT GmbH
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#ifndef _Argument_h
+#define _Argument_h
+
+#include <string>
+using std::string;
+
+class BoolArgument {
+public:
+ BoolArgument(string name, bool default_value, int argc, const char * const argv[]);
+ bool get();
+
+private:
+ bool value;
+};
+
+class FloatArgument {
+public:
+ FloatArgument(string name, float default_value, int argc, const char * const argv[]);
+ float get();
+
+private:
+ float value;
+};
+
+class IntArgument {
+public:
+ IntArgument(string name, int default_value, int argc, const char * const argv[]);
+ int get();
+
+private:
+ int value;
+};
+
+class UnsignedIntArgument {
+public:
+ UnsignedIntArgument(string name, unsigned int default_value, int argc, const char * const argv[]);
+ unsigned int get();
+
+private:
+ unsigned int value;
+};
+
+#endif
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2010,2011 BMW Car IT GmbH
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#ifndef _Camera_h
+#define _Camera_h
+
+#include "IUpdateable.h"
+#include "IlmMatrix.h"
+#include "vec.h"
+
+class Camera : public IUpdateable
+{
+public:
+ Camera(vec3f position, vec3f target, float viewportWidth, float viewportHeight);
+ virtual ~Camera();
+
+ IlmMatrix* getViewProjectionMatrix();
+ void update(int currentTimeInMs, int lastFrameTime);
+
+private:
+ vec3f m_position;
+ vec3f m_target;
+ IlmMatrix m_viewProjectionMatrix;
+ IlmMatrix m_translationMatrix;
+ IlmMatrix m_rotationMatrix;
+ IlmMatrix m_projectionMatrix;
+ IlmMatrix m_identityMatrix;
+ IlmMatrix eyeMatrix;
+};
+
+#endif
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2010,2011 BMW Car IT GmbH
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#ifndef _Car_h
+#define _Car_h
+
+#include "IRenderable.h"
+#include "vec.h"
+
+class ShaderBase;
+
+class Car : public IRenderable
+{
+public:
+ Car(vec3f position, vec3f size, vec4f color, ShaderBase* shader);
+ virtual ~Car() {}
+
+ virtual void render();
+
+private:
+ vec3f m_position;
+ vec3f m_size;
+ vec4f m_color;
+
+ vec3u m_index;
+ vec3f m_vertex[3];
+
+ ShaderBase* m_pShader;
+};
+
+#endif
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2010,2011 BMW Car IT GmbH
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#ifndef _Ground_h
+#define _Ground_h
+
+#include "IRenderable.h"
+#include "vec.h"
+
+class IlmMatrix;
+class ShaderBase;
+
+class Ground : public IRenderable
+{
+public:
+ Ground(vec3f position, vec3f size, vec4f color, ShaderBase* pShader);
+ virtual ~Ground() {}
+
+ virtual void render();
+
+private:
+ vec3f m_position;
+ vec3f m_size;
+ vec4f m_color;
+
+ vec3u m_index[2];
+ vec3f m_vertex[4];
+
+ ShaderBase* m_pShader;
+};
+
+#endif
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2010,2011 BMW Car IT GmbH
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#ifndef _MockNaviHouse_h
+#define _MockNaviHouse_h
+
+#include "IRenderable.h"
+#include "IUpdateable.h"
+#include "IlmMatrix.h"
+#include "vec.h"
+
+class ShaderBase;
+
+class House : public IRenderable, public IUpdateable
+{
+public:
+ House(vec3f position, vec3f size, vec4f houseColor, ShaderBase* pShader);
+ virtual ~House();
+
+ virtual void render();
+ virtual void update(int currentTimeInMs, int lastFrameTime);
+
+private:
+ void attachVertexBuffer();
+ void detachVertexBuffer();
+
+private:
+ vec3f m_position;
+ vec3f m_size;
+ vec4f m_color;
+
+ vec3f m_normals[6];
+ vec3u m_index[12];
+ vec3f m_vertex[8];
+
+ ShaderBase* m_pShader;
+};
+
+#endif
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2010,2011 BMW Car IT GmbH
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#ifndef _IRenderable_h
+#define _IRenderable_h
+
+class IRenderable
+{
+public:
+ virtual ~IRenderable() {}
+ virtual void render() = 0;
+};
+
+#endif
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2010,2011 BMW Car IT GmbH
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#ifndef _IUpdateable_h
+#define _IUpdateable_h
+
+class IUpdateable
+{
+public:
+ virtual ~IUpdateable() {}
+ virtual void update(int currentTimeInMs, int lastFrameTime) = 0;
+};
+
+#endif
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2010,2011 BMW Car IT GmbH
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#ifndef _MockNavi_h
+#define _MockNavi_h
+
+#include "OpenGLES2App.h"
+#include "IRenderable.h"
+#include "IUpdateable.h"
+#include "Camera.h"
+
+#include <list>
+using std::list;
+
+class MockNaviHouse;
+
+class MockNavi : public OpenGLES2App
+{
+public:
+ MockNavi(float fps, float animationSpeed, SurfaceConfiguration* config);
+
+ virtual void update(int currentTimeInMs, int lastFrameTime);
+ virtual void render();
+
+private:
+ void generateCity();
+
+private:
+ Camera m_camera;
+ int lastUpdateTime;
+ int m_houseCount;
+ list<IRenderable*> m_renderList;
+ list<IUpdateable*> m_updateList;
+};
+
+#endif
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2010, 2011 BMW Car IT GmbH
+ * Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#ifndef _OpenGLES2App_h
+#define _OpenGLES2App_h
+
+#include "wayland-client.h"
+#include "wayland-egl.h"
+#include <GLES2/gl2.h>
+
+#include "ilm_client.h"
+#include <EGL/egl.h>
+
+struct SurfaceConfiguration
+{
+ unsigned int layerId;
+ unsigned int surfaceId;
+ unsigned int surfaceWidth;
+ unsigned int surfaceHeight;
+};
+
+class OpenGLES2App
+{
+public:
+ OpenGLES2App(float fps, float animationSpeed, SurfaceConfiguration* config);
+ virtual ~OpenGLES2App();
+
+ void mainloop();
+
+ static void serverinfoListener( void *data, struct serverinfo *pServerinfo, uint32_t client_handle );
+ static void display_handle_global(struct wl_display* display, uint32_t id, const char* interface, uint32_t version, void* data);
+ static int event_mask_update(uint32_t mask, void* data);
+ static void frame_listener_func(void *data, struct wl_callback *callback, uint32_t time);
+
+protected:
+ virtual void update(int currentTimeInMs, int elapsedTimeInMs) = 0;
+ virtual void render() = 0;
+ void swapBuffers();
+
+private:
+ bool createWLContext(SurfaceConfiguration* config);
+ void destroyWLContext();
+
+ bool createEGLContext();
+ void destroyEglContext();
+
+ bool setupLayerMangement(SurfaceConfiguration* config);
+
+ unsigned int GetTickCount();
+
+protected:
+ float m_framesPerSecond;
+ float m_animationSpeed;
+ unsigned int m_timerIntervalInMs;
+
+ struct EglContextStruct
+ {
+ EGLNativeDisplayType nativeDisplay;
+ EGLNativeWindowType nativeWindow;
+ EGLDisplay eglDisplay;
+ EGLConfig eglConfig;
+ EGLSurface eglSurface;
+ EGLContext eglContext;
+ };
+
+ EglContextStruct m_eglContextStruct;
+
+ typedef struct t_wlContextStruct
+ {
+ struct wl_display* wlDisplay;
+ struct wl_compositor* wlCompositor;
+ struct wl_egl_window* wlNativeWindow;
+ struct wl_surface* wlSurface;
+ int width;
+ int height;
+
+ uint32_t mask;
+
+ struct serverinfo* wlExtServerinfo;
+ uint32_t connect_id;
+ } WLContextStruct;
+ WLContextStruct m_wlContextStruct;
+};
+
+#endif
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2010,2011 BMW Car IT GmbH
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#ifndef __SHADERBASE_H__
+#define __SHADERBASE_H__
+
+#include "vec.h"
+
+#include <string>
+using std::string;
+
+class IlmMatrix;
+
+class ShaderBase
+{
+public:
+ ShaderBase(string vertexCode, string fragmentCode, IlmMatrix* projectionMatrix);
+ virtual ~ShaderBase();
+ virtual void use(vec3f* position, vec4f* color);
+
+protected:
+ unsigned int shaderProgramId;
+
+private:
+ unsigned int fragmentShaderId;
+ unsigned int vertexShaderId;
+ int m_uniformProjectionMatrix;
+
+private:
+ bool initShader();
+ bool destroyShader();
+
+private:
+ string m_vertexCode;
+ string m_fragmentCode;
+ IlmMatrix* m_projectionMatrix;
+};
+
+#endif // __SHADERBASE_H__
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2010,2011 BMW Car IT GmbH
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#ifndef SHADERLIGHTING_H_
+#define SHADERLIGHTING_H_
+
+#include "ShaderBase.h"
+
+class ShaderLighting: public ShaderBase {
+public:
+ ShaderLighting(IlmMatrix* projectionMatrix);
+ virtual ~ShaderLighting();
+
+ virtual void use(vec3f* position, vec4f* color);
+
+private:
+ vec3f* m_pPosition;
+ vec4f* m_pColor;
+ int m_uniformModelMatrix;
+ int m_uniformColor;
+};
+
+#endif /* SHADERLIGHTING_H_ */
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2010,2011 BMW Car IT GmbH
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#ifndef _Street_h
+#define _Street_h
+
+#include "IRenderable.h"
+#include "IUpdateable.h"
+#include "vec.h"
+
+class ShaderBase;
+
+class Street : public IRenderable, public IUpdateable
+{
+public:
+ Street(vec3f position, vec3f size, vec4f color, ShaderBase* shader);
+ virtual ~Street() {}
+
+ virtual void render();
+ virtual void update(int currentTimeInMs, int lastFrameTime);
+
+private:
+ vec3f m_position;
+ vec3f m_size;
+ vec4f m_color;
+
+ vec3u m_index[2];
+ vec3f m_vertex[4];
+
+ ShaderBase* m_shader;
+};
+
+#endif
--- /dev/null
+/***************************************************************************
+*
+* Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
+*
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*
+* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*
+****************************************************************************/
+
+#ifndef WAYLAND_SERVERINFO_CLIENT_PROTOCOL_H
+#define WAYLAND_SERVERINFO_CLIENT_PROTOCOL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <stddef.h>
+#include "wayland-util.h"
+
+struct wl_client;
+struct wl_resource;
+
+struct serverinfo;
+
+extern const struct wl_interface serverinfo_interface;
+
+struct serverinfo_listener {
+ void (*connection_id)(void *data,
+ struct serverinfo *serverinfo,
+ uint32_t connection_id);
+};
+
+static inline int
+serverinfo_add_listener(struct serverinfo *serverinfo,
+ const struct serverinfo_listener *listener, void *data)
+{
+ return wl_proxy_add_listener((struct wl_proxy *) serverinfo,
+ (void (**)(void)) listener, data);
+}
+
+#define SERVERINFO_GET_CONNECTION_ID 0
+
+static inline void
+serverinfo_set_user_data(struct serverinfo *serverinfo, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) serverinfo, user_data);
+}
+
+static inline void *
+serverinfo_get_user_data(struct serverinfo *serverinfo)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) serverinfo);
+}
+
+static inline void
+serverinfo_destroy(struct serverinfo *serverinfo)
+{
+ wl_proxy_destroy((struct wl_proxy *) serverinfo);
+}
+
+static inline void
+serverinfo_get_connection_id(struct serverinfo *serverinfo)
+{
+ wl_proxy_marshal((struct wl_proxy *) serverinfo,
+ SERVERINFO_GET_CONNECTION_ID);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2010,2011 BMW Car IT GmbH
+ * Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#ifndef _vec_h
+#define _vec_h
+
+#include <GLES2/gl2.h>
+
+template <class T>
+class vec2
+{
+public:
+ vec2()
+ {
+ }
+
+ vec2(T _x, T _y)
+ : x(_x)
+ , y(_y)
+ {
+ }
+
+ struct
+ {
+ T x;
+ T y;
+ };
+};
+
+template <class T>
+class vec3
+{
+public:
+ vec3()
+ {
+ }
+
+ vec3(T _x, T _y, T _z)
+ : x(_x)
+ , y(_y)
+ , z(_z)
+ {
+ }
+
+ union
+ {
+ struct
+ {
+ T x;
+ T y;
+ T z;
+ };
+ struct
+ {
+ T r;
+ T g;
+ T b;
+ };
+ };
+};
+
+template <class T>
+class vec4
+{
+public:
+ vec4()
+ {
+ }
+
+ vec4(T _x, T _y, T _z, T _w)
+ : x(_x)
+ , y(_y)
+ , z(_z)
+ , w(_w)
+ {
+ }
+
+ union
+ {
+ struct
+ {
+ T x;
+ T y;
+ T z;
+ T w;
+ };
+ struct
+ {
+ T r;
+ T g;
+ T b;
+ T a;
+ };
+ };
+};
+
+typedef vec2<GLfloat> vec2f;
+typedef vec2<GLint> vec2i;
+typedef vec2<GLushort> vec2u;
+
+typedef vec3<GLfloat> vec3f;
+typedef vec3<GLint> vec3i;
+typedef vec3<GLushort> vec3u;
+
+typedef vec4<GLfloat> vec4f;
+typedef vec4<GLint> vec4i;
+typedef vec4<GLushort> vec4u;
+
+#endif
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2010,2011 BMW Car IT GmbH
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#include "Argument.h"
+#include <iostream>
+#include <stdlib.h>
+
+BoolArgument::BoolArgument(string name, bool default_value, int argc, const char * const argv[])
+: value(default_value)
+{
+ for (int arg = 1; arg < argc; ++arg) {
+ const char* lpArgNow = argv[arg];
+
+ if ((lpArgNow[0] == '-') && (name == &lpArgNow[1])) {
+ value = !value;
+ }
+ }
+}
+
+bool BoolArgument::get()
+{
+ return value;
+}
+
+FloatArgument::FloatArgument(string name, float default_value, int argc, const char * const argv[])
+: value(default_value)
+{
+ for (int arg = 1; arg < argc; ++arg)
+ {
+ char dummy[] = "";
+ const char* lpArgNow = argv[arg];
+ const char* lpArgNext = dummy;
+
+ if (arg != argc - 1)
+ {
+ lpArgNext = argv[arg + 1];
+ }
+
+ if ((lpArgNow[0] == '-') && (name == &lpArgNow[1]))
+ {
+ value = atof(lpArgNext);
+ }
+ }
+}
+
+float FloatArgument::get()
+{
+ return value;
+}
+
+
+IntArgument::IntArgument(string name, int default_value, int argc, const char * const argv[])
+: value(default_value)
+{
+ for (int arg = 1; arg < argc; ++arg)
+ {
+ char dummy[] = "";
+ const char* lpArgNow = argv[arg];
+ const char* lpArgNext = dummy;
+
+ if (arg != argc - 1)
+ {
+ lpArgNext = argv[arg + 1];
+ }
+
+ if ((lpArgNow[0] == '-') && (name == &lpArgNow[1]))
+ {
+ value = atoi(lpArgNext);
+ }
+ }
+}
+
+int IntArgument::get()
+{
+ return value;
+}
+
+
+UnsignedIntArgument::UnsignedIntArgument(string name, unsigned int default_value, int argc, const char * const argv[])
+: value(default_value)
+{
+ for (int arg = 1; arg < argc; ++arg)
+ {
+ char dummy[] = "";
+ const char* lpArgNow = argv[arg];
+ const char* lpArgNext = dummy;
+
+ if (arg != argc - 1)
+ {
+ lpArgNext = argv[arg + 1];
+ }
+
+ if ((lpArgNow[0] == '-') && (name == &lpArgNow[1]))
+ {
+ value = atoll(lpArgNext);
+ }
+ }
+}
+
+unsigned int UnsignedIntArgument::get()
+{
+ return value;
+}
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2010,2011 BMW Car IT GmbH
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#include "Camera.h"
+#include "vec.h"
+
+#include <math.h>
+
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+
+Camera::Camera(vec3f position, vec3f target, float viewportWidth, float viewportHeight)
+: m_position(position)
+, m_target(target)
+{
+ IlmMatrixIdentity(m_identityMatrix);
+ IlmMatrixTranslation(m_translationMatrix, m_position.x, m_position.y, m_position.z);
+ IlmMatrixRotateX(m_rotationMatrix, 45.0);
+ IlmMatrixProjection(m_projectionMatrix,
+ 45.0, // field of view
+ 0.1f, // near
+ 1000.0f, // far
+ viewportWidth/viewportHeight); // aspect ratio
+}
+
+Camera::~Camera()
+{
+}
+
+IlmMatrix* Camera::getViewProjectionMatrix()
+{
+ return &m_viewProjectionMatrix;
+}
+
+void Camera::update(int currentTimeInMs, int lastFrameTime)
+{
+ (void)currentTimeInMs; // prevent warning
+ (void)lastFrameTime; // prevent warning
+
+ IlmMatrixTranslation(m_translationMatrix, m_position.x, m_position.y, m_position.z);
+
+ m_viewProjectionMatrix = m_identityMatrix;
+ //IlmMatrixMultiply(m_viewProjectionMatrix, m_viewProjectionMatrix, m_rotationMatrix);
+ IlmMatrixMultiply(m_viewProjectionMatrix, m_viewProjectionMatrix, m_translationMatrix);
+ IlmMatrixMultiply(m_viewProjectionMatrix, m_viewProjectionMatrix, m_projectionMatrix);
+}
+
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2010,2011 BMW Car IT GmbH
+ * Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#include "Car.h"
+#include "ShaderBase.h"
+#include <string.h>
+
+#include <iostream>
+using std::cout;
+using std::endl;
+
+#include <GLES2/gl2.h>
+
+
+Car::Car(vec3f position, vec3f size, vec4f color, ShaderBase* shader)
+: m_position(position)
+, m_size(size)
+, m_color(color)
+, m_index(0, 1, 2)
+, m_pShader(shader)
+{
+ m_vertex[0].x = 0.0;
+ m_vertex[0].y = 0.0;
+ m_vertex[0].z = 0.0;
+
+ m_vertex[1].x = 0.5 * m_size.x;
+ m_vertex[1].y = 0.0;
+ m_vertex[1].z = -m_size.z;
+
+ m_vertex[2].x = m_size.x;
+ m_vertex[2].y = 0.0;
+ m_vertex[2].z = 0.0;
+}
+
+void Car::render()
+{
+ m_pShader->use(&m_position, &m_color);
+
+ // draw
+ glEnableVertexAttribArray(0);
+ glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, m_vertex);
+ glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_SHORT, &m_index);
+}
+
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2010,2011 BMW Car IT GmbH
+ * Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#include "Ground.h"
+#include "IlmMatrix.h"
+#include "ShaderLighting.h"
+
+#include <string.h>
+
+#include <iostream>
+using std::cout;
+using std::endl;
+
+#include <GLES2/gl2.h>
+
+
+Ground::Ground(vec3f position, vec3f size, vec4f color, ShaderBase* pShader)
+: m_position(position)
+, m_size(size)
+, m_color(color)
+, m_pShader(pShader)
+{
+ m_index[0] = vec3u(0, 1, 2);
+ m_index[1] = vec3u(2, 3, 0);
+
+ // y z
+ // 3-------------2 | /
+ // / / |/
+ // / / ------x
+ // 0-------------1
+
+ m_vertex[0].x = m_position.x;
+ m_vertex[0].y = m_position.y;
+ m_vertex[0].z = m_position.z;
+
+ m_vertex[1].x = m_position.x + m_size.x;
+ m_vertex[1].y = m_position.y;
+ m_vertex[1].z = m_position.z;
+
+ m_vertex[2].x = m_position.x + m_size.x;
+ m_vertex[2].y = m_position.y;
+ m_vertex[2].z = m_position.z + m_size.z;
+
+ m_vertex[3].x = m_position.x;
+ m_vertex[3].y = m_position.y;
+ m_vertex[3].z = m_position.z + m_size.z;
+}
+
+void Ground::render()
+{
+ m_pShader->use(&m_position, &m_color);
+
+ // draw
+ glEnableVertexAttribArray(0);
+ glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, m_vertex);
+ glDrawElements(GL_TRIANGLES, 3 * sizeof(m_index)/sizeof(m_index[0]), GL_UNSIGNED_SHORT, m_index);
+}
+
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2010,2011 BMW Car IT GmbH
+ * Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#include "House.h"
+#include "IlmMatrix.h"
+#include "ShaderLighting.h"
+
+#include <string.h>
+#include <math.h>
+#include <limits.h>
+#include <stdlib.h>
+
+#include <iostream>
+using std::cout;
+using std::endl;
+
+#include <GLES2/gl2.h>
+
+House::House(vec3f position, vec3f size, vec4f houseColor, ShaderBase* pShader)
+: m_position(position)
+, m_size(size)
+, m_color(houseColor)
+, m_pShader(pShader)
+{
+ /*
+ // 5-------------6
+ // /| /|
+ // / | / |
+ // 1-------------2 |
+ // | | | |
+ // | | | | x
+ // | | | | | z
+ // | 4----------|--7 | /
+ // | / | / |/
+ // |/ |/ ------y
+ // 0-------------3
+ */
+
+ float height = 0.1 + 1.5 * random() / INT_MAX;
+
+ m_index[0] = vec3u(7, 4, 0); // bottom
+ m_index[1] = vec3u(0, 3, 7); // bottom
+ m_index[2] = vec3u(3, 2, 6); // right
+ m_index[3] = vec3u(6, 7, 3); // right
+ m_index[4] = vec3u(7, 6, 5); // back
+ m_index[5] = vec3u(5, 4, 7); // back
+ m_index[6] = vec3u(4, 5, 1); // left
+ m_index[7] = vec3u(1, 0, 4); // left
+ m_index[8] = vec3u(5, 6, 2); // top
+ m_index[9] = vec3u(2, 1, 5); // top
+ m_index[10] = vec3u(0, 1, 2); // front
+ m_index[11] = vec3u(2, 3, 0); // front
+
+
+ m_vertex[0].x = 0.0f; m_vertex[0].y = 0.0f; m_vertex[0].z = 1.0f;
+ m_vertex[1].x = 1.0f; m_vertex[1].y = 0.0f; m_vertex[1].z = 1.0f;
+ m_vertex[2].x = 1.0f; m_vertex[2].y = height; m_vertex[2].z = 1.0f;
+ m_vertex[3].x = 0.0f; m_vertex[3].y = height; m_vertex[3].z = 1.0f;
+ m_vertex[4].x = 0.0f; m_vertex[4].y = 0.0f; m_vertex[4].z = 0.0f;
+ m_vertex[5].x = 1.0f; m_vertex[5].y = 0.0f; m_vertex[5].z = 0.0f;
+ m_vertex[6].x = 1.0f; m_vertex[6].y = height; m_vertex[6].z = 0.0f;
+ m_vertex[7].x = 0.0f; m_vertex[7].y = height; m_vertex[7].z = 0.0f;
+}
+
+House::~House()
+{
+}
+
+void House::render()
+{
+ m_pShader->use(&m_position, &m_color);
+
+ // draw
+ glEnableVertexAttribArray(0);
+ glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, m_vertex);
+ glDrawElements(GL_TRIANGLES, 3 * sizeof(m_index)/sizeof(m_index[0]), GL_UNSIGNED_SHORT, m_index);
+}
+
+void House::update(int currentTimeInMs, int lastFrameTime)
+{
+ (void)currentTimeInMs; //prevent warning
+
+ m_position.z += 0.0005f * (GLfloat)lastFrameTime;
+
+ if (m_position.z > 3.0)
+ {
+ m_position.z -= 15.0 * 2.0 * 1.0;
+ }
+}
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2010,2011 BMW Car IT GmbH
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#include "MockNavi.h"
+
+#include "House.h"
+#include "Street.h"
+#include "Ground.h"
+#include "Car.h"
+#include "ShaderLighting.h"
+
+#include <stdlib.h>
+#include <limits.h>
+
+#define CITY_GRID_SIZE 1.0f
+
+MockNavi::MockNavi(float fps, float animationSpeed, SurfaceConfiguration* config)
+: OpenGLES2App(fps, animationSpeed, config)
+, m_camera(vec3f(-1.5 * CITY_GRID_SIZE, -0.1, 0.0), vec3f(0.0, 0.0, 0.0), config->surfaceWidth, config->surfaceHeight)
+, m_houseCount(15)
+{
+ generateCity();
+}
+
+void MockNavi::update(int currentTimeInMs, int lastFrameTime)
+{
+ m_camera.update(currentTimeInMs, lastFrameTime);
+
+ list<IUpdateable*>::const_iterator iter = m_updateList.begin();
+ list<IUpdateable*>::const_iterator iterEnd = m_updateList.end();
+
+ for (; iter != iterEnd; ++iter)
+ {
+ (*iter)->update(currentTimeInMs, lastFrameTime);
+ }
+}
+
+void MockNavi::render()
+{
+ list<IRenderable*>::const_iterator iter = m_renderList.begin();
+ list<IRenderable*>::const_iterator iterEnd = m_renderList.end();
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ for (; iter != iterEnd; ++iter)
+ {
+ (*iter)->render();
+ }
+}
+
+void MockNavi::generateCity()
+{
+ IlmMatrix* projection = m_camera.getViewProjectionMatrix();
+ ShaderLighting* pShader = new ShaderLighting(projection);
+
+ // generate base plate
+ vec4f groundColor(0.8, 0.8, 0.6, 1.0);
+ vec3f position = vec3f(0.0, -0.001, 0.0);
+ vec3f size = vec3f(CITY_GRID_SIZE * 3, 0.0, -CITY_GRID_SIZE * 2.0 * m_houseCount);
+ Ground* ground = new Ground(position, size, groundColor, pShader);
+ m_renderList.push_back(ground);
+
+ // generate street z direction
+ vec4f streetColor(0.0, 0.0, 0.0, 1.0);
+ vec3f streetPosition = vec3f(0.6 * CITY_GRID_SIZE, 0.0, 0.0);
+ vec3f streetSize = vec3f(CITY_GRID_SIZE * 0.6, 0.0, -CITY_GRID_SIZE * 2.0 * m_houseCount);
+ Street* obj = new Street(streetPosition, streetSize, streetColor, pShader);
+ m_renderList.push_back(obj);
+
+ // generate streets x direction
+ for (int z = 1; z < m_houseCount; ++z)
+ {
+ vec4f streetColor(0.0, 0.0, 0.0, 1.0);
+ vec3f streetPosition = vec3f(0.0, 0.0, 0.6 - z * CITY_GRID_SIZE);
+ vec3f streetSize = vec3f(CITY_GRID_SIZE * 3, 0.0, CITY_GRID_SIZE * 0.6);
+ Street* obj = new Street(streetPosition, streetSize, streetColor, pShader);
+ m_renderList.push_back(obj);
+ m_updateList.push_back(obj);
+ }
+
+ // generate car
+ vec3f carPosition(1.4 * CITY_GRID_SIZE, 0.001, -0.3);
+ vec3f carSize(0.2f, 0.2f, 0.3f);
+ vec4f carColor(0.7, 0.3, 0.3, 1.0);
+ Car* car = new Car(carPosition, carSize, carColor, pShader);
+ m_renderList.push_back(car);
+
+ // generate houses
+ vec4f houseColor(0.6, 0.6, 0.8, 1.0);
+ for (int x = 0; x < 2; ++x)
+ {
+ for (int z = 0; z < m_houseCount; ++z)
+ {
+ float posx = x * 2.0 * CITY_GRID_SIZE;
+ float posy = 0.0;
+ float posz = -z * 2.0 * CITY_GRID_SIZE;
+
+ vec3f housePosition(posx, posy, posz);
+ vec3f houseSize(1.0, 1.0, 1.0);
+
+ House* obj = new House(housePosition, houseSize, houseColor, pShader);
+
+ m_renderList.push_back(obj);
+ m_updateList.push_back(obj);
+ }
+ }
+}
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2010, 2011 BMW Car IT GmbH
+ * Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#include "OpenGLES2App.h"
+#include "LayerScene.h"
+#include <ilm_client.h>
+
+#include <iostream>
+using std::cout;
+using std::endl;
+
+#include <stdlib.h>
+#include <math.h>
+#include <sys/time.h>
+
+#include <string.h>
+#include <stdbool.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+
+#include <stdint.h>
+#include <signal.h>
+#include <sys/stat.h>
+#include <linux/fb.h>
+
+#include "WaylandServerinfoClientProtocol.h"
+
+extern "C"
+{
+ void OpenGLES2App::serverinfoListener(void *data, struct serverinfo *pServerinfo, uint32_t client_handle)
+ {
+ pServerinfo = pServerinfo; // TODO:to avoid warning
+ WLContextStruct* p_wlCtx = (WLContextStruct*)data;
+ p_wlCtx->connect_id = client_handle;
+ }
+
+ struct serverinfo_listener serverinfo_listener_list = {
+ OpenGLES2App::serverinfoListener
+ };
+
+ void OpenGLES2App::display_handle_global(struct wl_display* display, uint32_t id, const char* interface, uint32_t version, void* data)
+ {
+ version = version; // TODO:to avoid warning
+ WLContextStruct* p_wlCtx = (WLContextStruct*)data;
+ int ans_strcmp = 0;
+
+ do
+ {
+ ans_strcmp = strcmp(interface, "wl_compositor");
+ if (0 == ans_strcmp)
+ {
+ p_wlCtx->wlCompositor = (wl_compositor*)wl_display_bind(display, id, &wl_compositor_interface);
+ break;
+ }
+
+ ans_strcmp = strcmp(interface, "tunneler");
+ if (0 == ans_strcmp)
+ {
+ p_wlCtx->wlExtServerinfo = (struct serverinfo*)wl_display_bind(display, id, &serverinfo_interface);
+ serverinfo_add_listener(p_wlCtx->wlExtServerinfo, &serverinfo_listener_list, data);
+ serverinfo_get_connection_id(p_wlCtx->wlExtServerinfo);
+ }
+ } while(0);
+ }
+
+ int OpenGLES2App::event_mask_update(uint32_t mask, void* data)
+ {
+ WLContextStruct* p_wlCtx = (WLContextStruct*)data;
+ p_wlCtx->mask = mask;
+ return 0;
+ }
+}
+
+#define RUNTIME_IN_MS() (GetTickCount() - startTimeInMS)
+
+
+OpenGLES2App::OpenGLES2App(float fps, float animationSpeed, SurfaceConfiguration* config)
+: m_framesPerSecond(fps)
+, m_animationSpeed(animationSpeed)
+, m_timerIntervalInMs(1000.0 / m_framesPerSecond)
+{
+ ilm_init();
+ createWLContext(config);
+ createEGLContext();
+ setupLayerMangement(config);
+
+ //glClearColor(0.2f, 0.2f, 0.5f, 1.0f);
+ glClearColor(0.2f, 0.2f, 0.5f, 1.0f);
+ glDisable(GL_BLEND);
+
+ glClearDepthf(1.0f);
+ glDisable(GL_CULL_FACE);
+ glEnable(GL_DEPTH_TEST);
+ glDepthFunc(GL_LEQUAL);
+}
+
+OpenGLES2App::~OpenGLES2App()
+{
+ destroyEglContext();
+ destroyWLContext();
+ ilm_destroy();
+}
+
+void OpenGLES2App::mainloop()
+{
+ unsigned int startTimeInMS = GetTickCount();
+ unsigned int frameStartTimeInMS = 0;
+ unsigned int renderTimeInMS = 0;
+ unsigned int frameEndTimeInMS = 0;
+ unsigned int frameTimeInMS = 0;
+
+ while (true)
+ {
+ frameTimeInMS = frameEndTimeInMS - frameStartTimeInMS;
+ frameStartTimeInMS = RUNTIME_IN_MS();
+
+ update(m_animationSpeed * frameStartTimeInMS, m_animationSpeed * frameTimeInMS);
+ render();
+ swapBuffers();
+
+ renderTimeInMS = RUNTIME_IN_MS() - frameStartTimeInMS;
+
+ if (renderTimeInMS < m_timerIntervalInMs)
+ {
+ usleep((m_timerIntervalInMs - renderTimeInMS) * 1000);
+ }
+
+ frameEndTimeInMS = RUNTIME_IN_MS();
+ }
+}
+
+bool OpenGLES2App::createWLContext(SurfaceConfiguration* config)
+{
+ t_ilm_bool result = ILM_TRUE;
+ int width = config->surfaceWidth;
+ int height = config->surfaceHeight;
+
+ memset(&m_wlContextStruct, 0, sizeof(m_wlContextStruct));
+
+ m_wlContextStruct.width = width;
+ m_wlContextStruct.height = height;
+ m_wlContextStruct.wlDisplay = wl_display_connect(NULL);
+ if (NULL == m_wlContextStruct.wlDisplay)
+ {
+ cout<<"Error: wl_display_connect() failed.\n";
+ }
+
+ wl_display_add_global_listener(m_wlContextStruct.wlDisplay, display_handle_global, &m_wlContextStruct);
+ wl_display_get_fd(m_wlContextStruct.wlDisplay, event_mask_update, &m_wlContextStruct);
+ wl_display_iterate(m_wlContextStruct.wlDisplay, WL_DISPLAY_READABLE);
+ wl_display_roundtrip(m_wlContextStruct.wlDisplay);
+
+ m_wlContextStruct.wlSurface = wl_compositor_create_surface(m_wlContextStruct.wlCompositor);
+ if (NULL == m_wlContextStruct.wlSurface)
+ {
+ cout<<"Error: wl_compositor_create_surface() failed.\n";
+ destroyWLContext();
+ }
+
+ m_wlContextStruct.wlNativeWindow = wl_egl_window_create(m_wlContextStruct.wlSurface, width, height);
+ if (NULL == m_wlContextStruct.wlNativeWindow)
+ {
+ cout<<"Error: wl_egl_window_create() failed"<<endl;
+ destroyWLContext();
+ }
+
+ return result;
+}
+
+bool OpenGLES2App::createEGLContext()
+{
+ t_ilm_bool result = ILM_TRUE;
+ EGLint eglstatus = EGL_SUCCESS;
+ m_eglContextStruct.eglDisplay = NULL;
+ m_eglContextStruct.eglSurface = NULL;
+ m_eglContextStruct.eglContext = NULL;
+
+ m_eglContextStruct.eglDisplay = eglGetDisplay(m_wlContextStruct.wlDisplay);
+ eglstatus = eglGetError();
+ if (!m_eglContextStruct.eglDisplay)
+ {
+ cout << "Error: eglGetDisplay() failed.\n";
+ }
+
+ EGLint iMajorVersion, iMinorVersion;
+ if (!eglInitialize(m_eglContextStruct.eglDisplay, &iMajorVersion,
+ &iMinorVersion))
+ {
+ cout << "Error: eglInitialize() failed.\n";
+ }
+
+ eglBindAPI(EGL_OPENGL_ES_API);
+ eglstatus = eglGetError();
+ if (eglstatus != EGL_SUCCESS)
+ {
+ cout << "Error: eglBindAPI() failed.\n";
+ }
+ EGLint pi32ConfigAttribs[] = {
+ EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+ EGL_RED_SIZE, 8,
+ EGL_GREEN_SIZE, 8,
+ EGL_BLUE_SIZE, 8,
+ EGL_ALPHA_SIZE, 8,
+ EGL_DEPTH_SIZE, 24,
+ EGL_STENCIL_SIZE, 8,
+ EGL_NONE };
+
+ int iConfigs;
+
+ if (!eglChooseConfig(m_eglContextStruct.eglDisplay, pi32ConfigAttribs, &m_eglContextStruct.eglConfig, 1, &iConfigs) || (iConfigs != 1))
+ {
+ cout << "Error: eglChooseConfig() failed.\n";
+ }
+
+ m_eglContextStruct.eglSurface = eglCreateWindowSurface(
+ m_eglContextStruct.eglDisplay, m_eglContextStruct.eglConfig,
+ m_wlContextStruct.wlNativeWindow, NULL);
+ eglstatus = eglGetError();
+
+ if (eglstatus != EGL_SUCCESS)
+ {
+ cout << "Error: eglCreateWindowSurface() failed.\n";
+ }
+
+ EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
+
+ m_eglContextStruct.eglContext = eglCreateContext(
+ m_eglContextStruct.eglDisplay, m_eglContextStruct.eglConfig, NULL,
+ contextAttribs);
+
+ eglstatus = eglGetError();
+ if (eglstatus != EGL_SUCCESS)
+ {
+ cout << "Error: eglCreateContext() failed.\n";
+ }
+
+ eglMakeCurrent(m_eglContextStruct.eglDisplay,
+ m_eglContextStruct.eglSurface, m_eglContextStruct.eglSurface,
+ m_eglContextStruct.eglContext);
+ eglSwapInterval(m_eglContextStruct.eglDisplay, 1);
+ eglstatus = eglGetError();
+ if (eglstatus != EGL_SUCCESS)
+ {
+ cout << "Error: eglMakeCurrent() failed.\n";
+ }
+
+ return result;
+}
+
+bool OpenGLES2App::setupLayerMangement(SurfaceConfiguration* config)
+{
+ ilmErrorTypes error = ILM_FAILED;
+
+ // register surfaces to layermanager
+ t_ilm_layer layerid = (t_ilm_layer)config->layerId;//LAYER_EXAMPLE_GLES_APPLICATIONS;
+ t_ilm_surface surfaceid = (t_ilm_surface)config->surfaceId;//SURFACE_EXAMPLE_EGLX11_APPLICATION;
+ int width = config->surfaceWidth;
+ int height = config->surfaceHeight;
+
+ // TODO: auto generate surface id
+ cout << "creating surface " << surfaceid << "\n";
+ struct wl_object* p_obj = (struct wl_object*)m_wlContextStruct.wlSurface;
+ uint32_t native_ilm_handle = 0;
+ native_ilm_handle = (m_wlContextStruct.connect_id << 16) | (uint32_t)p_obj->id;
+ cout<<"create a surface 0x"<<(t_ilm_nativehandle) native_ilm_handle<<"\n";
+ error = ilm_surfaceCreate( (t_ilm_nativehandle) native_ilm_handle, width, height,
+ ILM_PIXELFORMAT_RGBA_8888, &surfaceid);
+
+ cout << "set surface " << surfaceid << " dest region " << 0 << ", " << 0 << ", " << width << ", " << height << "\n";
+ error = ilm_surfaceSetDestinationRectangle(surfaceid, 0, 0, width, height);
+
+ cout << "set surface " << surfaceid << " src region " << 0 << ", " << 0 << ", " << width << ", " << height << "\n";
+ error = ilm_surfaceSetSourceRectangle(surfaceid, 0, 0, width, height);
+
+ cout << "Set surface " << surfaceid << " visible\n";
+ error = ilm_surfaceSetVisibility(surfaceid, ILM_TRUE);
+
+ cout << "Set surface " << surfaceid << " opacity 0.7\n";
+ error = ilm_surfaceSetOpacity(surfaceid, 0.5f);
+
+ cout << "add surface " << surfaceid << " to layer " << layerid << "\n";
+ error = ilm_layerAddSurface(layerid, surfaceid);
+
+ cout << "commit\n";
+ error = ilm_commitChanges();
+
+ return ILM_TRUE;
+}
+
+void OpenGLES2App::destroyEglContext()
+{
+ if (m_eglContextStruct.eglDisplay != NULL)
+ {
+ eglMakeCurrent(m_eglContextStruct.eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+ eglTerminate(m_eglContextStruct.eglDisplay);
+ }
+}
+
+void OpenGLES2App::destroyWLContext()
+{
+ if (m_wlContextStruct.wlNativeWindow)
+ {
+ wl_egl_window_destroy(m_wlContextStruct.wlNativeWindow);
+ }
+ if (m_wlContextStruct.wlSurface)
+ {
+ wl_surface_destroy(m_wlContextStruct.wlSurface);
+ }
+ if (m_wlContextStruct.wlCompositor)
+ {
+ wl_compositor_destroy(m_wlContextStruct.wlCompositor);
+ }
+}
+
+unsigned int OpenGLES2App::GetTickCount()
+{
+ struct timeval ts;
+ gettimeofday(&ts, 0);
+ return (t_ilm_uint) (ts.tv_sec * 1000 + (ts.tv_usec / 1000));
+}
+
+extern "C" void
+OpenGLES2App::frame_listener_func(void *data, struct wl_callback *callback, uint32_t time)
+{
+ data = data; // TODO:to avoid warning
+ time = time; // TODO:to avoid warning
+ if (callback)
+ {
+ wl_callback_destroy(callback);
+ }
+}
+
+static const struct wl_callback_listener frame_listener = {
+ OpenGLES2App::frame_listener_func
+};
+
+void OpenGLES2App::swapBuffers()
+{
+ eglSwapBuffers(m_eglContextStruct.eglDisplay, m_eglContextStruct.eglSurface);
+
+ struct wl_callback* callback = wl_surface_frame(m_wlContextStruct.wlSurface);
+ wl_callback_add_listener(callback, &frame_listener, NULL);
+ wl_display_flush(m_wlContextStruct.wlDisplay);
+}
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2010,2011 BMW Car IT GmbH
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#include "ShaderBase.h"
+#include "IlmMatrix.h"
+#include <ilm_client.h>
+#include <GLES2/gl2.h>
+#include <stdlib.h>
+#include <iostream>
+using std::cout;
+
+ShaderBase::ShaderBase(string vertexCode, string fragmentCode, IlmMatrix* projectionMatrix)
+: m_vertexCode()
+, m_fragmentCode(fragmentCode)
+, m_projectionMatrix(projectionMatrix)
+{
+ m_vertexCode = "uniform mediump mat4 u_projectionMatrix;\n";
+ m_vertexCode += vertexCode;
+ initShader();
+}
+
+ShaderBase::~ShaderBase()
+{
+ destroyShader();
+}
+
+bool ShaderBase::initShader()
+{
+ t_ilm_bool result = ILM_TRUE;
+
+ // Create the fragment shader object
+ fragmentShaderId = glCreateShader(GL_FRAGMENT_SHADER);
+
+ // Load Fragment Source
+ const char* fragmentShaderCode = m_fragmentCode.c_str();
+ glShaderSource(fragmentShaderId, 1, &fragmentShaderCode, NULL);
+
+ // Compile the source code of fragment shader
+ glCompileShader(fragmentShaderId);
+
+ glGetShaderiv(fragmentShaderId, GL_COMPILE_STATUS, (GLint*) &result);
+
+ if (!result)
+ {
+ t_ilm_int infoLength, numberChars;
+ glGetShaderiv(fragmentShaderId, GL_INFO_LOG_LENGTH, &infoLength);
+
+ // Allocate Log Space
+ char* info = (char*) malloc(sizeof(char) * infoLength);
+ glGetShaderInfoLog(fragmentShaderId, infoLength, &numberChars, info);
+
+ // Print the error
+ cout << "Failed to compile fragment shader: " << info << "\n";
+ free(info);
+ return ILM_FALSE;
+ }
+
+ // Create the fragment shader object
+ vertexShaderId = glCreateShader(GL_VERTEX_SHADER);
+
+ // Load Fragment Source
+ const char* vertexShaderCode = m_vertexCode.c_str();
+ glShaderSource(vertexShaderId, 1, &vertexShaderCode, NULL);
+
+ // Compile the source code of fragment shader
+ glCompileShader(vertexShaderId);
+
+ glGetShaderiv(vertexShaderId, GL_COMPILE_STATUS, (GLint*) &result);
+
+ if (!result)
+ {
+ t_ilm_int infoLength, numberChars;
+ glGetShaderiv(vertexShaderId, GL_INFO_LOG_LENGTH, &infoLength);
+
+ // Allocate Log Space
+ char* info = (char*) malloc(sizeof(char) * infoLength);
+ glGetShaderInfoLog(vertexShaderId, infoLength, &numberChars, info);
+
+ // Print the error
+ cout << "Failed to compile vertex shader: " << info << "\n";
+ free(info);
+ return ILM_FALSE;
+ }
+
+ shaderProgramId = glCreateProgram();
+
+ glAttachShader(shaderProgramId, fragmentShaderId);
+ glAttachShader(shaderProgramId, vertexShaderId);
+
+ glBindAttribLocation(shaderProgramId, 0, "a_vertex");
+
+ glLinkProgram(shaderProgramId);
+
+ glGetProgramiv(shaderProgramId, GL_LINK_STATUS, (GLint*) &result);
+
+ if (!result)
+ {
+ t_ilm_int infoLength, numberChars;
+ glGetShaderiv(shaderProgramId, GL_INFO_LOG_LENGTH, &infoLength);
+
+ // Allocate Log Space
+ char* info = (char*) malloc(sizeof(char) * infoLength);
+ glGetShaderInfoLog(shaderProgramId, infoLength, &numberChars,
+ info);
+
+ // Print the error
+ cout << "Failed to link program: " << info << "\n";
+ free(info);
+ return ILM_FALSE;
+ }
+
+#if 1 /* ADIT */
+ glValidateProgram(shaderProgramId);
+
+ glGetProgramiv(shaderProgramId, GL_VALIDATE_STATUS, (GLint*) &result);
+
+ if (!result)
+ {
+ t_ilm_int infoLength, numberChars;
+ glGetShaderiv(shaderProgramId, GL_INFO_LOG_LENGTH, &infoLength);
+
+ // Allocate Log Space
+ char* info = (char*) malloc(sizeof(char) * infoLength);
+ glGetShaderInfoLog(shaderProgramId, infoLength, &numberChars,
+ info);
+
+ // Print the error
+ cout << "Failed to validate program: " << info << "\n";
+ free(info);
+ return ILM_FALSE;
+ }
+
+#endif /* ADIT */
+
+ glUseProgram(shaderProgramId);
+
+ m_uniformProjectionMatrix = glGetUniformLocation(shaderProgramId, "u_projectionMatrix");
+
+ if (result)
+ {
+ cout << "Shader setup complete.\n";
+ }
+ else
+ {
+ cout << "Shader setup failed.\n";
+ }
+
+ return result;
+}
+
+bool ShaderBase::destroyShader()
+{
+ t_ilm_bool result = ILM_TRUE;
+ glDeleteProgram(shaderProgramId);
+ glDeleteShader(fragmentShaderId);
+ glDeleteShader(vertexShaderId);
+ return result;
+}
+
+void ShaderBase::use(vec3f* position, vec4f* color)
+{
+ (void)position; // prevent warning
+ (void)color; // prevent warning
+
+ glUseProgram(shaderProgramId);
+ glUniformMatrix4fv(m_uniformProjectionMatrix, 1, GL_FALSE, m_projectionMatrix->f);
+}
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2010,2011 BMW Car IT GmbH
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#include "ShaderLighting.h"
+#include "IlmMatrix.h"
+
+const char* vertexShaderCode =
+ "attribute mediump vec4 a_vertex; \
+ uniform mediump mat4 u_modelMatrix; \
+ varying mediump vec4 v_normal; \
+ void main(void) \
+ { \
+ gl_Position = u_projectionMatrix * u_modelMatrix * a_vertex; \
+ v_normal = normalize(a_vertex); \
+ }";
+
+const char* fragmentShaderCode =
+ "uniform mediump vec4 u_color; \
+ varying mediump vec4 v_normal; \
+ mediump vec4 lightPosition; \
+ void main (void) \
+ { \
+ lightPosition = normalize(vec4(-3.0, -5.0, 10.0, 1.0)); \
+ gl_FragColor = max(dot(v_normal, lightPosition), 0.0) * 0.5 * u_color + 0.8 * u_color; \
+ gl_FragColor.a = 1.0; \
+ }";
+
+ShaderLighting::ShaderLighting(IlmMatrix* projectionMatrix)
+: ShaderBase(vertexShaderCode, fragmentShaderCode, projectionMatrix)
+{
+ glUseProgram(shaderProgramId);
+ m_uniformModelMatrix = glGetUniformLocation(shaderProgramId, "u_modelMatrix");
+ m_uniformColor = glGetUniformLocation(shaderProgramId, "u_color");
+}
+
+ShaderLighting::~ShaderLighting()
+{
+}
+
+void ShaderLighting::use(vec3f* position, vec4f* color)
+{
+ ShaderBase::use(position, color);
+
+ IlmMatrix translation;
+ IlmMatrixTranslation(translation, position->x, position->y, position->z);
+
+ glUseProgram(shaderProgramId);
+ glUniformMatrix4fv(m_uniformModelMatrix, 1, GL_FALSE, translation.f);
+ glUniform4fv(m_uniformColor, 1, &color->r);
+
+}
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2010,2011 BMW Car IT GmbH
+ * Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#include "Street.h"
+#include "IlmMatrix.h"
+#include "ShaderBase.h"
+
+#include <string.h>
+
+#include <iostream>
+using std::cout;
+using std::endl;
+
+#include <GLES2/gl2.h>
+
+
+Street::Street(vec3f position, vec3f size, vec4f color, ShaderBase* shader)
+: m_position(position)
+, m_size(size)
+, m_color(color)
+, m_shader(shader)
+{
+ m_index[0] = vec3u(0, 3, 2);
+ m_index[1] = vec3u(2, 1, 0);
+
+ // y z
+ // 3-------------2 | /
+ // / / |/
+ // / / ------x
+ // 0-------------1
+
+ m_vertex[0].x = m_position.x;
+ m_vertex[0].y = m_position.y;
+ m_vertex[0].z = m_position.z;
+
+ m_vertex[1].x = m_position.x + m_size.x;
+ m_vertex[1].y = m_position.y;
+ m_vertex[1].z = m_position.z;
+
+ m_vertex[2].x = m_position.x + m_size.x;
+ m_vertex[2].y = m_position.y;
+ m_vertex[2].z = m_position.z + m_size.z;
+
+ m_vertex[3].x = m_position.x;
+ m_vertex[3].y = m_position.y;
+ m_vertex[3].z = m_position.z + m_size.z;
+}
+
+void Street::render()
+{
+ m_shader->use(&m_position, &m_color);
+
+ // draw
+ glEnableVertexAttribArray(0);
+ glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, m_vertex);
+ glDrawElements(GL_TRIANGLES, 3 * sizeof(m_index)/sizeof(m_index[0]), GL_UNSIGNED_SHORT, m_index);
+}
+
+void Street::update(int currentTimeInMs, int lastFrameTime)
+{
+ (void)currentTimeInMs; //prevent warning
+ m_position.z += 0.0005 * lastFrameTime;
+
+ if (m_position.z > 3.0)
+ {
+ m_position.z -= 2 * 2.0;
+ }
+}
--- /dev/null
+/***************************************************************************
+*
+* Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
+*
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*
+* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*
+****************************************************************************/
+
+#include <stdlib.h>
+#include <stdint.h>
+#include "wayland-util.h"
+
+
+static const struct wl_interface *types[] = {
+ NULL,
+};
+
+static const struct wl_message serverinfo_requests[] = {
+ { "get_connection_id", "", types + 0 },
+};
+
+static const struct wl_message serverinfo_events[] = {
+ { "connection_id", "u", types + 0 },
+};
+
+extern "C" WL_EXPORT const struct wl_interface serverinfo_interface = {
+ "serverinfo", 1,
+ ARRAY_LENGTH(serverinfo_requests), serverinfo_requests,
+ ARRAY_LENGTH(serverinfo_events), serverinfo_events,
+};
+
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2010,2011 BMW Car IT GmbH
+ * Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#include "Argument.h"
+#include "MockNavi.h"
+#include "LayerScene.h"
+
+#include <iostream>
+using std::cout;
+
+#define DEFAULT_FPS 30.0
+#define DEFAULT_ANIM 1.0
+#define DEFAULT_LAYER LAYER_EXAMPLE_GLES_APPLICATIONS
+#define DEFAULT_SURFACE SURFACE_EXAMPLE_EGLX11_APPLICATION
+#define DEFAULT_WIDTH 800
+#define DEFAULT_HEIGHT 480
+
+int main (int argc, const char * argv[])
+{
+ FloatArgument fps("fps", DEFAULT_FPS, argc, argv);
+ FloatArgument animSpeed("anim", DEFAULT_ANIM, argc, argv);
+ UnsignedIntArgument surfaceId("surface", DEFAULT_SURFACE, argc, argv);
+ UnsignedIntArgument layerId("layer", DEFAULT_LAYER, argc, argv);
+ IntArgument width("width", DEFAULT_WIDTH, argc, argv);
+ IntArgument height("height", DEFAULT_HEIGHT, argc, argv);
+ BoolArgument help("help", false, argc, argv);
+
+ if (help.get())
+ {
+ cout << "\nUsage: " << argv[0] << " [options]\n"
+ << "possible options are:\n"
+ << " -help show this help text\n"
+ << " -fps x limit frames per second to x (default " << DEFAULT_FPS << ")\n"
+ << " -anim x set animation speed (default " << DEFAULT_ANIM << ")\n"
+ << " -surface x render to surface id x (default " << DEFAULT_SURFACE << ")\n"
+ << " -layer x add surface to layer x (default " << DEFAULT_LAYER << ")\n"
+ << " -width x set surface width to x (default " << DEFAULT_WIDTH << ")\n"
+ << " -height x set surface height to x (default " << DEFAULT_HEIGHT << ")\n\n";
+ }
+ else
+ {
+ SurfaceConfiguration config;
+ config.layerId = layerId.get();
+ config.surfaceId = surfaceId.get();
+ config.surfaceWidth = width.get();
+ config.surfaceHeight = height.get();
+
+ MockNavi navi(fps.get(), animSpeed.get(), &config);
+ navi.mainloop();
+ }
+
+ return 0;
+}
+