Commits

Christian Fischer committed 89d3a1e

removed all SDL dependencies from the core library

Comments (0)

Files changed (79)

build/cmake/modules/wiesel-module.cmake

 	# get all sources from this directory
 	wiesel_module_get_files(MODULE_SRC_FILES ${source_dir})
 	
+	# get the library type, if given
+	if (DEFINED ARGV3)
+		set(libtype ${ARGV3})
+	else()
+		set(libtype SHARED)
+	endif()
+	
+	# check if libtype is valid
+	if (NOT ((${libtype} STREQUAL "SHARED") OR (${libtype} STREQUAL "STATIC")))
+		message(FATAL_ERROR "Illegal library type for module ${target}: ${libtype} - should be SHARED or STATIC")
+	endif()
+	
 	# add sources to the module's target
 	add_library(${target} SHARED ${MODULE_SRC_FILES})
 	

libraries/desktop/wiesel-core/module.cmake

 wiesel_module_add_dependency(wiesel-core glee third-party/glee)
 
 
+# TODO: remove when GL dependencies gets removed
+wiesel_target_add_compileflags(wiesel-core "-DWIESEL_USE_GLEE")
+
 
 # add libxml2 dependency
 include(FindLibXml2)
 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()

libraries/desktop/wiesel-mainproc/module.cmake

+# wiesel-mainproc library
+
+
+# create the main module
+wiesel_create_module(wiesel-mainproc ${WIESEL_SRC_DIR}/mainproc ${WIESEL_TESTS_DIR}/mainproc STATIC)
+
+# add required modules
+wiesel_module_add_dependency(wiesel-mainproc wiesel-base)
+wiesel_module_add_dependency(wiesel-mainproc wiesel-core)
+

libraries/desktop/wiesel-sdl/module.cmake

 # add required modules
 wiesel_module_add_dependency(wiesel-sdl wiesel-base)
 wiesel_module_add_dependency(wiesel-sdl wiesel-core)
-#wiesel_module_add_dependency(wiesel-sdl glee third-party/glee)
 
 
+# TODO: remove when GL dependencies gets removed
+wiesel_target_add_compileflags(wiesel-sdl "-DWIESEL_USE_GLEE")
+
 
 # add SDL dependency
 include(FindSDL)

samples/HelloWiesel/CMakeLists.txt

 
 wiesel_create_executable(HelloWiesel ./src)
 
+# TODO: remove when GL dependencies gets removed
+wiesel_target_add_compileflags(HelloWiesel "-DWIESEL_USE_GLEE")
+
 
 # add required libraries
 wiesel_module_add_dependency(HelloWiesel wiesel-base)
 wiesel_module_add_dependency(HelloWiesel wiesel-core)
 wiesel_module_add_dependency(HelloWiesel wiesel-common)
 wiesel_module_add_dependency(HelloWiesel wiesel-sdl)
+wiesel_module_add_dependency(HelloWiesel wiesel-mainproc)
 
 wiesel_target_add_compileflags(HelloWiesel "-DWIESEL_USE_LIBSDL")
 

samples/HelloWiesel/src/HelloWiesel.cpp

 #include <wiesel/graph/2d/sprite_node.h>
 #include <wiesel/ui/bitmapfont.h>
 #include <wiesel/ui/label_node.h>
+#include <wiesel/video/screen.h>
+#include <wiesel/video/video_device.h>
 #include <wiesel.h>
 
 using namespace wiesel;
+using namespace wiesel::video;
 using namespace std;
 
 
 public:
 	virtual bool onInit() {
 		Log::info << "start application HelloWiesel" << std::endl;
+
+		// at first, we create our screen object
+		screen = new Screen();
+		screen->retain();
+
+		// the screen needs to be initialized
+		screen->loadVideoDevice(dimension(640, 480), 0);
+		
+		// successful?
+		assert(screen->getVideoDevice());
+		if (!screen->getVideoDevice()) {
+			return false;
+		}
 		
 		// get the screen centre
-		const dimension &screen = Engine::getCurrent()->getScreen()->getSize();
-		float center_x = screen.width  / 2;
-		float center_y = screen.height / 2;
-		float size     = min(screen.width, screen.height);
+		const dimension &screen_size = screen->getVideoDevice()->getResolution();
+		float center_x = screen_size.width  / 2;
+		float center_y = screen_size.height / 2;
+		float size     = min(screen_size.width, screen_size.height);
 
 		// note: we're loading this image from SDcard, it's currently not part of this sample application
-		File *tex_file = Engine::getCurrent()->getAssetFileSystem()->findFile("/images/wiesel.png");
+		File *tex_file = Engine::getInstance()->getAssetFileSystem()->findFile("/images/wiesel.png");
 		if (tex_file) {
 			Log::info << "load texture from: " << tex_file->getFullPath() << std::endl;
 			texture = Texture::fromFile(tex_file);
 		sprite->retain();
 
 		// load the bitmap font
-		File*			font_file		= Engine::getCurrent()->getAssetFileSystem()->findFile("/images/font.png");
+		File*			font_file		= Engine::getInstance()->getAssetFileSystem()->findFile("/images/font.png");
 		Texture*		font_texture	= Texture::fromFile(font_file);
 		SpriteSheet*	font_ss			= new SpriteSheet(font_texture);
 
 		label->setText("Hello Wiesel");
 		label->setPosition(center_x, 0.0f);
 		label->setPivot(0.5f, 0.0f);
-		label->setScale(screen.width / label->getContentSize().width * 0.95f);
+		label->setScale(screen_size.width / label->getContentSize().width * 0.95f);
 		label->retain();
 
 		Scene *scene = new Scene();
 
 	virtual void onRun(float dt) {
 		Application::onRun(dt);
+
+		switch(screen->getState()) {
+			case Video_Uninitialized: {
+				// do nothing
+				break;
+			}
+
+			case Video_Suspended: {
+				// do nothing
+				break;
+			}
+
+			case Video_Background:
+			case Video_Active: {
+				if (screen && screen->getVideoDevice()) {
+					screen->getVideoDevice()->preRender();
+					this->onRender(screen->getVideoDevice());
+					screen->getVideoDevice()->postRender();
+				}
+
+				break;
+			}
+		}
+
 		return;
 	}
 
 
-	virtual void onRender() {
-		Application::onRender();
+	virtual void onRender(VideoDevice *video_device) {
+		Application::onRender(video_device);
 		return;
 	}
 
 	}
 
 private:
+	Screen*			screen;
+
 	Texture*		texture;
 	wiesel::Font*	font;
 

src/common/wiesel/generic_platform.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 "generic_platform.h"
+#include "wiesel/io/generic_root_fs.h"
+
+#include "wiesel/io/datasource.h"
+#include "wiesel/io/directory_filesystem.h"
+#include "wiesel/util/log.h"
+
+#include <sys/unistd.h>
+#include <sys/param.h>
+#include <sstream>
+
+
+using namespace wiesel;
+using namespace std;
+
+
+GenericPlatform::GenericPlatform() {
+	// create file systems
+	root_fs = new GenericFileSystem();
+
+	// get the current working directory
+	char working_dir_name[MAXPATHLEN];
+	getcwd(working_dir_name, MAXPATHLEN);
+
+	// replace backslashes with normal slashes, as the file system API
+	// cannot handle backslashes as separators yet.
+	for(int i=0; i<MAXPATHLEN; i++) {
+		if (working_dir_name[i] == '\0') {
+			break;
+		}
+
+		if (working_dir_name[i] == '\\') {
+			working_dir_name[i] =  '/';
+		}
+	}
+
+	stringstream ss;
+	ss << working_dir_name;
+	ss << "/resources/common";
+
+	Directory *asset_root = root_fs->findDirectory(ss.str());
+	assert(asset_root);
+
+	if (asset_root) {
+		asset_fs = new DirectoryFileSystem(asset_root);
+	}
+	else {
+		// try another root file-system as a fallback
+		asset_fs = new GenericFileSystem();
+	}
+
+	return;
+}
+
+GenericPlatform::~GenericPlatform() {
+	delete asset_fs;
+	delete root_fs;
+
+	return;
+}
+
+
+bool GenericPlatform::onInit() {
+	return true;
+}
+
+
+void GenericPlatform::onShutdown() {
+	return;
+}
+
+
+void GenericPlatform::onRunFirst() {
+	return;
+}
+
+
+bool GenericPlatform::onRun() {
+	return false;
+}
+
+
+FileSystem *GenericPlatform::getRootFileSystem() {
+	return root_fs;
+}
+
+
+FileSystem *GenericPlatform::getAssetFileSystem() {
+	return asset_fs;
+}

src/common/wiesel/generic_platform.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_GENERIC_PLATFORM_H__
+#define __WIESEL_GENERIC_PLATFORM_H__
+
+#include <wiesel/wiesel-common.def>
+
+#include <wiesel/platform.h>
+
+
+namespace wiesel {
+
+	class GenericFileSystem;
+
+
+	/**
+	 * @brief A generic platform implementation which should fit
+	 * most windows and unix like implementations.
+	 */
+	class WIESEL_COMMON_EXPORT GenericPlatform : public Platform
+	{
+	public:
+		GenericPlatform();
+		virtual ~GenericPlatform();
+
+	// overridables
+	protected:
+		virtual bool onInit();
+		virtual void onShutdown();
+
+		virtual void onRunFirst();
+		virtual bool onRun();
+
+	public:
+		virtual FileSystem *getRootFileSystem();
+		virtual FileSystem *getAssetFileSystem();
+
+	protected:
+		FileSystem*		root_fs;
+		FileSystem*		asset_fs;
+	};
+
+}
+
+#endif /* __WIESEL_GENERIC_PLATFORM_H__ */

src/common/wiesel/generic_platform.loadable_module

+
+#include <wiesel/module_registry.h>
+#include "generic_platform.h"
+
+// add the module to the module registry
+namespace wiesel {
+	REGISTER_MODULE_SINGLETON(
+			Platform,
+			GenericPlatform,
+			&generic_create<GenericPlatform>,
+			"Generic",
+			0x01000000u,
+			IModuleLoader::PriorityLow
+	)
+}

src/common/wiesel/io/generic_root_fs.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 "wiesel.h"
+#include "generic_root_fs.h"
+#include "wiesel/util/log.h"
+#include <dirent.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sstream>
+
+#if WIESEL_PLATFORM_WINDOWS && !WIESEL_PLATFORM_CYGWIN
+#include "windows.h"
+#endif
+
+
+using namespace wiesel;
+using namespace std;
+
+
+GenericFileSystem::GenericFileSystem() {
+	root = new GenericFileSystemDirectory(this, NULL, "");
+	root->retain();
+	return;
+}
+
+GenericFileSystem::~GenericFileSystem() {
+	root->release();
+	return;
+}
+
+
+Directory *GenericFileSystem::getRootDirectory() {
+	return root;
+}
+
+
+
+
+
+
+
+
+GenericFileSystemDirectory::GenericFileSystemDirectory(GenericFileSystem *fs, Directory *parent, const string &name)
+:	Directory(fs, parent), name(name)
+{
+	return;
+}
+
+GenericFileSystemDirectory::~GenericFileSystemDirectory() {
+	return;
+}
+
+
+string GenericFileSystemDirectory::getName() const {
+	return name;
+}
+
+
+string GenericFileSystemDirectory::getFullPath() {
+	#if WIESEL_PLATFORM_WINDOWS && !WIESEL_PLATFORM_CYGWIN
+	if (getParent() && getParent()->getName().empty()) {
+		// this is a 2nd level directory, on a windows file system this
+		// would be a drive-letter, so we need to skip the leading slash
+		return getName();
+	}
+	#endif // windows
+
+	return Directory::getFullPath();
+}
+
+
+string GenericFileSystemDirectory::getNativePath() {
+	return getFullPath();
+}
+
+
+DirectoryList GenericFileSystemDirectory::getSubDirectories() {
+	#if WIESEL_PLATFORM_WINDOWS && !WIESEL_PLATFORM_CYGWIN
+	// on windows, the root folder should contain a list of windows drive letters
+	if (this->name.empty()) {
+		GenericFileSystem *fs = (GenericFileSystem*)(getFileSystem());
+		DirectoryList directories;
+		DWORD all_drives = GetLogicalDrives();
+
+		for(char drive=0; drive<=26; drive++) {
+			if ((all_drives & (1 << drive)) != 0) {
+				stringstream drive_name;
+				drive_name << (char)('A' + drive);
+				drive_name << ':';
+				directories.push_back(new GenericFileSystemDirectory(fs, this, drive_name.str()));
+			}
+		}
+
+		return directories;
+	}
+	#endif // windows
+
+	DirectoryList directories;
+	struct dirent *dirp;
+	struct stat fileinfo;
+	DIR *dp;
+
+	string fullpath = (getFullPath() + "/");
+
+	if ((dp = opendir(fullpath.c_str())) != NULL) {
+		while ((dirp = readdir(dp)) != NULL) {
+			string newdirname = dirp->d_name;
+			string fullpath = getFullPath() + "/" + newdirname;
+
+			// get entry fileinfo
+			if (stat(fullpath.c_str(), &fileinfo) < 0) {
+				continue;
+			}
+
+			// skip, if is no directory
+			if (S_ISDIR(fileinfo.st_mode) == false) {
+				continue;
+			}
+
+			// skip "current" and "parent" directory entries
+			if (newdirname == "." || newdirname == "..") {
+				continue;
+			}
+
+			directories.push_back(new GenericFileSystemDirectory((GenericFileSystem*)(getFileSystem()), this, newdirname));
+		}
+
+		closedir(dp);
+	}
+
+	return directories;
+}
+
+
+FileList GenericFileSystemDirectory::getFiles() {
+	FileList files;
+	struct dirent *dirp;
+	struct stat fileinfo;
+	DIR *dp;
+
+	if ((dp = opendir((getFullPath() + "/").c_str())) != NULL) {
+		while ((dirp = readdir(dp)) != NULL) {
+			string newfilename = dirp->d_name;
+			string fullpath = getFullPath() + "/" + newfilename;
+
+			// get entry fileinfo
+			if (stat(fullpath.c_str(), &fileinfo) < 0) {
+				continue;
+			}
+
+			// skip, if not a file
+			if (S_ISREG(fileinfo.st_mode) == false) {
+				continue;
+			}
+
+			files.push_back(new GenericFileSystemFile(this, newfilename));
+		}
+
+		closedir(dp);
+	}
+
+	return files;
+}
+
+
+
+
+
+
+
+GenericFileSystemFile::GenericFileSystemFile(GenericFileSystemDirectory *parent, const string &name)
+: File(parent), name(name)
+{
+	return;
+}
+
+GenericFileSystemFile::~GenericFileSystemFile() {
+	return;
+}
+
+
+string GenericFileSystemFile::getName() const {
+	return name;
+}
+
+
+string GenericFileSystemFile::getNativePath() {
+	return getFullPath();
+}
+
+
+DataBuffer *GenericFileSystemFile::getContent() {
+	FILE *fp = fopen(getFullPath().c_str(), "rb");
+	if (fp != NULL) {
+		fseek(fp, 0, SEEK_END);
+		size_t size = ftell(fp);
+		fseek(fp, 0, SEEK_SET);
+
+		unsigned char *data = new unsigned char[size];
+		if (data) {
+			fread(data, size, 1, fp);
+		}
+
+		fclose(fp);
+
+		return new ExclusiveDataBuffer(data, size);
+	}
+
+	return NULL;
+}
+

src/common/wiesel/io/generic_root_fs.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_IO_GENERIC_ROOT_FS_H__
+#define __WIESEL_IO_GENERIC_ROOT_FS_H__
+
+#include <wiesel/wiesel-common.def>
+
+#include "wiesel/io/filesystem.h"
+
+
+namespace wiesel {
+
+	class GenericFileSystemDirectory;
+
+
+
+	class WIESEL_COMMON_EXPORT GenericFileSystem : public FileSystem
+	{
+	public:
+		GenericFileSystem();
+		virtual ~GenericFileSystem();
+
+		virtual Directory *getRootDirectory();
+
+	private:
+		GenericFileSystemDirectory *root;
+	};
+
+
+
+	class WIESEL_COMMON_EXPORT GenericFileSystemDirectory : public Directory
+	{
+	public:
+		GenericFileSystemDirectory(GenericFileSystem *fs, Directory *parent, const std::string &name);
+		~GenericFileSystemDirectory();
+
+		virtual std::string getName() const;
+		virtual std::string getFullPath();
+		virtual std::string getNativePath();
+		virtual DirectoryList getSubDirectories();
+		virtual FileList getFiles();
+
+	private:
+		std::string		name;
+	};
+
+
+
+	class WIESEL_COMMON_EXPORT GenericFileSystemFile : public File
+	{
+	public:
+		GenericFileSystemFile(GenericFileSystemDirectory *parent, const std::string &name);
+		~GenericFileSystemFile();
+
+		virtual std::string getName() const;
+		virtual std::string getNativePath();
+
+		virtual DataBuffer *getContent();
+
+	private:
+		std::string		name;
+	};
+
+} /* namespace wiesel */
+#endif /* __WIESEL_IO_GENERIC_ROOT_FS_H__ */

src/common/wiesel/resources/graphics/image_loader_libpng.h

 
 #include <wiesel/io/databuffer.h>
 #include <wiesel/io/file.h>
-#include <wiesel/modules.h>
+#include <wiesel/module.h>
 #include <wiesel/resources/graphics/image_loader.h>
 #include <wiesel/wiesel-common-config.h>
 #include <wiesel/wiesel-common.def>

src/common/wiesel/resources/graphics/image_loader_libpng.loadable_module

 
+#include <wiesel/module_registry.h>
 #include "image_loader_libpng.h"
 
 

src/common/wiesel/util/log_writer_stdout.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 "log_writer_stdout.h"
+#include <stdio.h>
+
+
+using namespace wiesel;
+
+
+LogWriterStdOut::LogWriterStdOut() {
+	return;
+}
+
+LogWriterStdOut::~LogWriterStdOut() {
+	return;
+}
+
+// implementing the platform specific logging
+bool LogWriterStdOut::write(LogLevel level, const std::string &tag, const std::string &message) {
+	FILE *stream = stdout;
+	char lvl = '?';
+	switch(level) {
+		case LogLevel_Debug:	lvl = 'D';							break;
+		case LogLevel_Info:		lvl = 'I';							break;
+		case LogLevel_Warning:	lvl = 'W';							break;
+		case LogLevel_Error:	lvl = 'E';		stream = stderr;	break;
+		default:				lvl = '-';							break;	// should not happen
+	}
+
+	fprintf(stream, "[%c] %-16s %s\n", lvl, tag.c_str(), message.c_str());
+	fflush(stream);
+	
+	return true;
+}

src/common/wiesel/util/log_writer_stdout.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_UTIL_LOG_WRITER_STDOUT_H__
+#define __WIESEL_UTIL_LOG_WRITER_STDOUT_H__
+
+#include <wiesel/wiesel-common.def>
+#include <wiesel/util/log_writer.h>
+#include <wiesel/util/log.h>
+
+
+
+namespace wiesel {
+
+	/**
+	 * @brief A log writer module to write log messages into stdout stream
+	 */
+	class WIESEL_COMMON_EXPORT LogWriterStdOut : public ILogWriter
+	{
+	public:
+		LogWriterStdOut();
+		virtual ~LogWriterStdOut();
+
+	public:
+		virtual bool write(LogLevel level, const std::string &tag, const std::string &message);
+	};
+
+} /* namespace wiesel */
+#endif /* __WIESEL_UTIL_LOG_WRITER_STDOUT_H__ */

src/common/wiesel/util/log_writer_stdout.loadable_module

+
+#include <wiesel/module_registry.h>
+#include "log_writer_stdout.h"
+
+// add the module to the module registry
+namespace wiesel {
+	REGISTER_MODULE_SINGLETON(
+			ILogWriter,
+			LogWriterStdOut,
+			&generic_create<LogWriterStdOut>,
+			"STDOUT",
+			0x01000000u,
+			IModuleLoader::PriorityLow
+	)
+}

src/core/wiesel.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"

src/core/wiesel/application.cpp

 }
 
 
-void Application::onRender() {
+void Application::onRender(video::VideoDevice *video_device) {
 	// draw all scenes
 	for(SceneList::iterator it=scene_stack.begin(); it!=scene_stack.end(); it++) {
-		(*it)->render();
+		(*it)->render(video_device);
 	}
 
 	return;

src/core/wiesel/application.h

 
 #include <wiesel/wiesel-core.def>
 
-#include "graph/scene.h"
+#include "wiesel/graph/scene.h"
+#include "wiesel/module.h"
+
 #include <vector>
 
 
 	/**
 	 * @brief An abstract class implementing the application logic.
 	 */
-	class WIESEL_CORE_EXPORT Application {
+	class WIESEL_CORE_EXPORT Application : public Module
+	{
 	public:
 		Application();
 		virtual ~Application();
 		 * @brief called each frame to render graphics.
 		 * DUMMY - will be replaced by scene graph later.
 		 */
-		virtual void onRender();
+		virtual void onRender(video::VideoDevice *video_device);
 
 	// scene stack
 	public:

src/core/wiesel/application_main.h

  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301 USA
  */
-#ifndef __WIESEL_APPLICATIONMAIN_H__
-#define __WIESEL_APPLICATIONMAIN_H__
+#ifndef __WIESEL_APPLICATION_ENTRY_H__
+#define __WIESEL_APPLICATION_ENTRY_H__
 
-#include "../wiesel.h"
+#include <wiesel/wiesel-core.def>
+#include <wiesel/application.h>
+#include <wiesel/module.h>
+#include <wiesel/module_registry.h>
 
-// application class
-#include "application.h"
+/// macro to register an application class, so it can be loaded from the engine
+#define WIESEL_APPLICATION_SETUP(APPLICATION_CLASS)								\
+				static APPLICATION_CLASS* __##APPLICATION_CLASS##_factory() {	\
+					return new APPLICATION_CLASS();								\
+				}																\
+																				\
+				REGISTER_MODULE(												\
+							wiesel::Application,								\
+							APPLICATION_CLASS,									\
+							&__##APPLICATION_CLASS##_factory,					\
+							"Application",										\
+							0x01000000u,										\
+							wiesel::IModuleLoader::PriorityNormal				\
+				)
 
-// 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__
+#endif /* __WIESEL_APPLICATION_H__ */

src/core/wiesel/device.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 "device.h"
+#include "device_resource.h"
+
+#include <algorithm>
+
+using namespace wiesel;
+
+
+Device::Device() {
+	return;
+}
+
+
+Device::~Device() {
+	// free all device resources
+	for(DeviceResourceList::iterator it=resources.begin(); it!=resources.end(); it++) {
+		// there should be no more references when the device will be released
+		assert((*it)->getReferenceCount() == 1);
+
+		(*it)->release();
+	}
+
+	return;
+}
+
+
+void Device::addResource(DeviceResource *resource) {
+	// check, if the resource is already in the list
+	DeviceResourceList::iterator it = std::find(resources.begin(), resources.end(), resource);
+	assert(it == resources.end());
+
+	if (it == resources.end()) {
+		resources.push_back(resource);
+		resource->retain();
+	}
+
+	return;
+}
+
+
+void Device::removeResource(DeviceResource *resource) {
+	DeviceResourceList::iterator it = std::find(resources.begin(), resources.end(), resource);
+
+	if ((*it) == resource) {
+		resources.erase(it);
+		(*it)->release();
+	}
+
+	return;
+}
+

src/core/wiesel/device.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_DEVICE_H__
+#define __WIESEL_DEVICE_H__
+
+#include <wiesel/wiesel-core.def>
+
+#include <wiesel/util/shared_object.h>
+
+#include <vector>
+
+
+namespace wiesel {
+	
+	
+	// forward declarations
+	
+	class DeviceResource;
+	
+
+	/**
+	 * @brief An abstract baseclass for any device classes.
+	 * Device classes wwill be used as an interface layer between application
+	 * and various hardware and platform specific implementations, such as
+	 * video devices for rendering or input devices for pointer and key input.
+	 * A device can handle various \ref DeviceResource objects.
+	 */
+	class WIESEL_CORE_EXPORT Device : public virtual SharedObject
+	{
+	protected:
+		Device();
+		
+	public:
+		virtual ~Device();
+		
+	// handle resources
+	protected:
+		/**
+		 * @brief Adds a new resource to this device.
+		 * This is allowed for subclasses only. Subclasses should provide 
+		 * their own set of functions to provide access to device resources.
+		 */
+		void addResource(DeviceResource *resource);
+		
+		/**
+		 * @brief Removes an existing resource to this device.
+		 * This is allowed for subclasses only. Subclasses should provide 
+		 * their own set of functions to provide access to device resources.
+		 */
+		void removeResource(DeviceResource *resource);
+		
+	protected:
+		/// type alias for resource lists
+		typedef std::vector<DeviceResource*>	DeviceResourceList;
+		
+		DeviceResourceList		resources;
+	};
+
+}
+
+#endif /* __WIESEL_ENGINE_H__ */

src/core/wiesel/device_resource.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 "device_resource.h"
+#include "device.h"
+
+#include <assert.h>
+
+using namespace wiesel;
+
+
+DeviceResource::DeviceResource() : device(NULL) {
+	return;
+}
+
+
+DeviceResource::DeviceResource(Device *device) {
+	// device should be valid
+	assert(device);
+	
+	this->device = device;
+	
+	return;
+}
+
+
+DeviceResource::~DeviceResource() {
+	return;
+}

src/core/wiesel/device_resource.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_DEVICE_RESOURCE_H__
+#define __WIESEL_DEVICE_RESOURCE_H__
+
+#include <wiesel/wiesel-core.def>
+
+#include <wiesel/util/shared_object.h>
+
+
+
+namespace wiesel {
+
+	// forward declarations
+	
+	class Device;
+	
+	
+	class WIESEL_CORE_EXPORT DeviceResource : public virtual SharedObject
+	{
+	private:
+		/// hidden default constructor
+		DeviceResource();
+		
+	protected:
+		/// create a new device resource, 
+		DeviceResource(Device *device);
+		
+	public:
+		virtual ~DeviceResource();
+		
+	// getters
+	public:
+		/// get the device, which owns this resource
+		inline Device* getDevice() {
+			return device;
+		}
+		
+		/// get the device, which owns this resource
+		inline const Device* getDevice() const {
+			return device;
+		}
+		
+	private:
+		Device*		device;
+	};
+
+}
+
+#endif /* __WIESEL_DEVICE_RESOURCE_H__ */

src/core/wiesel/engine.cpp

 
 #include <wiesel/util/shared_object.h>
 #include <wiesel/util/log.h>
+#include <wiesel/module.h>
+#include <wiesel/module_registry.h>
 
 #include <wiesel/ui/touchhandler.h>
 
 using namespace wiesel;
 
 
-Engine*				Engine::current_instance		= NULL;
-Application*		Engine::current_app				= NULL;
-bool				Engine::exit_requested			= false;
+Engine		Engine::instance;
 
 
-Engine::Engine()
-: screen(NULL)
-{
-	state		= Engine_Uninitialized;
+Engine::Engine() {
+	state				= Engine_Uninitialized;
+	exit_requested		= false;
+	application			= NULL;
+
 	return;
 }
 
 Engine::~Engine() {
+	shutdown();
 	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;
+bool Engine::initialize(int argc, char* argv[]) {
+	// try to find a valid platform object
+	if (this->platforms.empty()) {
+		std::vector<ModuleLoader<Platform>*> loaders = ModuleRegistry::getInstance()->findModules<Platform>();
+		for(std::vector<ModuleLoader<Platform>*>::iterator it=loaders.begin(); it!=loaders.end(); it++) {
+			Platform *platform = (*it)->create();
+
+			if (platform) {
+				platform->retain();
+				platform->onInit();
+
+				this->platforms.push_back(platform);
+			}
+		}
+
+		assert(platforms.empty() == false);
+		if (platforms.empty()) {
+			return false;
+		}
 	}
 
-	// initialize the new engine
-	if (engine->onInit() == false) {
-		return false;
+	// try to find a valid application object
+	if (this->application == NULL) {
+		std::vector<ModuleLoader<Application>*> loaders = ModuleRegistry::getInstance()->findModules<Application>();
+		for(std::vector<ModuleLoader<Application>*>::iterator it=loaders.begin(); it!=loaders.end(); it++) {
+			Application *app = (*it)->create();
+			if (app) {
+				this->application = app;
+				this->application->retain();
+				this->application->onInit();
+			}
+		}
+
+		assert(application);
+		if (application == NULL) {
+			return false;
+		}
 	}
 
-	// store the new instance
-	current_instance = engine;
-
-	// success
 	return true;
 }
 
 
-bool Engine::shutdown() {
-	if (current_instance == NULL) {
-		return false;
+FileSystem *Engine::getRootFileSystem() {
+	for(std::vector<Platform*>::reverse_iterator it=platforms.rbegin(); it!=platforms.rend(); it++) {
+		Platform *platform = *it;
+
+		FileSystem *fs = platform->getRootFileSystem();
+		if (fs) {
+			return fs;
+		}
 	}
 
-	// shutdown
-	current_instance->onShutdown();
-	delete current_instance;
-	current_instance = NULL;
+	return NULL;
+}
+
+
+FileSystem *Engine::getAssetFileSystem() {
+	for(std::vector<Platform*>::reverse_iterator it=platforms.rbegin(); it!=platforms.rend(); it++) {
+		Platform *platform = *it;
+
+		FileSystem *fs = platform->getAssetFileSystem();
+		if (fs) {
+			return fs;
+		}
+	}
+
+	return NULL;
+}
+
+
+bool Engine::shutdown() {
+	// release the application object
+	if (application) {
+		application->onShutdown();
+		application->release();
+		application = NULL;
+	}
+
+	// release all platforms
+	for(std::vector<Platform*>::reverse_iterator it=platforms.rbegin(); it!=platforms.rend(); it++) {
+		Platform *platform = *it;
+		platform->onShutdown();
+		platform->release();
+	}
+
+	platforms.clear();
 
 	// done
 	return true;
 }
 
 
-void Engine::run(Application *application) {
-	// no other application running
-	assert(current_app == NULL);
-	if (current_app) {
+void Engine::run() {
+	// check, if a platform object is available
+	assert(platforms.empty() == false);
+	if (platforms.empty()) {
 		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();
+	for(std::vector<Platform*>::iterator it=platforms.begin(); it!=platforms.end(); it++) {
+		(*it)->onRunFirst();
+	}
 
 	// timers
 	clock_t last_t = clock();
 
 	bool done = false;
 	do {
-		done = current_instance->onRun();
+		done = false;
+
+		for(std::vector<Platform*>::iterator it=platforms.begin(); it!=platforms.end(); it++) {
+			Platform *platform = *it;
+			done |= platform->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()) {
+		switch(getState()) {
 			case Engine_Uninitialized: {
 				// 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();
+				// run all updateable objects
+				for(int i=updateables.size(); --i>=0;) {
+					updateables.at(i)->update(dt);
 				}
 
 				break;
 			}
 		}
 
+		// the application's onRun will be invoked every frame
+		// the application may decide itself, what to do in each state
+		application->onRun(dt);
+
 		// purge all dead objects at the end of each frame
 		SharedObject::purgeDeadObjects();
 
 	}
 	while(!done);
 
-	// release the current app
-	current_app->onShutdown();
-
-	// clear current application
-	current_app = NULL;
-
 	return;
 }
 
 
 
 void Engine::startApp() {
-	assert(current_instance != NULL);
-	assert(current_app != NULL);
+	assert(application != NULL);
 
-	switch(current_instance->getState()) {
+	switch(getState()) {
 		case Engine_Uninitialized: {
-			if (current_app) {
-				current_app->onInit();
+			if (application) {
+				application->onInit();
 			}
 
-			current_instance->state = Engine_Background;
+			state = Engine_Background;
 
 			break;
 		}
 
 
 void Engine::enterBackground() {
-	assert(current_instance != NULL);
-	assert(current_app != NULL);
+	assert(application != NULL);
 
-	switch(current_instance->getState()) {
+	switch(getState()) {
 		case Engine_Running: {
-			if (current_app != NULL) {
-				current_app->onEnterBackground();
+			if (application != NULL) {
+				application->onEnterBackground();
 			}
 
-			current_instance->state = Engine_Background;
+			state = Engine_Background;
 
 			break;
 		}
 
 
 void Engine::enterForeground() {
-	assert(current_instance != NULL);
-	assert(current_app != NULL);
+	assert(application != NULL);
 
-	switch(current_instance->getState()) {
+	switch(getState()) {
 		case Engine_Background: {
-			if (current_app != NULL) {
-				current_app->onEnterForeground();
+			if (application != NULL) {
+				application->onEnterForeground();
 			}
 
-			current_instance->state = Engine_Running;
+			state = Engine_Running;
 
 			break;
 		}
 
 
 void Engine::suspendApp() {
-	assert(current_instance != NULL);
-	assert(current_app != NULL);
+	assert(application != NULL);
 
-	switch(current_instance->getState()) {
+	switch(getState()) {
 		case Engine_Running: {
 			enterBackground();
 
 		}
 
 		case Engine_Background: {
-			if (current_app) {
-				current_app->onSuspend();
+			if (application) {
+				application->onSuspend();
 			}
 
-			current_instance->state = Engine_Suspended;
+			state = Engine_Suspended;
 
 			break;
 		}
 
 
 void Engine::resumeSuspendedApp() {
-	assert(current_instance != NULL);
-	assert(current_app != NULL);
+	assert(application != NULL);
 
-	switch(current_instance->getState()) {
+	switch(getState()) {
 		case Engine_Suspended: {
-			if (current_app) {
-				current_app->onResumeSuspended();
+			if (application) {
+				application->onResumeSuspended();
 			}
 
-			current_instance->state = Engine_Background;
+			state = Engine_Background;
 
 			break;
 		}

src/core/wiesel/engine.h

 
 #include <wiesel/wiesel-core.def>
 
-#include "screen.h"
+#include "platform.h"
 #include "application.h"
 #include "engine_interfaces.h"
 
 	 * @brief An interface to the game engine.
 	 */
 	class WIESEL_CORE_EXPORT Engine {
-	protected:
+	private:
 		Engine();
 		virtual ~Engine();
 
+	// getter
 	public:
 		/**
 		 * @brief get the currently active Engine instance.
 		 */
-		inline static Engine *getCurrent() {
-			return current_instance;
+		inline static Engine *getInstance() {
+			return &instance;
+		}
+
+		/**
+		 * @brief get the current platform, this engine is running on.
+		 */
+		inline const std::vector<Platform*> *getPlatforms() {
+			return &platforms;
 		}
 
 		/**
 		 * @brief get the current running application or \c NULL, if none
 		 */
-		inline static Application *getApplication() {
-			return current_app;
+		inline Application *getApplication() {
+			return application;
 		}
 
 		/**
-		 * @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.
+		 * @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.
 		 */
-		static WIESEL_CORE_EXPORT bool install(Engine *engine);
+		FileSystem *getRootFileSystem();
+
+		/**
+		 * @brief get the file system, which stores the assets of the current application.
+		 */
+		FileSystem *getAssetFileSystem();
+
+	// lifecycle
+	public:
+		/**
+		 * @brief initialize the engine.
+		 */
+		bool initialize(int argc, char* argv[]);
 
 		/**
 		 * @brief terminate the currently registered engine.
 		 * Also terminates the currently runnung \ref Application instance.
 		 */
-		static WIESEL_CORE_EXPORT bool shutdown();
+		bool shutdown();
 
 		/**
-		 * @brief starts the main loop with the currently installed engine.
+		 * @brief starts the main loop.
 		 */
-		static WIESEL_CORE_EXPORT void run(Application *application);
+		void run();
 
 		/**
 		 * @brief requests to stop the main loop after the current frame.
 		 */
-		static void requestExit();
+		void requestExit();
 
 	// register/remove objects
 	public:
 			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:
 		/**
 		 * Fails, if no application is available.
 		 * In other states, this method will have no effect.
 		 */
-		static void startApp();
+		void startApp();
 
 		/**
 		 * @brief the application will enter the background.
 		 */
-		static void enterBackground();
+		void enterBackground();
 
 		/**
 		 * @brief the application will enter the foreground.
 		 */
-		static void enterForeground();
+		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();
+		void suspendApp();
 
 		/**
 		 * @brief resumes a suspended application.
 		 * 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;
+		void resumeSuspendedApp();
 
 	// static members
 	private:
-		static WIESEL_CORE_EXPORT Engine*			    current_instance;
-		static WIESEL_CORE_EXPORT Application*		current_app;
-		static WIESEL_CORE_EXPORT bool				exit_requested;
-
+		static WIESEL_CORE_EXPORT Engine	instance;
+	
 	// instance members
-	protected:
-		Screen*		screen;
-
 	private:
 		std::vector<IUpdateable*>		updateables;
 
 		EngineState						state;
+		bool							exit_requested;
+
+		std::vector<Platform*>			platforms;
+		Application*					application;
 	};
 
 }

src/core/wiesel/gl/texture/texture.cpp

 #include <wiesel/resources/graphics/image.h>
 #include <wiesel/resources/graphics/imageutils.h>
 #include <wiesel/resources/graphics/image_loader.h>
-#include <wiesel/modules.h>
+#include <wiesel/module_registry.h>
 
 
 using namespace wiesel;

src/core/wiesel/graph/2d/multisprite_node.cpp

 #include "wiesel/gl/shader/shaders.h"
 #include "wiesel/gl/texture/spriteframe.h"
 #include "wiesel/gl/vbo/indexbuffer.h"
+#include "wiesel/video/video_device.h"
 
 using namespace wiesel;
+using namespace wiesel::video;
 
 
 MultiSpriteNode::MultiSpriteNode() {
 }
 
 
-void MultiSpriteNode::onDraw() {
+void MultiSpriteNode::onDraw(video::VideoDevice *video_device) {
 	if (texture && !entries.empty()) {
 		if (vbo_dirty) {
 			rebuildVertexBuffer();
 		}
 
 		shader->bind();
-		shader->setProjectionMatrix(Engine::getCurrent()->getScreen()->getProjectionMatrix());
+		shader->setProjectionMatrix(video_device->getProjectionMatrix());
 		shader->setModelviewMatrix(getWorldTransform());
 
 		vbo->bind(shader, texture);

src/core/wiesel/graph/2d/multisprite_node.h

 
 	// overridables
 	protected:
-		virtual void onDraw();
+		virtual void onDraw(video::VideoDevice *video_device);
 
 		virtual void rebuildVertexBuffer();
 

src/core/wiesel/graph/2d/sprite_node.cpp

 #include "wiesel/engine.h"
 #include "wiesel/gl/shader/shaders.h"
 #include "wiesel/gl/texture/spriteframe.h"
+#include "wiesel/video/video_device.h"
 
 using namespace wiesel;
 
 }
 
 
-void SpriteNode::onDraw() {
+void SpriteNode::onDraw(video::VideoDevice *video_device) {
 	if (texture) {
 		if (vbo_dirty) {
 			rebuildVertexBuffer();
 		}
 
 		shader->bind();
-		shader->setProjectionMatrix(Engine::getCurrent()->getScreen()->getProjectionMatrix());
+		shader->setProjectionMatrix(video_device->getProjectionMatrix());
 		shader->setModelviewMatrix(getWorldTransform());
 
 		vbo->bind(shader, texture);

src/core/wiesel/graph/2d/sprite_node.h

 
 	// overridables
 	protected:
-		virtual void onDraw();
+		virtual void onDraw(video::VideoDevice *video_device);
 
 		virtual void rebuildVertexBuffer();
 

src/core/wiesel/graph/node.cpp

 #include "node.h"
 
 #include "wiesel/engine.h"
+#include "wiesel/video/video_device.h"
 
 #include <assert.h>
 #include <algorithm>
 }
 
 
-vector2d Node::convertScreenToLocal(const vector2d& screen) {
+vector2d Node::convertScreenToLocal(video::VideoDevice *video_device, const vector2d& screen) {
 	// at first, convert into OpenGL coordinate space
 	vector2d transformed = vector2d(
-			+(screen.x / Engine::getCurrent()->getScreen()->getSize().width  - 0.5f) * 2,
-			-(screen.y / Engine::getCurrent()->getScreen()->getSize().height - 0.5f) * 2
+			+(screen.x / video_device->getResolution().width  - 0.5f) * 2,
+			-(screen.y / video_device->getResolution().height - 0.5f) * 2
 	);
 
 	// then use the projection- and modelview matrix to get the actual coordinate system
 	return
 			transformed
-		/	Engine::getCurrent()->getScreen()->getProjectionMatrix()
+		/	video_device->getProjectionMatrix()