Permalink
Browse files

#13 Transitioned to SDL2.0

  • Loading branch information...
volca02 committed Apr 28, 2014
1 parent 3730a5d commit 851d36f4c66300b08f61a95e38cd662aed22c963
Showing with 896 additions and 1,277 deletions.
  1. +9 −10 CMakeLists.txt
  2. +93 −0 cmake/FindSDL2.cmake
  3. +1 −1 doc/DEVELOPERS
  4. +0 −1 proto/python/CMakeLists.txt
  5. +1 −2 src/base/CMakeLists.txt
  6. +0 −2 src/base/console/CMakeLists.txt
  7. +0 −156 src/base/console/ConsoleFrontend.cpp
  8. +0 −75 src/base/console/ConsoleFrontend.h
  9. +0 −1 src/bindings/CMakeLists.txt
  10. +4 −5 src/main/CMakeLists.txt
  11. +7 −27 src/main/GameLoadState.cpp
  12. +5 −9 src/main/GameLoadState.h
  13. +56 −116 src/main/GamePlayState.cpp
  14. +6 −12 src/main/GamePlayState.h
  15. +24 −45 src/main/GameState.h
  16. +24 −51 src/main/GameStateManager.cpp
  17. +10 −21 src/main/GameStateManager.h
  18. +0 −1 src/main/Root.cpp
  19. +0 −1 src/main/Root.h
  20. +3 −3 src/services/binary/BinaryService.h
  21. +19 −18 src/services/config/ConfigService.cpp
  22. +11 −10 src/services/config/ConfigService.h
  23. +0 −1 src/services/gui/CMakeLists.txt
  24. +42 −41 src/services/gui/ConsoleGUI.cpp
  25. +4 −6 src/services/gui/ConsoleGUI.h
  26. +41 −66 src/services/gui/GUIService.cpp
  27. +27 −32 src/services/gui/GUIService.h
  28. +0 −2 src/services/input/CMakeLists.txt
  29. +218 −364 src/services/input/InputService.cpp
  30. +38 −63 src/services/input/InputService.h
  31. +0 −1 src/services/light/CMakeLists.txt
  32. +0 −1 src/services/loop/CMakeLists.txt
  33. +0 −1 src/services/material/CMakeLists.txt
  34. +143 −34 src/services/render/RenderService.cpp
  35. +20 −7 src/services/render/RenderService.h
  36. +0 −1 src/services/script/CMakeLists.txt
  37. +90 −90 src/services/worldrep/LightmapAtlas.h
View
@@ -156,15 +156,14 @@ ENDIF(GLOBAL_DEBUG)
# Solve the dependencies
-SET(OIS_DIR ${CMAKE_MODULE_PATH})
SET(ODE_DIR ${CMAKE_MODULE_PATH})
SET(OGRE_DIR ${CMAKE_MODULE_PATH})
SET(FREEIMAGE_DIR ${CMAKE_MODULE_PATH})
-FIND_PACKAGE(OIS REQUIRED)
FIND_PACKAGE(ODE REQUIRED)
FIND_PACKAGE(OGRE REQUIRED)
FIND_PACKAGE(FREEIMAGE REQUIRED)
+FIND_PACKAGE(SDL2 REQUIRED)
# Documentation
# On Ubuntu, the following command does not search for Dot :(
@@ -196,6 +195,14 @@ ELSE(ODE_FOUND)
MESSAGE(FATAL_ERROR "ODE not found and selected in options!")
ENDIF(ODE_FOUND)
+IF(SDL2_FOUND)
+ MESSAGE(STATUS "SDL2 Found OK")
+ MESSAGE(STATUS " - SDL2 includes ${SDL2_INCLUDE_DIR}")
+ MESSAGE(STATUS " - SDL2 libs ${SDL2_LIBRARIES}")
+ELSE(SDL2_FOUND)
+ MESSAGE(FATAL_ERROR "SDL2 not found!")
+ENDIF(SDL2_FOUND)
+
FIND_PACKAGE(PythonLibs REQUIRED)
SET(OPDE_PYTHON_LIBRARIES optimized ${PYTHON_LIBRARIES} debug ${PYTHON_DEBUG_LIBRARIES})
@@ -214,14 +221,6 @@ ELSE(OPDE_PYTHON_LIBRARIES)
ENDIF(OPDE_PYTHON_LIBRARIES)
# Only visual check enabling verbose output, and package found info
-IF(OIS_FOUND)
- MESSAGE(STATUS "OIS Found OK")
- MESSAGE(STATUS " - OIS includes ${OIS_INCLUDE_DIR}")
- MESSAGE(STATUS " - OIS libs ${OIS_LIBRARIES}")
-ELSE(OIS_FOUND)
- MESSAGE(FATAL_ERROR "OIS not found")
-ENDIF(OIS_FOUND)
-
IF(OGRE_FOUND)
MESSAGE(STATUS "OGRE Found OK")
MESSAGE(STATUS " - Ogre includes ${OGRE_INCLUDE_DIR}")
View
@@ -0,0 +1,93 @@
+# - Find SDL2 library and headers
+#
+# Find module for SDL 2.0 (http://www.libsdl.org/).
+# It defines the following variables:
+# SDL2_INCLUDE_DIRS - The location of the headers, e.g., SDL.h.
+# SDL2_LIBRARIES - The libraries to link against to use SDL2.
+# SDL2_FOUND - If false, do not try to use SDL2.
+# SDL2_VERSION_STRING - Human-readable string containing the version of SDL2.
+#
+# This module responds to the the flag:
+# SDL2_BUILDING_LIBRARY
+# If this is defined, then no SDL2_main will be linked in because
+# only applications need main().
+# Otherwise, it is assumed you are building an application and this
+# module will attempt to locate and set the the proper link flags
+# as part of the returned SDL2_LIBRARIES variable.
+#
+# Also defined, but not for general use are:
+# SDL2_INCLUDE_DIR - The directory that contains SDL.h.
+# SDL2_LIBRARY - The location of the SDL2 library.
+# SDL2MAIN_LIBRARY - The location of the SDL2main library.
+#
+
+#=============================================================================
+# Copyright 2013 Benjamin Eikel
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+find_package(PkgConfig QUIET)
+pkg_check_modules(PC_SDL2 QUIET sdl2)
+
+find_path(SDL2_INCLUDE_DIR
+ NAMES SDL.h
+ HINTS
+ ${PC_SDL2_INCLUDEDIR}
+ ${PC_SDL2_INCLUDE_DIRS}
+ PATH_SUFFIXES SDL2
+)
+
+find_library(SDL2_LIBRARY
+ NAMES SDL2
+ HINTS
+ ${PC_SDL2_LIBDIR}
+ ${PC_SDL2_LIBRARY_DIRS}
+ PATH_SUFFIXES x64 x86
+)
+
+# VOLCA: commented out the SDL2main
+#if(NOT SDL2_BUILDING_LIBRARY)
+# find_library(SDL2MAIN_LIBRARY
+# NAMES SDL2main
+# HINTS
+# ${PC_SDL2_LIBDIR}
+# ${PC_SDL2_LIBRARY_DIRS}
+# PATH_SUFFIXES x64 x86
+# )
+#endif()
+
+if(SDL2_INCLUDE_DIR AND EXISTS "${SDL2_INCLUDE_DIR}/SDL_version.h")
+ file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+[0-9]+$")
+ file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MINOR_VERSION[ \t]+[0-9]+$")
+ file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_PATCHLEVEL[ \t]+[0-9]+$")
+ string(REGEX REPLACE "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_MAJOR "${SDL2_VERSION_MAJOR_LINE}")
+ string(REGEX REPLACE "^#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_MINOR "${SDL2_VERSION_MINOR_LINE}")
+ string(REGEX REPLACE "^#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_PATCH "${SDL2_VERSION_PATCH_LINE}")
+ set(SDL2_VERSION_STRING ${SDL2_VERSION_MAJOR}.${SDL2_VERSION_MINOR}.${SDL2_VERSION_PATCH})
+ unset(SDL2_VERSION_MAJOR_LINE)
+ unset(SDL2_VERSION_MINOR_LINE)
+ unset(SDL2_VERSION_PATCH_LINE)
+ unset(SDL2_VERSION_MAJOR)
+ unset(SDL2_VERSION_MINOR)
+ unset(SDL2_VERSION_PATCH)
+endif()
+
+set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR})
+# VOLCA: commented out the SDL2main set(SDL2_LIBRARIES ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY})
+set(SDL2_LIBRARIES ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY})
+
+include(FindPackageHandleStandardArgs)
+
+find_package_handle_standard_args(SDL2
+ REQUIRED_VARS SDL2_INCLUDE_DIR SDL2_LIBRARY
+ VERSION_VAR SDL2_VERSION_STRING)
+
+mark_as_advanced(SDL2_INCLUDE_DIR SDL2_LIBRARY)
View
@@ -9,7 +9,7 @@ Last updated on 19-Oct-2008
OPDE needs:
* OGRE3D library, version 1.7
* FreeImage library
-* OIS (The part of Ogre SDK under windows, do not install separately)
+* SDL2
* CMake
* Python
* For documentation builds: epydoc, texi2html, doxygen and graphviz
@@ -8,7 +8,6 @@ INCLUDE( ${OPDE_SOURCE_DIR}/src/base/Base.cmake )
include_directories(
${ODE_INCLUDE_DIR}
${OGRE_INCLUDE_DIR}
- ${OIS_INCLUDE_DIR}
${OPDE_BINARY_DIR}
${OPDE_BASE_INCLUDES}
${OPDE_SERVICE_INCLUDES}
View
@@ -3,9 +3,8 @@
INCLUDE(${OPDE_SOURCE_DIR}/src/base/Base.cmake)
include_directories(
- ${ODE_INCLUDE_DIR}
+ ${ODE_INCLUDE_DIR}
${OGRE_INCLUDE_DIR}
- ${OIS_INCLUDE_DIR}
${OPDE_BINARY_DIR}
${OPDE_BASE_INCLUDES}
${OPDE_SOURCE_DIR}/src/base/Dark
@@ -14,8 +14,6 @@ link_directories ( ${OGRE_LIB_DIR} )
add_library (OpdeConsole STATIC
ConsoleBackend.cpp
ConsoleBackend.h
- ConsoleFrontend.cpp
- ConsoleFrontend.h
ConsoleCommandListener.cpp
ConsoleCommandListener.h
)
@@ -1,156 +0,0 @@
-/******************************************************************************
- *
- * This file is part of openDarkEngine project
- * Copyright (C) 2005-2006 openDarkEngine team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- *
- *****************************************************************************/
-
-#include "config.h"
-#include "ConsoleFrontend.h"
-#include "ConsoleBackend.h"
-
-#include "OpdeException.h"
-
-#include <OIS.h>
-#include <string.h>
-
-
-using namespace Ogre;
-using namespace OIS;
-using namespace std;
-
-namespace Opde {
-
- ConsoleFrontend::ConsoleFrontend() : mIsActive(false) {
- mRoot = Root::getSingletonPtr();
- mOverlayMgr = OverlayManager::getSingletonPtr();
-
- mConsoleOverlay = OverlayManager::getSingleton().getByName("Opde/Console");
-
- if (mConsoleOverlay == NULL)
- OPDE_EXCEPT("Could not create console overlay!", "ConsoleFrontend::ConsoleFrontend");
-
-
- mConsoleOverlay->hide();
-
- // prepare the handle to the Opde/CommandLine
- mCommandLine = OverlayManager::getSingleton().getOverlayElement("Opde/CommandLine");
-
- mConsoleText = OverlayManager::getSingleton().getOverlayElement("Opde/ConsoleText");
-
- mConsoleBackend = ConsoleBackend::getSingletonPtr();
-
- mPosition = -1; // follow
- }
-
- ConsoleFrontend::~ConsoleFrontend() {
- mConsoleOverlay->hide();
- }
-
- void ConsoleFrontend::setActive(bool active) {
- mIsActive = active;
- }
-
- bool ConsoleFrontend::injectKeyPress(const OIS::KeyEvent &e) {
- if (!mIsActive)
- return false;
-
- if (e.key == KC_RETURN) {
- ConsoleBackend::getSingleton().executeCommand(mCommand);
- mCommand = "";
- } else if (e.key == KC_BACK) {
- mCommand = mCommand.substr(0, mCommand.length()-1);
- } else if (e.key == KC_PGUP) {
- mPosition -= 28; // let two lines be the same
- mConsoleBackend->setChanged();
- } else if (e.key == KC_PGDOWN) {
- mPosition += 28;
- mConsoleBackend->setChanged();
- } else if (e.key == KC_END) {
- mPosition = -1;
- mConsoleBackend->setChanged();
- }else if (e.key == KC_HOME) {
- mPosition = 0;
- mConsoleBackend->setChanged();
- }
- else {
- string allowed = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ,./:;'-_+=[]{}()| \"\t";
- /*
- string key = "" + (char)(e.text);
-
- if (allowed.find(key) != string::npos) {
- mCommand += key;
- }*/
-
- char key[2];
- key[0] = (char)(e.text);
- key[1] = 0;
-
- if (allowed.find(key) != string::npos)
- mCommand += key;
- }
-
- mCommandLine->setCaption(">" + mCommand);
-
- return true;
-
- }
-
- void ConsoleFrontend::update(int timems) {
- if (mIsActive) {
- mConsoleOverlay->show();
- if (mConsoleBackend->getChanged()) {
- // need to update the text window
- std::vector< ConsoleBackend::Message > texts;
- mConsoleBackend->pullMessages(texts, mPosition, 30);
-
- String text;
-
- std::vector< ConsoleBackend::Message >::iterator it = texts.begin();
-
- for (;it != texts.end(); ++it) {
- text += it->second + "\n";
- }
-
- mConsoleText->setCaption(text);
- }
- } else
- mConsoleOverlay->hide();
- /*
- Real scrollY = mConsoleOverlay->_getTop();
-
- if (mIsActive && scrollY < 0) {
- scrollY += timems/1000;
-
- if (scrollY > 1)
- scrollY = 1;
-
- mConsoleOverlay->setTop(scrollY);
- }
-
- if (!mIsActive && scrollY > -0.5) {
- scrollY -= timems/1000;
-
- if (scrollY < -0.5)
- scrollY = -0.5;
-
- mConsoleOverlay->setTop(scrollY);
- }*/
- }
-}
Oops, something went wrong.

0 comments on commit 851d36f

Please sign in to comment.