summaryrefslogtreecommitdiff
path: root/games/dustrac/files/patch-git6a7c41
diff options
context:
space:
mode:
Diffstat (limited to 'games/dustrac/files/patch-git6a7c41')
-rw-r--r--games/dustrac/files/patch-git6a7c41451
1 files changed, 451 insertions, 0 deletions
diff --git a/games/dustrac/files/patch-git6a7c41 b/games/dustrac/files/patch-git6a7c41
new file mode 100644
index 000000000000..9c96044d3d73
--- /dev/null
+++ b/games/dustrac/files/patch-git6a7c41
@@ -0,0 +1,451 @@
+diff --git CMakeLists.txt CMakeLists.txt
+index 5921d71..1692ee0 100644
+--- CMakeLists.txt
++++ CMakeLists.txt
+@@ -39,6 +39,9 @@ endif()
+ if(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -W -Wall -O3 -pedantic")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fomit-frame-pointer -finline-functions -ffast-math")
++elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -W -Wall -O3 -pedantic")
++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fomit-frame-pointer -finline-functions -ffast-math")
+ endif()
+
+ set(GAME_BINARY_NAME "dustrac-game")
+diff --git src/game/MiniCore/CMakeLists.txt src/game/MiniCore/CMakeLists.txt
+index 5144d1a..286cfc9 100644
+--- src/game/MiniCore/CMakeLists.txt
++++ src/game/MiniCore/CMakeLists.txt
+@@ -29,6 +29,7 @@ Graphics/mcglobjectbase.cc
+ Graphics/mcglpointparticlerenderer.cc
+ Graphics/mcglscene.cc
+ Graphics/mcglshaderprogram.cc
++Graphics/mcrenderlayer.cc
+ Graphics/mcshaders.hh
+ Graphics/mcshaders30.hh
+ Graphics/mcshadersGLES.hh
+diff --git src/game/MiniCore/Graphics/mcrenderlayer.cc src/game/MiniCore/Graphics/mcrenderlayer.cc
+new file mode 100644
+index 0000000..c5f9016
+--- /dev/null
++++ src/game/MiniCore/Graphics/mcrenderlayer.cc
+@@ -0,0 +1,52 @@
++// This file belongs to the "MiniCore" game engine.
++// Copyright (C) 2014 Jussi Lind <jussi.lind@iki.fi>
++//
++// 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., 51 Franklin Street, Fifth Floor, Boston,
++// MA 02110-1301, USA.
++//
++
++#include "mcrenderlayer.hh"
++#include "mccamera.hh"
++#include "mcobject.hh"
++
++MCRenderLayer::MCRenderLayer()
++ : m_depthTestEnabled(false)
++{
++}
++
++void MCRenderLayer::setDepthTestEnabled(bool enable)
++{
++ m_depthTestEnabled = enable;
++}
++
++bool MCRenderLayer::depthTestEnabled() const
++{
++ return m_depthTestEnabled;
++}
++
++MCRenderLayer::ObjectSet & MCRenderLayer::objectSet()
++{
++ return m_objectSet;
++}
++
++MCRenderLayer::CameraBatchMap & MCRenderLayer::objectBatches()
++{
++ return m_objectBatches;
++}
++
++MCRenderLayer::CameraBatchMap & MCRenderLayer::particleBatches()
++{
++ return m_particleBatches;
++}
+diff --git src/game/MiniCore/Graphics/mcrenderlayer.hh src/game/MiniCore/Graphics/mcrenderlayer.hh
+new file mode 100644
+index 0000000..0b2fae4
+--- /dev/null
++++ src/game/MiniCore/Graphics/mcrenderlayer.hh
+@@ -0,0 +1,63 @@
++// This file belongs to the "MiniCore" game engine.
++// Copyright (C) 2014 Jussi Lind <jussi.lind@iki.fi>
++//
++// 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., 51 Franklin Street, Fifth Floor, Boston,
++// MA 02110-1301, USA.
++//
++
++#ifndef MCRENDERLAYER_HH
++#define MCRENDERLAYER_HH
++
++#include <map>
++#include <unordered_set>
++#include <vector>
++
++class MCCamera;
++class MCObject;
++
++class MCRenderLayer
++{
++public:
++
++ MCRenderLayer();
++
++ void setDepthTestEnabled(bool enable);
++
++ bool depthTestEnabled() const;
++
++ typedef std::unordered_set<MCObject *> ObjectSet;
++
++ ObjectSet & objectSet();
++
++ typedef int ObjectTypeId;
++ typedef std::map<ObjectTypeId, std::vector<MCObject *> > BatchMap;
++ typedef std::map<MCCamera *, BatchMap> CameraBatchMap;
++
++ CameraBatchMap & objectBatches();
++
++ CameraBatchMap & particleBatches();
++
++private:
++
++ bool m_depthTestEnabled;
++
++ ObjectSet m_objectSet;
++
++ CameraBatchMap m_objectBatches;
++
++ CameraBatchMap m_particleBatches;
++};
++
++#endif // MCRENDERLAYER_HH
+diff --git src/game/MiniCore/Graphics/mcworldrenderer.cc src/game/MiniCore/Graphics/mcworldrenderer.cc
+index 41e6607..ab8cb8a 100644
+--- src/game/MiniCore/Graphics/mcworldrenderer.cc
++++ src/game/MiniCore/Graphics/mcworldrenderer.cc
+@@ -31,10 +31,6 @@
+
+ MCWorldRenderer::MCWorldRenderer()
+ {
+- for (unsigned i = 0; i < MCWorld::MaxLayers; i++)
+- {
+- m_depthTestEnabled[i] = false;
+- }
+ }
+
+ void MCWorldRenderer::registerPointParticleRenderer(MCUint typeId, MCGLPointParticleRenderer & renderer)
+@@ -61,13 +57,15 @@ void MCWorldRenderer::buildBatches(MCCamera * camera)
+ // Grouping the objects like this reduces texture switches etc and increases
+ // overall performance.
+
+- for (int i = 0; i < MCWorld::MaxLayers; i++)
++ auto layerIter = m_layers.begin();
++ while (layerIter != m_layers.end())
+ {
+- m_objectBatches[camera][i].clear();
+- m_particleBatches[camera][i].clear();
++ MCRenderLayer & layer = layerIter->second;
+
+- const auto end = m_layers[i].end();
+- for (auto objectIter = m_layers[i].begin(); objectIter != end; objectIter++)
++ layer.objectBatches().clear();
++ layer.particleBatches().clear();
++
++ for (auto objectIter = layer.objectSet().begin(); objectIter != layer.objectSet().end(); objectIter++)
+ {
+ MCObject & object = **objectIter;
+ if (object.isRenderable())
+@@ -83,7 +81,7 @@ void MCWorldRenderer::buildBatches(MCCamera * camera)
+ bbox.translate(MCVector2dF(object.location()));
+ if (!camera || camera->isVisible(bbox))
+ {
+- m_objectBatches[camera][i][object.typeID()].push_back(&object);
++ layer.objectBatches()[camera][object.typeID()].push_back(&object);
+ }
+ }
+ }
+@@ -93,7 +91,7 @@ void MCWorldRenderer::buildBatches(MCCamera * camera)
+ {
+ if (camera->isVisible(object.bbox()))
+ {
+- m_particleBatches[camera][i][object.typeID()].push_back(&object);
++ layer.particleBatches()[camera][object.typeID()].push_back(&object);
+ }
+ else
+ {
+@@ -120,12 +118,14 @@ void MCWorldRenderer::buildBatches(MCCamera * camera)
+ }
+ else
+ {
+- m_particleBatches[camera][i][object.typeID()].push_back(&object);
++ layer.particleBatches()[camera][object.typeID()].push_back(&object);
+ }
+ }
+ }
+ }
+ }
++
++ layerIter++;
+ }
+ }
+
+@@ -135,11 +135,14 @@ void MCWorldRenderer::renderBatches(MCCamera * camera)
+ // layer-specific.
+
+ bool depthTest = false;
+- for (int layer = 0; layer < MCWorld::MaxLayers; layer++)
++ auto layerIter = m_layers.begin();
++ while (layerIter != m_layers.end())
+ {
++ MCRenderLayer & layer = layerIter->second;
++
+ // The depth test is enabled/disabled separately on
+ // each object layer.
+- if (m_depthTestEnabled[layer] && !depthTest)
++ if (layer.depthTestEnabled() && !depthTest)
+ {
+ glEnable(GL_DEPTH_TEST);
+ depthTest = true;
+@@ -152,13 +155,15 @@ void MCWorldRenderer::renderBatches(MCCamera * camera)
+
+ renderObjectBatches(camera, layer);
+ renderParticleBatches(camera, layer);
++
++ layerIter++;
+ }
+ }
+
+-void MCWorldRenderer::renderObjectBatches(MCCamera * camera, int layer)
++void MCWorldRenderer::renderObjectBatches(MCCamera * camera, MCRenderLayer & layer)
+ {
+- auto iter = m_objectBatches[camera][layer].begin();
+- const auto end = m_objectBatches[camera][layer].end();
++ auto iter = layer.objectBatches()[camera].begin();
++ const auto end = layer.objectBatches()[camera].end();
+ while (iter != end)
+ {
+ const int itemCountInBatch = iter->second.size();
+@@ -185,11 +190,11 @@ void MCWorldRenderer::renderObjectBatches(MCCamera * camera, int layer)
+ }
+ }
+
+-void MCWorldRenderer::renderParticleBatches(MCCamera * camera, int layer)
++void MCWorldRenderer::renderParticleBatches(MCCamera * camera, MCRenderLayer & layer)
+ {
+ // Render particle batches
+- auto batchIter = m_particleBatches[camera][layer].begin();
+- const auto end = m_particleBatches[camera][layer].end();
++ auto batchIter = layer.particleBatches()[camera].begin();
++ const auto end = layer.particleBatches()[camera].end();
+ while (batchIter != end)
+ {
+ if (!batchIter->second.size())
+@@ -233,17 +238,20 @@ void MCWorldRenderer::renderShadows(MCCamera * camera)
+ {
+ glDisable(GL_DEPTH_TEST);
+
+- for (int i = 0; i < MCWorld::MaxLayers; i++)
++ auto layerIter = m_layers.begin();
++ while (layerIter != m_layers.end())
+ {
++ MCRenderLayer & layer = layerIter->second;
++
+ // Render batches
+- auto iter = m_objectBatches[camera][i].begin();
+- const auto end = m_objectBatches[camera][i].end();
+- while (iter != end)
++ auto batchIter = layer.objectBatches()[camera].begin();
++ const auto end = layer.objectBatches()[camera].end();
++ while (batchIter != end)
+ {
+- const int itemCountInBatch = iter->second.size();
++ const int itemCountInBatch = batchIter->second.size();
+ if (itemCountInBatch > 0)
+ {
+- MCObject * object = iter->second[0];
++ MCObject * object = batchIter->second[0];
+ std::shared_ptr<MCShapeView> view = object->shape()->view();
+ if (view && view->hasShadow())
+ {
+@@ -252,10 +260,10 @@ void MCWorldRenderer::renderShadows(MCCamera * camera)
+
+ for (int i = 1; i < itemCountInBatch - 1; i++)
+ {
+- iter->second[i]->renderShadow(camera);
++ batchIter->second[i]->renderShadow(camera);
+ }
+
+- object = iter->second[itemCountInBatch - 1];
++ object = batchIter->second[itemCountInBatch - 1];
+ object->renderShadow(camera);
+
+ view = object->shape()->view();
+@@ -263,31 +271,26 @@ void MCWorldRenderer::renderShadows(MCCamera * camera)
+ }
+ }
+
+- iter++;
++ batchIter++;
+ }
++
++ layerIter++;
+ }
+ }
+
+ void MCWorldRenderer::enableDepthTestOnLayer(int layer, bool enable)
+ {
+- if (layer < MCWorld::MaxLayers)
+- {
+- m_depthTestEnabled[layer] = enable;
+- }
++ m_layers[layer].setDepthTestEnabled(enable);
+ }
+
+ void MCWorldRenderer::addToLayerMap(MCObject & object)
+ {
+- const int layerIndex =
+- object.renderLayer() >= MCWorld::MaxLayers ? MCWorld::MaxLayers - 1 : object.renderLayer();
+- m_layers[layerIndex].insert(&object);
++ m_layers[object.renderLayer()].objectSet().insert(&object);
+ }
+
+ void MCWorldRenderer::removeFromLayerMap(MCObject & object)
+ {
+- const int layerIndex =
+- object.renderLayer() >= MCWorld::MaxLayers ? MCWorld::MaxLayers - 1 : object.renderLayer();
+- m_layers[layerIndex].erase(&object);
++ m_layers[object.renderLayer()].objectSet().erase(&object);
+ }
+
+ void MCWorldRenderer::addParticleVisibilityCamera(MCCamera & camera)
+@@ -302,8 +305,5 @@ void MCWorldRenderer::removeParticleVisibilityCameras()
+
+ void MCWorldRenderer::clear()
+ {
+- for (int i = 0; i < MCWorld::MaxLayers; i++)
+- {
+- m_layers[i].clear();
+- }
++ m_layers.clear();
+ }
+diff --git src/game/MiniCore/Graphics/mcworldrenderer.hh src/game/MiniCore/Graphics/mcworldrenderer.hh
+index 0a45a49..287af58 100644
+--- src/game/MiniCore/Graphics/mcworldrenderer.hh
++++ src/game/MiniCore/Graphics/mcworldrenderer.hh
+@@ -20,6 +20,7 @@
+ #ifndef MCWORLDRENDERER_HH
+ #define MCWORLDRENDERER_HH
+
++#include "mcrenderlayer.hh"
+ #include "mctypes.hh"
+ #include "mcworld.hh"
+
+@@ -72,24 +73,17 @@ private:
+
+ void renderBatches(MCCamera * camera = nullptr);
+
+- void renderObjectBatches(MCCamera * camera, int layer);
++ void renderObjectBatches(MCCamera * camera, MCRenderLayer & layer);
+
+- void renderParticleBatches(MCCamera * camera, int layer);
++ void renderParticleBatches(MCCamera * camera, MCRenderLayer & layer);
+
+- typedef std::unordered_set<MCObject *> LayerSet;
+- LayerSet m_layers[MCWorld::MaxLayers];
+-
+- typedef std::map<int, std::vector<MCObject *> > BatchMap;
+- typedef std::map<MCCamera *, BatchMap[MCWorld::MaxLayers]> CameraBatchMap;
+-
+- CameraBatchMap m_objectBatches;
+- CameraBatchMap m_particleBatches;
+-
+- bool m_depthTestEnabled[MCWorld::MaxLayers];
++ typedef int LayerId;
++ std::map<LayerId, MCRenderLayer> m_layers;
+
+ std::vector<MCCamera *> m_visibilityCameras;
+
+- typedef std::map<int, MCGLPointParticleRenderer *> ParticleRendererMap;
++ typedef int ParticleTypeId;
++ typedef std::map<ParticleTypeId, MCGLPointParticleRenderer *> ParticleRendererMap;
+ ParticleRendererMap m_particleRenderers;
+ };
+
+diff --git src/game/checkeredflag.cpp src/game/checkeredflag.cpp
+index 10fd62d..67bb608 100644
+--- src/game/checkeredflag.cpp
++++ src/game/checkeredflag.cpp
+@@ -23,7 +23,6 @@
+ static const int FLAG_W = 32;
+ static const int FLAG_H = 24;
+ static const int V_SPACING = 20;
+-static const float APPEARANCE_SPEED = 0.05f;
+
+ CheckeredFlag::CheckeredFlag()
+ : m_surface(MCAssetManager::surfaceManager().surface("checkeredFlag"))
+diff --git src/game/game.cpp src/game/game.cpp
+index db4a55a..5ad81ac 100644
+--- src/game/game.cpp
++++ src/game/game.cpp
+@@ -44,8 +44,7 @@
+
+ #include <cassert>
+
+-static const unsigned int MAX_PLAYERS = 2;
+-static const float DEFAULT_VOLUME = 0.5;
++static const unsigned int MAX_PLAYERS = 2;
+
+ Game * Game::m_instance = nullptr;
+
+diff --git src/game/game.pro src/game/game.pro
+index 055d28c..a73daae 100644
+--- src/game/game.pro
++++ src/game/game.pro
+@@ -152,6 +152,7 @@ HEADERS += \
+ MiniCore/Graphics/mcshaders.hh \
+ MiniCore/Graphics/mcshaders30.hh \
+ MiniCore/Graphics/mcshadersGLES.hh \
++ MiniCore/Graphics/mcrenderlayer.hh \
+ MiniCore/Graphics/mcshapeview.hh \
+ MiniCore/Graphics/mcsurface.hh \
+ MiniCore/Graphics/mcsurfaceconfigloader.hh \
+@@ -292,6 +293,7 @@ SOURCES += \
+ MiniCore/Graphics/mcmeshmanager.cc \
+ MiniCore/Graphics/mcmeshobjectdata.cc \
+ MiniCore/Graphics/mcmeshview.cc \
++ MiniCore/Graphics/mcrenderlayer.cc \
+ MiniCore/Graphics/mcsurface.cc \
+ MiniCore/Graphics/mcsurfaceconfigloader.cc \
+ MiniCore/Graphics/mcsurfacemanager.cc \