From: Nobuhiko Tanibata Date: Mon, 12 Mar 2012 07:36:28 +0000 (+0900) Subject: LayerManagerExamples: MockNavigation Example for Wayland plugins X-Git-Tag: ivi-layer-management_version_0_9_6~23 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6c82ec80b597e3e52e4d6cca84447380a0b9bae9;p=profile%2Fivi%2Flayer-management.git LayerManagerExamples: MockNavigation Example for Wayland plugins --- diff --git a/LayerManagerExamples/EGLWLMockNavigation/CMakeLists.txt b/LayerManagerExamples/EGLWLMockNavigation/CMakeLists.txt new file mode 100644 index 0000000..526c244 --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/CMakeLists.txt @@ -0,0 +1,97 @@ +############################################################################ +# +# 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) diff --git a/LayerManagerExamples/EGLWLMockNavigation/include/Argument.h b/LayerManagerExamples/EGLWLMockNavigation/include/Argument.h new file mode 100644 index 0000000..0bca6f5 --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/include/Argument.h @@ -0,0 +1,61 @@ +/*************************************************************************** + * + * 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 +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 diff --git a/LayerManagerExamples/EGLWLMockNavigation/include/Camera.h b/LayerManagerExamples/EGLWLMockNavigation/include/Camera.h new file mode 100644 index 0000000..5ec44cf --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/include/Camera.h @@ -0,0 +1,46 @@ +/*************************************************************************** + * + * 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 diff --git a/LayerManagerExamples/EGLWLMockNavigation/include/Car.h b/LayerManagerExamples/EGLWLMockNavigation/include/Car.h new file mode 100644 index 0000000..d495576 --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/include/Car.h @@ -0,0 +1,46 @@ +/*************************************************************************** + * + * 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 diff --git a/LayerManagerExamples/EGLWLMockNavigation/include/Ground.h b/LayerManagerExamples/EGLWLMockNavigation/include/Ground.h new file mode 100644 index 0000000..2cf5d6b --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/include/Ground.h @@ -0,0 +1,47 @@ +/*************************************************************************** + * + * 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 diff --git a/LayerManagerExamples/EGLWLMockNavigation/include/House.h b/LayerManagerExamples/EGLWLMockNavigation/include/House.h new file mode 100644 index 0000000..811a12c --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/include/House.h @@ -0,0 +1,54 @@ +/*************************************************************************** + * + * 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 diff --git a/LayerManagerExamples/EGLWLMockNavigation/include/IRenderable.h b/LayerManagerExamples/EGLWLMockNavigation/include/IRenderable.h new file mode 100644 index 0000000..0db7d63 --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/include/IRenderable.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * + * 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 diff --git a/LayerManagerExamples/EGLWLMockNavigation/include/IUpdateable.h b/LayerManagerExamples/EGLWLMockNavigation/include/IUpdateable.h new file mode 100644 index 0000000..ad2df52 --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/include/IUpdateable.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * + * 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 diff --git a/LayerManagerExamples/EGLWLMockNavigation/include/MockNavi.h b/LayerManagerExamples/EGLWLMockNavigation/include/MockNavi.h new file mode 100644 index 0000000..30f9324 --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/include/MockNavi.h @@ -0,0 +1,51 @@ +/*************************************************************************** + * + * 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 +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 m_renderList; + list m_updateList; +}; + +#endif diff --git a/LayerManagerExamples/EGLWLMockNavigation/include/OpenGLES2App.h b/LayerManagerExamples/EGLWLMockNavigation/include/OpenGLES2App.h new file mode 100644 index 0000000..ef71c7a --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/include/OpenGLES2App.h @@ -0,0 +1,101 @@ +/*************************************************************************** + * + * 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 + +#include "ilm_client.h" +#include + +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 diff --git a/LayerManagerExamples/EGLWLMockNavigation/include/ShaderBase.h b/LayerManagerExamples/EGLWLMockNavigation/include/ShaderBase.h new file mode 100644 index 0000000..cc4878b --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/include/ShaderBase.h @@ -0,0 +1,54 @@ +/*************************************************************************** + * + * 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 +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__ diff --git a/LayerManagerExamples/EGLWLMockNavigation/include/ShaderLighting.h b/LayerManagerExamples/EGLWLMockNavigation/include/ShaderLighting.h new file mode 100644 index 0000000..c4bef2a --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/include/ShaderLighting.h @@ -0,0 +1,38 @@ +/*************************************************************************** + * + * 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_ */ diff --git a/LayerManagerExamples/EGLWLMockNavigation/include/Street.h b/LayerManagerExamples/EGLWLMockNavigation/include/Street.h new file mode 100644 index 0000000..40d54bd --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/include/Street.h @@ -0,0 +1,48 @@ +/*************************************************************************** + * + * 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 diff --git a/LayerManagerExamples/EGLWLMockNavigation/include/WaylandServerinfoClientProtocol.h b/LayerManagerExamples/EGLWLMockNavigation/include/WaylandServerinfoClientProtocol.h new file mode 100644 index 0000000..94ce7af --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/include/WaylandServerinfoClientProtocol.h @@ -0,0 +1,92 @@ +/*************************************************************************** +* +* 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 +#include +#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 diff --git a/LayerManagerExamples/EGLWLMockNavigation/include/vec.h b/LayerManagerExamples/EGLWLMockNavigation/include/vec.h new file mode 100644 index 0000000..b1327e8 --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/include/vec.h @@ -0,0 +1,125 @@ +/*************************************************************************** + * + * 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 + +template +class vec2 +{ +public: + vec2() + { + } + + vec2(T _x, T _y) + : x(_x) + , y(_y) + { + } + + struct + { + T x; + T y; + }; +}; + +template +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 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 vec2f; +typedef vec2 vec2i; +typedef vec2 vec2u; + +typedef vec3 vec3f; +typedef vec3 vec3i; +typedef vec3 vec3u; + +typedef vec4 vec4f; +typedef vec4 vec4i; +typedef vec4 vec4u; + +#endif diff --git a/LayerManagerExamples/EGLWLMockNavigation/src/Argument.cpp b/LayerManagerExamples/EGLWLMockNavigation/src/Argument.cpp new file mode 100644 index 0000000..f3cbea0 --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/src/Argument.cpp @@ -0,0 +1,118 @@ +/*************************************************************************** + * + * 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 +#include + +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; +} diff --git a/LayerManagerExamples/EGLWLMockNavigation/src/Camera.cpp b/LayerManagerExamples/EGLWLMockNavigation/src/Camera.cpp new file mode 100644 index 0000000..3ba753c --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/src/Camera.cpp @@ -0,0 +1,62 @@ +/*************************************************************************** + * + * 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 + +#include +#include + +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); +} + diff --git a/LayerManagerExamples/EGLWLMockNavigation/src/Car.cpp b/LayerManagerExamples/EGLWLMockNavigation/src/Car.cpp new file mode 100644 index 0000000..1b4a164 --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/src/Car.cpp @@ -0,0 +1,60 @@ +/*************************************************************************** + * + * 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 + +#include +using std::cout; +using std::endl; + +#include + + +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); +} + diff --git a/LayerManagerExamples/EGLWLMockNavigation/src/Ground.cpp b/LayerManagerExamples/EGLWLMockNavigation/src/Ground.cpp new file mode 100644 index 0000000..a9d3d0b --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/src/Ground.cpp @@ -0,0 +1,74 @@ +/*************************************************************************** + * + * 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 + +#include +using std::cout; +using std::endl; + +#include + + +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); +} + diff --git a/LayerManagerExamples/EGLWLMockNavigation/src/House.cpp b/LayerManagerExamples/EGLWLMockNavigation/src/House.cpp new file mode 100644 index 0000000..91dbba2 --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/src/House.cpp @@ -0,0 +1,105 @@ +/*************************************************************************** + * + * 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 +#include +#include +#include + +#include +using std::cout; +using std::endl; + +#include + +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; + } +} diff --git a/LayerManagerExamples/EGLWLMockNavigation/src/MockNavi.cpp b/LayerManagerExamples/EGLWLMockNavigation/src/MockNavi.cpp new file mode 100644 index 0000000..9c3e7e8 --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/src/MockNavi.cpp @@ -0,0 +1,122 @@ +/*************************************************************************** + * + * 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 +#include + +#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::const_iterator iter = m_updateList.begin(); + list::const_iterator iterEnd = m_updateList.end(); + + for (; iter != iterEnd; ++iter) + { + (*iter)->update(currentTimeInMs, lastFrameTime); + } +} + +void MockNavi::render() +{ + list::const_iterator iter = m_renderList.begin(); + list::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); + } + } +} diff --git a/LayerManagerExamples/EGLWLMockNavigation/src/OpenGLES2App.cpp b/LayerManagerExamples/EGLWLMockNavigation/src/OpenGLES2App.cpp new file mode 100644 index 0000000..8a917b0 --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/src/OpenGLES2App.cpp @@ -0,0 +1,366 @@ +/*************************************************************************** + * + * 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 + +#include +using std::cout; +using std::endl; + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#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"<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); +} diff --git a/LayerManagerExamples/EGLWLMockNavigation/src/ShaderBase.cpp b/LayerManagerExamples/EGLWLMockNavigation/src/ShaderBase.cpp new file mode 100644 index 0000000..48bd485 --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/src/ShaderBase.cpp @@ -0,0 +1,182 @@ +/*************************************************************************** + * + * 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 +#include +#include +#include +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); +} diff --git a/LayerManagerExamples/EGLWLMockNavigation/src/ShaderLighting.cpp b/LayerManagerExamples/EGLWLMockNavigation/src/ShaderLighting.cpp new file mode 100644 index 0000000..94e49a8 --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/src/ShaderLighting.cpp @@ -0,0 +1,66 @@ +/*************************************************************************** + * + * 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); + +} diff --git a/LayerManagerExamples/EGLWLMockNavigation/src/Street.cpp b/LayerManagerExamples/EGLWLMockNavigation/src/Street.cpp new file mode 100644 index 0000000..286a359 --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/src/Street.cpp @@ -0,0 +1,84 @@ +/*************************************************************************** + * + * 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 + +#include +using std::cout; +using std::endl; + +#include + + +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; + } +} diff --git a/LayerManagerExamples/EGLWLMockNavigation/src/WaylandServerinfoProtocol.cpp b/LayerManagerExamples/EGLWLMockNavigation/src/WaylandServerinfoProtocol.cpp new file mode 100644 index 0000000..86f4aaf --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/src/WaylandServerinfoProtocol.cpp @@ -0,0 +1,51 @@ +/*************************************************************************** +* +* 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 +#include +#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, +}; + diff --git a/LayerManagerExamples/EGLWLMockNavigation/src/main.cpp b/LayerManagerExamples/EGLWLMockNavigation/src/main.cpp new file mode 100644 index 0000000..8ecf192 --- /dev/null +++ b/LayerManagerExamples/EGLWLMockNavigation/src/main.cpp @@ -0,0 +1,70 @@ +/*************************************************************************** + * + * 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 +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; +} +