Commits

Christian Fischer  committed cdecaa0

renamed common library into core

  • Participants
  • Parent commits 2e3e66b

Comments (0)

Files changed (202)

File libraries/desktop/wiesel-common/module.cmake

-# wiesel-common library
-
-
-# collect all files which belongs to this library
-wiesel_create_module(wiesel-common ${WIESEL_SRC_DIR}/common ${WIESEL_TESTS_DIR}/common)
-
-# export include directories of this library for other targets
-wiesel_module_export_includes(wiesel-common ${WIESEL_SRC_DIR}/common)
-
-# add required modules
-wiesel_module_add_dependency(wiesel-common wiesel-base)
-wiesel_module_add_dependency(wiesel-common glee third-party/glee)
-
-
-
-# add libxml2 dependency
-include(FindLibXml2)
-
-if(DEFINED LIBXML2_FOUND)
-	wiesel_target_add_includes(wiesel-common ${LIBXML2_INCLUDE_DIR})
-	wiesel_target_add_libraries(wiesel-common ${LIBXML2_LIBRARIES})
-	wiesel_target_add_compileflags(wiesel-common ${LIBXML2_DEFINITIONS})
-else()
-	message(FATAL_ERROR "required library libxml2 not found!")
-endif()
-
-
-# add SDL dependency
-include(FindSDL)
-
-if(DEFINED SDL_FOUND)
-	wiesel_target_add_includes(wiesel-common ${SDL_INCLUDE_DIR})
-	wiesel_target_add_libraries(wiesel-common ${SDL_LIBRARY})
-	wiesel_target_add_compileflags(wiesel-common "-DWIESEL_USE_LIBSDL")
-else()
-	message(FATAL_ERROR "required library SDL not found!")
-endif()

File libraries/desktop/wiesel-core/module.cmake

+# wiesel-core library
+
+
+# collect all files which belongs to this library
+wiesel_create_module(wiesel-core ${WIESEL_SRC_DIR}/core ${WIESEL_TESTS_DIR}/core)
+
+# export include directories of this library for other targets
+wiesel_module_export_includes(wiesel-core ${WIESEL_SRC_DIR}/core)
+
+# add required modules
+wiesel_module_add_dependency(wiesel-core wiesel-base)
+wiesel_module_add_dependency(wiesel-core glee third-party/glee)
+
+
+
+# add libxml2 dependency
+include(FindLibXml2)
+
+if(DEFINED LIBXML2_FOUND)
+	wiesel_target_add_includes(wiesel-core ${LIBXML2_INCLUDE_DIR})
+	wiesel_target_add_libraries(wiesel-core ${LIBXML2_LIBRARIES})
+	wiesel_target_add_compileflags(wiesel-core ${LIBXML2_DEFINITIONS})
+else()
+	message(FATAL_ERROR "required library libxml2 not found!")
+endif()
+
+
+# add SDL dependency
+include(FindSDL)
+
+if(DEFINED SDL_FOUND)
+	wiesel_target_add_includes(wiesel-core ${SDL_INCLUDE_DIR})
+	wiesel_target_add_libraries(wiesel-core ${SDL_LIBRARY})
+	wiesel_target_add_compileflags(wiesel-core "-DWIESEL_USE_LIBSDL")
+else()
+	message(FATAL_ERROR "required library SDL not found!")
+endif()

File libraries/desktop/wiesel-sdl/module.cmake

 
 # add required modules
 wiesel_module_add_dependency(wiesel-sdl wiesel-base)
-wiesel_module_add_dependency(wiesel-sdl wiesel-common)
+wiesel_module_add_dependency(wiesel-sdl wiesel-core)
 #wiesel_module_add_dependency(wiesel-sdl glee third-party/glee)
 
 

File samples/HelloWiesel/CMakeLists.txt

 
 # add required libraries
 wiesel_module_add_dependency(HelloWiesel wiesel-base)
-wiesel_module_add_dependency(HelloWiesel wiesel-common)
+wiesel_module_add_dependency(HelloWiesel wiesel-core)
 wiesel_module_add_dependency(HelloWiesel wiesel-sdl)
 
 wiesel_target_add_compileflags(HelloWiesel "-DWIESEL_USE_LIBSDL")

File src/common/wiesel.h

-/**
- * Copyright (C) 2012
- * Christian Fischer
- *
- * https://bitbucket.org/baldur/wiesel/
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-#ifndef __WIESEL_H__
-#define __WIESEL_H__
-
-#include "wiesel/application.h"
-#include "wiesel/engine.h"
-
-// get the basic platform includes
-#include "wiesel/platform/platform_config.h"
-#include "wiesel/platform/platforms.h"
-
-// some useful default includes
-#include "wiesel/util/log.h"
-#include "wiesel/util/shared_object.h"
-
-// should be useful for most applications
-#include <assert.h>
-#include <inttypes.h>
-#include <stddef.h>
-
-#endif // __WIESEL_H__

File src/common/wiesel/application.cpp

-/**
- * Copyright (C) 2012
- * Christian Fischer
- *
- * https://bitbucket.org/baldur/wiesel/
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-#include "application.h"
-
-#include <algorithm>
-
-
-using namespace wiesel;
-
-
-Application::Application() {
-	return;
-}
-
-Application::~Application() {
-	clearSceneStack();
-	return;
-}
-
-
-
-
-void Application::onRun(float) {
-	return;
-}
-
-
-void Application::onRender() {
-	// draw all scenes
-	for(SceneList::iterator it=scene_stack.begin(); it!=scene_stack.end(); it++) {
-		(*it)->render();
-	}
-
-	return;
-}
-
-
-
-
-bool Application::pushScene(Scene *scene) {
-	SceneList::iterator it = std::find(scene_stack.begin(), scene_stack.end(), scene);
-	assert(it == scene_stack.end());
-	assert(scene);
-
-	if (scene && it == scene_stack.end()) {
-		scene_stack.push_back(scene);
-		scene->retain();
-
-		return true;
-	}
-
-	return false;
-}
-
-
-void Application::removeScene(Scene *scene) {
-	SceneList::iterator it = std::find(scene_stack.begin(), scene_stack.end(), scene);
-	if (it != scene_stack.end()) {
-		scene_stack.erase(it);
-		scene->release();
-	}
-
-	return;
-}
-
-
-void Application::clearSceneStack() {
-	for(SceneList::reverse_iterator it=scene_stack.rbegin(); it!=scene_stack.rend(); it++) {
-		(*it)->release();
-	}
-
-	scene_stack.clear();
-
-	return;
-}
-
-
-Scene *Application::getTopScene() {
-	if (scene_stack.empty()) {
-		return NULL;
-	}
-
-	return scene_stack.back();
-}
-

File src/common/wiesel/application.h

-/**
- * Copyright (C) 2012
- * Christian Fischer
- *
- * https://bitbucket.org/baldur/wiesel/
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-#ifndef __WIESEL_APPLICATION_H__
-#define __WIESEL_APPLICATION_H__
-
-#include <wiesel/wiesel-common.def>
-
-#include "graph/scene.h"
-#include <vector>
-
-
-namespace wiesel {
-
-
-	/**
-	 * @brief An abstract class implementing the application logic.
-	 */
-	class WIESEL_COMMON_EXPORT Application {
-	public:
-		Application();
-		virtual ~Application();
-
-		/**
-		 * @brief initialize the application before running.
-		 */
-		virtual bool onInit() = 0;
-
-		/**
-		 * @brief release contents before stopping the application.
-		 */
-		virtual void onShutdown() = 0;
-
-		/**
-		 * @brief notification when the application has lost focus and is no longer in the foreground.
-		 */
-		virtual void onEnterBackground() {}
-
-		/**
-		 * @brief notification when the application will enter the foreground and is active.
-		 */
-		virtual void onEnterForeground() {}
-
-		/**
-		 * @brief suspends the application, for example when the user switches to another task.
-		 */
-		virtual void onSuspend() {}
-
-		/**
-		 * @brief resume the application after beeing suspended.
-		 */
-		virtual void onResumeSuspended() {}
-
-		/**
-		 * @brief called each frame to process application data.
-		 * DUMMY - will be replaced by scene graph later.
-		 */
-		virtual void onRun(float dt);
-
-		/**
-		 * @brief called each frame to render graphics.
-		 * DUMMY - will be replaced by scene graph later.
-		 */
-		virtual void onRender();
-
-	// scene stack
-	public:
-		/**
-		 * @brief Push a new scene to the scene stack.
-		 * @return \c true, when the scene was added, \c false otherwise.
-		 */
-		bool pushScene(Scene *scene);
-
-		/**
-		 * @brief Removes a scene from the scene stack.
-		 */
-		void removeScene(Scene *scene);
-
-		/**
-		 * @brief removes all scenes from the scene stack.
-		 */
-		void clearSceneStack();
-
-		/**
-		 * @brief Get the topmost scene in the scene stack.
-		 * @return the topmost scene, or \c NULL, when the scene stack is empty.
-		 */
-		inline Scene *getTopScene();
-
-		/**
-		 * @brief Provides access to the scene stack.
-		 * @return A const-list of all scenes in the stack, which cannot be manipulated.
-		 */
-		inline const SceneList *getSceneStack() const {
-			return &scene_stack;
-		}
-
-	private:
-		SceneList		scene_stack;
-	};
-
-}
-
-#endif /* __WIESEL_APPLICATION_H__ */

File src/common/wiesel/application_main.h

-/**
- * Copyright (C) 2012
- * Christian Fischer
- *
- * https://bitbucket.org/baldur/wiesel/
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-#ifndef __WIESEL_APPLICATIONMAIN_H__
-#define __WIESEL_APPLICATIONMAIN_H__
-
-#include "../wiesel.h"
-
-// application class
-#include "application.h"
-
-// get all the platforms
-#include "platform/platforms.h"
-
-// check, if the entry-point macro exists.
-#if !defined(WIESEL_APPLICATION_SETUP)
-#error "WIESEL_APPLICATION_SETUP not defined - compiling on an unknown platform?"
-#endif
-
-#endif // __WIESEL_H__

File src/common/wiesel/engine.cpp

-/**
- * Copyright (C) 2012
- * Christian Fischer
- *
- * https://bitbucket.org/baldur/wiesel/
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-#include "engine.h"
-
-#include <wiesel/util/shared_object.h>
-#include <wiesel/util/log.h>
-
-#include <wiesel/ui/touchhandler.h>
-
-#include <assert.h>
-#include <stddef.h>
-#include <time.h>
-
-#include <algorithm>
-
-
-using namespace wiesel;
-
-
-Engine*				Engine::current_instance		= NULL;
-Application*		Engine::current_app				= NULL;
-bool				Engine::exit_requested			= false;
-
-
-Engine::Engine()
-: screen(NULL)
-{
-	state		= Engine_Uninitialized;
-	return;
-}
-
-Engine::~Engine() {
-	return;
-}
-
-
-bool Engine::install(Engine *engine) {
-	// if there's already an existing instance, the installation fails
-	assert(current_instance == NULL);
-	if (current_instance) {
-		return false;
-	}
-
-	// initialize the new engine
-	if (engine->onInit() == false) {
-		return false;
-	}
-
-	// store the new instance
-	current_instance = engine;
-
-	// success
-	return true;
-}
-
-
-bool Engine::shutdown() {
-	if (current_instance == NULL) {
-		return false;
-	}
-
-	// shutdown
-	current_instance->onShutdown();
-	delete current_instance;
-	current_instance = NULL;
-
-	// done
-	return true;
-}
-
-
-void Engine::run(Application *application) {
-	// no other application running
-	assert(current_app == NULL);
-	if (current_app) {
-		return;
-	}
-
-	// we need a valid application object to run
-	assert(application);
-	if (application == NULL) {
-		return;
-	}
-
-	// reset the exit_requested flag before starting the main loop
-	exit_requested = false;
-
-	// store the application object
-	current_app = application;
-
-	// first onRun before entering the main loop
-	current_instance->onRunFirst();
-
-	// timers
-	clock_t last_t = clock();
-	clock_t now_t;
-
-	bool done = false;
-	do {
-		done = current_instance->onRun();
-
-		// measure time of this frame
-		last_t = now_t;
-		now_t  = clock();
-		float dt = (float(now_t - last_t) / CLOCKS_PER_SEC);
-
-		// run all updateable objects
-		for(int i=current_instance->updateables.size(); --i>=0;) {
-			current_instance->updateables.at(i)->update(dt);
-		}
-
-		switch(current_instance->getState()) {
-			case Engine_Uninitialized: {
-				// do nothing
-				break;
-			}
-
-			case Engine_Suspended: {
-				// do nothing
-				break;
-			}
-
-			case Engine_Background: {
-				// do nothing
-				break;
-			}
-
-			case Engine_Running: {
-				// application onRun
-				current_app->onRun(dt);
-
-				Screen *screen = current_instance->getScreen();
-
-				if (screen) {
-					screen->preRender();
-					current_app->onRender();
-					screen->postRender();
-				}
-
-				break;
-			}
-		}
-
-		// purge all dead objects at the end of each frame
-		SharedObject::purgeDeadObjects();
-
-		// exit requested by application?
-		done |= exit_requested;
-	}
-	while(!done);
-
-	// release the current app
-	current_app->onShutdown();
-
-	// clear current application
-	current_app = NULL;
-
-	return;
-}
-
-
-void Engine::requestExit() {
-	exit_requested = true;
-	return;
-}
-
-
-void Engine::registerUpdateable(IUpdateable* updateable) {
-	std::vector<IUpdateable*>::iterator it = std::find(updateables.begin(), updateables.end(), updateable);
-	if (it == updateables.end()) {
-		updateables.push_back(updateable);
-		updateable->retain();
-	}
-
-	return;
-}
-
-
-void Engine::unregisterUpdateable(IUpdateable* updateable) {
-	std::vector<IUpdateable*>::iterator it = std::find(updateables.begin(), updateables.end(), updateable);
-	if (it != updateables.end()) {
-		updateables.erase(it);
-		updateable->release();
-	}
-
-	return;
-}
-
-
-
-
-
-void Engine::startApp() {
-	assert(current_instance != NULL);
-	assert(current_app != NULL);
-
-	switch(current_instance->getState()) {
-		case Engine_Uninitialized: {
-			if (current_app) {
-				current_app->onInit();
-			}
-
-			current_instance->state = Engine_Background;
-
-			break;
-		}
-
-		default: {
-			break;
-		}
-	}
-
-	return;
-}
-
-
-void Engine::enterBackground() {
-	assert(current_instance != NULL);
-	assert(current_app != NULL);
-
-	switch(current_instance->getState()) {
-		case Engine_Running: {
-			if (current_app != NULL) {
-				current_app->onEnterBackground();
-			}
-
-			current_instance->state = Engine_Background;
-
-			break;
-		}
-
-		default: {
-			break;
-		}
-	}
-
-	return;
-}
-
-
-void Engine::enterForeground() {
-	assert(current_instance != NULL);
-	assert(current_app != NULL);
-
-	switch(current_instance->getState()) {
-		case Engine_Background: {
-			if (current_app != NULL) {
-				current_app->onEnterForeground();
-			}
-
-			current_instance->state = Engine_Running;
-
-			break;
-		}
-
-		default: {
-			break;
-		}
-	}
-
-	return;
-}
-
-
-void Engine::suspendApp() {
-	assert(current_instance != NULL);
-	assert(current_app != NULL);
-
-	switch(current_instance->getState()) {
-		case Engine_Running: {
-			enterBackground();
-
-			// NOBR
-		}
-
-		case Engine_Background: {
-			if (current_app) {
-				current_app->onSuspend();
-			}
-
-			current_instance->state = Engine_Suspended;
-
-			break;
-		}
-
-		default: {
-			break;
-		}
-	}
-
-	return;
-}
-
-
-void Engine::resumeSuspendedApp() {
-	assert(current_instance != NULL);
-	assert(current_app != NULL);
-
-	switch(current_instance->getState()) {
-		case Engine_Suspended: {
-			if (current_app) {
-				current_app->onResumeSuspended();
-			}
-
-			current_instance->state = Engine_Background;
-
-			break;
-		}
-
-		default: {
-			break;
-		}
-	}
-
-	return;
-}

File src/common/wiesel/engine.h

-/**
- * Copyright (C) 2012
- * Christian Fischer
- *
- * https://bitbucket.org/baldur/wiesel/
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-#ifndef __WIESEL_ENGINE_H__
-#define __WIESEL_ENGINE_H__
-
-#include <wiesel/wiesel-common.def>
-
-#include "screen.h"
-#include "application.h"
-#include "engine_interfaces.h"
-
-#include <string>
-
-
-namespace wiesel {
-
-	// some external classes
-
-	class DataSource;
-	class FileSystem;
-	class TouchHandler;
-
-
-
-	/**
-	 * @brief manages the current state of the application.
-	 */
-	enum EngineState
-	{
-		Engine_Uninitialized,		//<! The initial state of the engine before initialization.
-		Engine_Running,				//<! The engine was initialized and is running.
-		Engine_Background,			//<! The engine is running in background
-		Engine_Suspended,			//<! The engine was suspended - no update or render calls will be invoked.
-	};
-
-
-
-	/**
-	 * @brief An interface to the game engine.
-	 */
-	class WIESEL_COMMON_EXPORT Engine {
-	protected:
-		Engine();
-		virtual ~Engine();
-
-	public:
-		/**
-		 * @brief get the currently active Engine instance.
-		 */
-		static Engine *getCurrent() {
-			return current_instance;
-		}
-
-		/**
-		 * @brief get the current running application or \c NULL, if none
-		 */
-		static Application *getApplication() {
-			return current_app;
-		}
-
-		/**
-		 * @brief Install a new Engine isntance, if currently no other instance is active.
-		 * @returns \c true, if the engine was installed successfully.
-		 * @returns \c false, if the installation process failed or another engine is already running.
-		 */
-		static bool install(Engine *engine);
-
-		/**
-		 * @brief terminate the currently registered engine.
-		 * Also terminates the currently runnung \ref Application instance.
-		 */
-		static bool shutdown();
-
-		/**
-		 * @brief starts the main loop with the currently installed engine.
-		 */
-		static WIESEL_COMMON_EXPORT void run(Application *application);
-
-		/**
-		 * @brief requests to stop the main loop after the current frame.
-		 */
-		static void requestExit();
-
-	// register/remove objects
-	public:
-		/**
-		 * @brief Registers an IUpdateable object to receive periodically updates.
-		 */
-		void registerUpdateable(IUpdateable *updateable);
-
-		/**
-		 * @brief Removes an IUpdateable object, so it will no longer receive updates.
-		 */
-		void unregisterUpdateable(IUpdateable *updateable);
-
-	// public methods
-	public:
-		/**
-		 * @brief get the engine's current state.
-		 */
-		inline EngineState getState() const {
-			return state;
-		}
-
-		/**
-		 * @brief checks, if the current instance is still the active \ref Engine instance.
-		 */
-		inline bool isActive() const {
-			return (this == current_instance);
-		}
-
-		/**
-		 * @brief get the screen object.
-		 */
-		inline Screen *getScreen() {
-			return screen;
-		}
-
-	// overridables
-	protected:
-		/**
-		 * @brief initialize the engine on installation process.
-		 */
-		virtual bool onInit() = 0;
-
-		/**
-		 * @brief clean up on shutdown.
-		 * The engine should release all resources here.
-		 */
-		virtual void onShutdown() = 0;
-
-		/**
-		 * @brief first update of the engine.
-		 * May be used to invoke \ref startApp, but can be left empty.
-		 */
-		virtual void onRunFirst() = 0;
-
-		/**
-		 * @brief called periodically by the main loop to process the message loop.
-		 * @return \c true to stop the main loop
-		 */
-		virtual bool onRun() = 0;
-
-	// application control
-	protected:
-		/**
-		 * @brief start the application, when application state is \ref Application_Uninitialized.
-		 * Fails, if no application is available.
-		 * In other states, this method will have no effect.
-		 */
-		static void startApp();
-
-		/**
-		 * @brief the application will enter the background.
-		 */
-		static void enterBackground();
-
-		/**
-		 * @brief the application will enter the foreground.
-		 */
-		static void enterForeground();
-
-		/**
-		 * @brief suspends a running application.
-		 * Fails, if no application is available.
-		 * In other states, this method will have no effect.
-		 */
-		static void suspendApp();
-
-		/**
-		 * @brief resumes a suspended application.
-		 * Fails, if no application is available.
-		 * In other states, this method will have no effect.
-		 * After resuming, the application is in the Background state.
-		 */
-		static void resumeSuspendedApp();
-
-	// filesystems
-	public:
-		/**
-		 * @brief get the system's root file system where all data is stored.
-		 * The root filesystem may be read-only or empty for the application.
-		 */
-		virtual FileSystem *getRootFileSystem() = 0;
-
-		/**
-		 * @brief get the file system, which stores the assets of the current application.
-		 */
-		virtual FileSystem *getAssetFileSystem() = 0;
-
-	// additional objects
-	public:
-		virtual TouchHandler *getTouchHandler() = 0;
-
-	// static members
-	private:
-		static WIESEL_COMMON_EXPORT Engine*			    current_instance;
-		static WIESEL_COMMON_EXPORT Application*		current_app;
-		static WIESEL_COMMON_EXPORT bool				exit_requested;
-
-	// instance members
-	protected:
-		Screen*		screen;
-
-	private:
-		std::vector<IUpdateable*>		updateables;
-
-		EngineState						state;
-	};
-
-}
-
-#endif /* __WIESEL_ENGINE_H__ */

File src/common/wiesel/engine_interfaces.cpp

-/**
- * Copyright (C) 2012
- * Christian Fischer
- *
- * https://bitbucket.org/baldur/wiesel/
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-#include "engine_interfaces.h"
-
-using namespace wiesel;
-
-
-IUpdateable::IUpdateable() {
-	return;
-}
-
-IUpdateable::~IUpdateable() {
-	return;
-}
-

File src/common/wiesel/engine_interfaces.h

-/**
- * Copyright (C) 2012
- * Christian Fischer
- *
- * https://bitbucket.org/baldur/wiesel/
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-#ifndef __WIESEL_ENGINE_INTERFACES_H__
-#define __WIESEL_ENGINE_INTERFACES_H__
-
-#include <wiesel/wiesel-common.def>
-
-#include <wiesel/util/shared_object.h>
-
-
-namespace wiesel {
-
-	/**
-	 * @brief Interface for classes, which wants to receive periodically updates.
-	 * To receive updates, the object has to be received on the engine object.
-	 * The update will be invoked each frame by the engine.
-	 */
-	class WIESEL_COMMON_EXPORT IUpdateable : public virtual SharedObject
-	{
-	public:
-		IUpdateable();
-		virtual ~IUpdateable();
-
-	public:
-		/**
-		 * @brief Called each frame by the engine.
-		 * @param dt The time which has elapsed since the last update in seconds.
-		 */
-		virtual void update(float dt) = 0;
-	};
-
-}
-
-#endif /* __WIESEL_ENGINE_INTERFACES_H__ */

File src/common/wiesel/gl/gl.cpp

-/**
- * Copyright (C) 2012
- * Christian Fischer
- *
- * https://bitbucket.org/baldur/wiesel/
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-#include "gl.h"
-#include "wiesel/util/log.h"
-
-
-void wiesel::checkGlError(const char *file, int line) {
-    for (GLint error=glGetError(); error; error=glGetError()) {
-    	const char *message = NULL;
-
-    	switch(error) {
-			case GL_INVALID_ENUM:			message = "GL_INVALID_ENUM";			break;
-			case GL_INVALID_VALUE:			message = "GL_INVALID_VALUE";			break;
-			case GL_INVALID_OPERATION:		message = "GL_INVALID_OPERATION";		break;
-			case GL_OUT_OF_MEMORY:			message = "GL_OUT_OF_MEMORY";			break;
-			default:						message = "unknown";					break;
-    	}
-
-        logmsg(LogLevel_Error, WIESEL_GL_LOG_TAG, "@%s, %d: %s (0x%x)\n", file, line, message, error);
-    }
-
-    return;
-}
-
-

File src/common/wiesel/gl/gl.h

-/**
- * Copyright (C) 2012
- * Christian Fischer
- *
- * https://bitbucket.org/baldur/wiesel/
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-#ifndef __WIESEL_GL_GLUTILS_H__
-#define __WIESEL_GL_GLUTILS_H__
-
-#include <wiesel/wiesel-common.def>
-
-// include platform specific OpenGL headers
-#include "wiesel/platform/gl_import.h"
-
-#define WIESEL_GL_LOG_TAG	"GL"
-#define CHECK_GL_ERROR		wiesel::checkGlError(__FILE__,__LINE__)
-
-
-namespace wiesel
-{
-	/**
-	 * @brief check for OpenGL errors and print the error message.
-	 * @param file	The current source code file.
-	 * @param line	The current source code line.
-	 */
-	WIESEL_COMMON_EXPORT void checkGlError(const char *file, int line);
-}
-
-
-#endif /* __WIESEL_GL_GLUTILS_H__ */

File src/common/wiesel/gl/shader/shader.cpp

-/**
- * Copyright (C) 2012
- * Christian Fischer
- *
- * https://bitbucket.org/baldur/wiesel/
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-#include "shader.h"
-
-#include "wiesel/gl/gl.h"
-#include "wiesel/util/log.h"
-#include <assert.h>
-#include <map>
-
-using namespace wiesel;
-using namespace std;
-
-
-Shader::Shader() {
-	return;
-}
-
-
-Shader::Shader(const std::string &source, ShaderType type) {
-	assert(type == ShaderType_VertexShader || type == ShaderType_FragmentShader);
-
-	DataBuffer *buffer = ExclusiveDataBuffer::createCopyOf(source);
-	this->shader = 0;
-	this->type   = type;
-	this->source = new BufferDataSource(buffer);
-	this->source->retain();
-
-	return;
-}
-
-
-Shader::Shader(DataSource *source, ShaderType type) {
-	assert(type == ShaderType_VertexShader || type == ShaderType_FragmentShader);
-
-	this->shader = 0;
-	this->type   = type;
-	this->source = source;
-	this->source->retain();
-
-	return;
-}
-
-
-Shader::~Shader() {
-	if (source) {
-		source->release();
-	}
-
-	if (shader) {
-		release_shader();
-	}
-
-	return;
-}
-
-
-Shader *Shader::compile(const string &source, ShaderType type) {
-	Shader *shader = new Shader(source, type);
-	if (shader->compile()) {
-		return shader;
-	}
-	else {
-		delete shader;
-	}
-
-	return NULL;
-}
-
-
-Shader *Shader::compile(DataSource *source, ShaderType type) {
-	Shader *shader = new Shader(source, type);
-	if (shader->compile()) {
-		return shader;
-	}
-	else {
-		delete shader;
-	}
-
-	return NULL;
-}
-
-
-bool Shader::compile() {
-	assert(type == ShaderType_VertexShader || type == ShaderType_FragmentShader);
-
-	// release previous shader, if any
-	release_shader();
-
-	const char *pSource = source->getDataBuffer()->getDataAsCharPtr();
-	GLint  compiled = 0;
-	shader = 0;
-
-	switch(type) {
-		case ShaderType_VertexShader: {
-			shader = glCreateShader(GL_VERTEX_SHADER);
-			break;
-		}
-
-		case ShaderType_FragmentShader: {
-			shader = glCreateShader(GL_FRAGMENT_SHADER);
-			break;
-		}
-	}
-
-	if (shader == 0) {
-		return false;
-	}
-
-	// assign the shader source
-	glShaderSource(shader, 1, &pSource, NULL);
-	CHECK_GL_ERROR;
-
-	// compile the shader
-	glCompileShader(shader);
-	CHECK_GL_ERROR;
-
-	// check, if the shader was compiled
-	glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
-	CHECK_GL_ERROR;
-
-	if (!compiled) {
-		// get the info message, which caused the compile to fail
-		GLint infoLen = 0;
-		glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLen);
-		logmsg(LogLevel_Error, WIESEL_GL_LOG_TAG, "Could not compile shader:\n%s", pSource);
-
-		if (infoLen) {
-			char *buffer = new char[infoLen];
-
-			if (buffer) {
-				GLint length_read = 0;
-				glGetShaderInfoLog(shader, infoLen, &length_read, buffer);
-				logmsg(LogLevel_Error, WIESEL_GL_LOG_TAG, "%s", buffer);
-				delete buffer;
-			}
-			else {
-				logmsg(LogLevel_Error, WIESEL_GL_LOG_TAG, "unknown reason.");
-			}
-		}
-
-		glDeleteShader(shader);
-		shader = 0;
-	}
-
-	CHECK_GL_ERROR;
-
-	if (shader) {
-		return true;
-	}
-
-	return false;
-}
-
-
-void Shader::release_shader() {
-	if (shader) {
-		glDeleteShader(shader);
-		shader = 0;
-	}
-
-	return;
-}
-
-
-void Shader::addUniform(const std::string& name) {
-	uniform_attributes.push_back(name);
-}
-
-
-
-
-
-
-ShaderProgram::ShaderProgram()
- :	program(0),
-  	need_link(false)
-{
-	attrib_handle_vertex_position		= -1;
-	attrib_handle_vertex_normal			= -1;
-	attrib_handle_vertex_color			= -1;
-	return;
-}
-
-
-ShaderProgram::~ShaderProgram() {
-	if (program) {
-		release_shader();
-	}
-
-	for(vector<Shader*>::iterator it=shaders.begin(); it!=shaders.end(); it++) {
-		(*it)->release();
-	}
-
-	return;
-}
-
-
-bool ShaderProgram::attach(Shader *shader) {
-	if (shader) {
-		shader->retain();
-		shaders.push_back(shader);
-		need_link = true;
-
-		return true;
-	}
-
-	return false;
-}
-
-
-bool ShaderProgram::link() {
-	if (need_link) {
-		// create the program, if neccessary
-		if (program == 0) {
-			program = glCreateProgram();
-		}
-
-		// fail, if program could not be created.
-		if (program == 0) {
-			logmsg(LogLevel_Error, WIESEL_GL_LOG_TAG, "could not create shader program");
-			return false;
-		}
-
-		// attach each shader
-		for(vector<Shader*>::iterator it=shaders.begin(); it!=shaders.end(); it++) {
-			glAttachShader(program, (*it)->getGlShader());
-		}
-
-		// link the program
-		glLinkProgram(program);
-
-		// check link status
-		GLint linkStatus = GL_FALSE;
-		glGetProgramiv(program, GL_LINK_STATUS, &linkStatus);
-
-		if (linkStatus != GL_TRUE) {
-			GLint length = 0;
-			glGetProgramiv(program, GL_INFO_LOG_LENGTH, &length);
-
-			if (length) {
-				char* buffer = new char[length];
-				if (buffer) {
-					GLint length_read = 0;
-					glGetProgramInfoLog(program, length, &length_read, buffer);
-					logmsg(LogLevel_Error, WIESEL_GL_LOG_TAG, "Could not link program:\n%s\n", buffer);
-					delete buffer;
-				}
-				else {
-					logmsg(LogLevel_Error, WIESEL_GL_LOG_TAG, "Could not link program for unknown reason.");
-				}
-			}
-
-			glDeleteProgram(program);
-			program = 0;
-		}
-
-		CHECK_GL_ERROR;
-
-		// bind all configured attributes
-		bindAttributes();
-
-		need_link = false;
-	}
-
-	return true;
-}
-
-
-void ShaderProgram::bindAttributes() {
-	uniform_attributes.clear();
-
-	// get all attribute handles
-	for(vector<Shader*>::iterator it=shaders.begin(); it!=shaders.end(); it++) {
-		Shader *shader = *it;
-
-		switch(shader->getType()) {
-			case ShaderType_VertexShader: {
-				if (shader->uniform_projection_matrix.empty() == false) {
-					uniform_handle_projection_matrix = glGetUniformLocation(program, shader->uniform_projection_matrix.c_str());
-					CHECK_GL_ERROR;
-					assert(uniform_handle_projection_matrix != -1);
-				}
-
-				if (shader->uniform_modelview_matrix.empty() == false) {
-					uniform_handle_modelview_matrix = glGetUniformLocation(program, shader->uniform_modelview_matrix.c_str());
-					CHECK_GL_ERROR;
-					assert(uniform_handle_modelview_matrix != -1);
-				}
-
-				if (shader->attrib_vertex_position.empty() == false) {
-					attrib_handle_vertex_position = glGetAttribLocation(program, shader->attrib_vertex_position.c_str());
-					CHECK_GL_ERROR;
-					assert(attrib_handle_vertex_position != -1);
-				}
-
-				if (shader->attrib_vertex_normal.empty() == false) {
-					attrib_handle_vertex_normal = glGetAttribLocation(program, shader->attrib_vertex_normal.c_str());
-					CHECK_GL_ERROR;
-					assert(attrib_handle_vertex_position != -1);
-				}
-
-				if (shader->attrib_vertex_color.empty() == false) {
-					attrib_handle_vertex_color = glGetAttribLocation(program, shader->attrib_vertex_color.c_str());
-					CHECK_GL_ERROR;
-					assert(attrib_handle_vertex_position != -1);
-				}
-
-				attrib_handle_vertex_texcoords.clear();
-				for(vector<string>::const_iterator it=shader->attrib_vertex_texcoords.begin(); it!=shader->attrib_vertex_texcoords.end(); it++) {
-					GLuint handle = glGetAttribLocation(program, it->c_str());
-					attrib_handle_vertex_texcoords.push_back(handle);
-					CHECK_GL_ERROR;
-				}
-
-				break;
-			}
-
-			case ShaderType_FragmentShader: {
-				attrib_handle_vertex_textures.clear();
-				for(vector<string>::const_iterator it=shader->attrib_vertex_textures.begin(); it!=shader->attrib_vertex_textures.end(); it++) {
-					GLuint handle = glGetUniformLocation(program, it->c_str());
-					attrib_handle_vertex_textures.push_back(handle);
-					CHECK_GL_ERROR;
-				}
-
-				break;
-			}
-		}
-
-		for(vector<string>::const_iterator it=shader->uniform_attributes.begin(); it!=shader->uniform_attributes.end(); it++) {
-			GLint handle = glGetUniformLocation(program, it->c_str());
-			uniform_attributes[*it] = handle;
-			CHECK_GL_ERROR;
-		}
-	}
-
-	CHECK_GL_ERROR;
-
-	return;
-}
-
-
-void ShaderProgram::setDefaultValues() {
-	setProjectionMatrix(matrix4x4::identity);
-	setModelviewMatrix(matrix4x4::identity);
-	return;
-}
-
-
-GLint ShaderProgram::getUniformHandle(const std::string& name) const {
-	std::map<string,GLint>::const_iterator it = uniform_attributes.find(name);
-	if (it != uniform_attributes.end()) {
-		return it->second;
-	}
-	
-	return -1;
-}
-
-
-void ShaderProgram::set(const std::string& name, int value) {
-	GLint handle = getUniformHandle(name);
-	if (handle != -1) {
-		glUniform1i(handle, value);
-	}
-}
-
-
-void ShaderProgram::set(const std::string& name, float value) {
-	GLint handle = getUniformHandle(name);
-	if (handle != -1) {
-		glUniform1f(handle, value);
-	}
-}
-
-
-void ShaderProgram::setProjectionMatrix(const matrix4x4& matrix) {
-	// bind the projection matrix
-	GLint uniform_projection_matrix = getProjectionMatrixHandle();
-	assert(uniform_projection_matrix != -1);
-
-	if (uniform_projection_matrix != -1) {
-		glUniformMatrix4fv(uniform_projection_matrix, 1, false, matrix);
-	}
-
-	return;
-}
-
-
-void ShaderProgram::setModelviewMatrix(const matrix4x4& matrix) {
-	// bind the modelview matrix
-	GLint uniform_modelview_matrix = getModelviewMatrixHandle();
-	assert(uniform_modelview_matrix != -1);
-
-	if (uniform_modelview_matrix != -1) {
-		glUniformMatrix4fv(uniform_modelview_matrix, 1, false, matrix);
-	}
-
-	return;
-}
-
-
-void ShaderProgram::release_shader() {
-	glDeleteProgram(program);
-	return;
-}
-
-
-void ShaderProgram::bind() const {
-	assert(need_link == false);
-
-	if (program) {
-		glUseProgram(program);
-		CHECK_GL_ERROR;
-	}
-
-	return;
-}
-
-
-void ShaderProgram::unbind() const {
-	glUseProgram(0);
-	CHECK_GL_ERROR;
-	return;
-}
-
-
-bool ShaderProgram::isBound() const {
-	GLint current_program;
-	glGetIntegerv(GL_CURRENT_PROGRAM, &current_program);
-	return static_cast<GLuint>(current_program) == program;
-}

File src/common/wiesel/gl/shader/shader.h

-/**
- * Copyright (C) 2012
- * Christian Fischer
- *
- * https://bitbucket.org/baldur/wiesel/
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-#ifndef __WIESEL_GL_SHADER_SHADER_H__
-#define __WIESEL_GL_SHADER_SHADER_H__
-
-#include <wiesel/gl/gl.h>
-#include <wiesel/math/matrix.h>
-#include <wiesel/io/datasource.h>
-#include <wiesel/util/shared_object.h>
-#include <string>
-#include <vector>
-#include <map>
-
-
-namespace wiesel {
-
-
-	/**
-	 * @brief Handles for each available shader type.
-	 */
-	enum ShaderType
-	{
-		ShaderType_VertexShader,		//!< Vertex Shader applies transformations to each vertex.
-		ShaderType_FragmentShader,		//!< Fragment Shaders will be applied to each pixel.
-	};
-
-
-
-
-	/**
-	 * @brief A class handling a single shader object.
-	 */
-	class WIESEL_COMMON_EXPORT Shader : public virtual SharedObject
-	{
-	private:
-		Shader();
-
-	public:
-		/**
-		 * @brief Create a new shader with source code from a string
-		 * The created shader is not compiled. Call compile() to compile
-		 * the shader or use compile(const std::string&, ShaderType)
-		 * to get a compiled shader.
-		 */
-		Shader(const std::string &source, ShaderType type);
-
-		/**
-		 * @brief Create a new shader with source code from a DataSource
-		 * The created shader is not compiled. Call compile() to compile
-		 * the shader or use compile(const std::string&, ShaderType)
-		 * to get a compiled shader.
-		 */
-		Shader(DataSource *source, ShaderType type);
-
-		virtual ~Shader();
-
-		/**
-		 * @brief compile a shader from source code.
-		 * @return the created shader on success, \c NULL when compiling failed.
-		 */
-		static WIESEL_COMMON_EXPORT Shader *compile(const std::string &source, ShaderType type);
-
-		/**
-		 * @brief compile a shader from source code.
-		 * @return the created shader on success, \c NULL when compiling failed.
-		 */
-		static WIESEL_COMMON_EXPORT Shader *compile(DataSource *source, ShaderType type);
-
-		/**
-		 * 
-		 * @return \c true when the shader was compiled successfully, \c false otherwise.
-		 */
-		bool compile();
-
-		/**
-		 * @brief Add the name of a new uniform attribute.
-		 */
-		void addUniform(const std::string &name);
-
-		/**
-		 * @brief get the type of this shader.
-		 */
-		inline ShaderType getType() const {
-			return type;
-		}
-
-		/**
-		 * @brief get access to the OpenGL shader handle.
-		 */
-		inline GLuint getGlShader() {
-			return shader;
-		}
-
-	// attributes (vertex shader)
-	public:
-		std::string		uniform_projection_matrix;
-		std::string		uniform_modelview_matrix;
-		std::string		attrib_vertex_position;
-		std::string		attrib_vertex_normal;
-		std::string		attrib_vertex_color;
-
-		/// names of texture coordinate attributes
-		std::vector<std::string>	attrib_vertex_texcoords;
-
-	// attributes (fragment shader)
-	public:
-		/// names of texture coordinate attributes
-		std::vector<std::string>	attrib_vertex_textures;
-
-	// attributes (custom)
-	public:
-		/// names of custom uniform attributes to be set from user code
-		std::vector<std::string>	uniform_attributes;
-
-	private:
-		/**
-		 * @brief release the shader.
-		 * Needs to be used before deleting this object.
-		 */
-		void release_shader();
-
-	private:
-		DataSource*		source;
-		ShaderType		type;
-		GLuint			shader;
-	};
-
-
-
-	/**
-	 * @brief Handles a shader program with mulitple shaders linked.
-	 */
-	class WIESEL_COMMON_EXPORT ShaderProgram : public virtual SharedObject
-	{
-	public:
-		/**
-		 * @brief Create a new \ref ShaderProgram with no shaders attached.
-		 */
-		ShaderProgram();
-
-		virtual ~ShaderProgram();
-
-
-	public:
-		/**
-		 * @brief Attaches a new shader to this program.
-		 */
-		bool attach(Shader *shader);
-
-		/**
-		 * @brief link the shader program after attaching all shaders.
-		 */
-		bool link();
-
-		/**
-		 * @brief binds this program to the current OpenGL context.
-		 */
-		void bind() const;
-
-		/**
-		 * @brief removes this program from the current OpenGL context.
-		 */
-		void unbind() const;
-
-		/**
-		 * @brief check, if this shader is currently bound to the GL context.
-		 */
-		bool isBound() const;
-