@@ -1,8 +1,8 @@ | |||
// | |||
// Lol Engine | |||
// | |||
// Copyright © 2010—2013 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | |||
// © 2009—2013 Sam Hocevar <sam@hocevar.net> | |||
// Copyright © 2009—2019 Sam Hocevar <sam@hocevar.net> | |||
// © 2010—2013 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | |||
// | |||
// This library is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
@@ -24,11 +24,8 @@ namespace lol | |||
// Override Gamegroups names for Physic-usage | |||
// "_ENT_" means that this is a group for Entities that use EasyPhysic primitives. | |||
// "_EZP_" means that this is a group for EasyPhysic primitives. | |||
#define GAMEGROUP_ENT_INPUT GAMEGROUP_INPUT | |||
#define GAMEGROUP_ENT_PLATFORM GAMEGROUP_ENTITY | |||
#define GAMEGROUP_ENT_MAIN GAMEGROUP_OTHER_1 | |||
#define GAMEGROUP_EZP_CHAR_CTRLR GAMEGROUP_OTHER_2 | |||
#define GAMEGROUP_SIMULATION GAMEGROUP_OTHER_3 | |||
#define GAMEGROUP_EZP_CHAR_CTRLR tickable::group::game::other_2 | |||
#define GAMEGROUP_SIMULATION tickable::group::game::other_3 | |||
#define LOL2BT_UNIT 1.0f | |||
#define BT2LOL_UNIT 1.0f | |||
@@ -52,6 +52,9 @@ liblol_core_headers = \ | |||
lol/audio/all.h \ | |||
lol/audio/audio.h lol/audio/sample.h \ | |||
\ | |||
lol/engine/all.h \ | |||
lol/engine/tickable.h \ | |||
\ | |||
lol/sys/all.h \ | |||
lol/sys/init.h lol/sys/file.h lol/sys/getopt.h lol/sys/thread.h \ | |||
lol/sys/threadtypes.h lol/sys/timer.h \ | |||
@@ -130,7 +133,7 @@ liblol_core_sources = \ | |||
image/filter/dilate.cpp image/filter/median.cpp image/filter/yuv.cpp \ | |||
image/movie.cpp \ | |||
\ | |||
engine/ticker.cpp engine/ticker.h \ | |||
engine/tickable.cpp engine/ticker.cpp engine/ticker.h \ | |||
engine/entity.cpp engine/entity.h \ | |||
engine/world.cpp engine/world.h \ | |||
engine/worldentity.cpp engine/worldentity.h \ | |||
@@ -27,8 +27,8 @@ namespace lol | |||
Camera::Camera() | |||
{ | |||
m_gamegroup = GAMEGROUP_CAMERA; | |||
m_drawgroup = DRAWGROUP_CAMERA; | |||
m_gamegroup = tickable::group::game::camera; | |||
m_drawgroup = tickable::group::draw::camera; | |||
//Arbitrary values when scene renderer is not ready. | |||
ivec2 screen_size = (Scene::GetCount()) ? (Video::GetSize()) : (ivec2(800, 600)); | |||
@@ -1,7 +1,7 @@ | |||
// | |||
// Lol Engine | |||
// | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
@@ -56,7 +56,7 @@ DebugRecord::DebugRecord(std::string const &path, float fps) | |||
m_data->m_sequence = nullptr; | |||
#endif | |||
m_drawgroup = DRAWGROUP_CAPTURE; | |||
m_drawgroup = tickable::group::draw::capture; | |||
} | |||
void DebugRecord::tick_game(float seconds) | |||
@@ -1,11 +1,13 @@ | |||
// | |||
// Lol Engine | |||
// Lol Engine | |||
// | |||
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||
// This program is free software; you can redistribute it and/or | |||
// modify it under the terms of the Do What The Fuck You Want To | |||
// Public License, Version 2, as published by Sam Hocevar. See | |||
// http://www.wtfpl.net/ for more details. | |||
// Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#include <lol/engine-internal.h> | |||
@@ -38,7 +40,7 @@ DebugStats::DebugStats(char const *path) | |||
{ | |||
data->fp = fopen(path, "w+"); | |||
m_gamegroup = GAMEGROUP_STATS; | |||
m_gamegroup = tickable::group::game::stats; | |||
} | |||
void DebugStats::tick_game(float seconds) | |||
@@ -1,7 +1,7 @@ | |||
// | |||
// Lol Engine | |||
// | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
@@ -29,8 +29,8 @@ Entity::Entity() : | |||
#if !LOL_BUILD_RELEASE | |||
m_tickstate = STATE_IDLE; | |||
#endif | |||
m_gamegroup = GAMEGROUP_ENTITY; | |||
m_drawgroup = DRAWGROUP_ENTITY; | |||
m_gamegroup = tickable::group::game::entity; | |||
m_drawgroup = tickable::group::draw::entity; | |||
/* FIXME: is this a problem? because the object can | |||
* be ticked before the constructor is finished! */ | |||
Ticker::Register(this); | |||
@@ -20,7 +20,9 @@ | |||
// Ticker class for the ticking logic and the linked list implementation. | |||
// | |||
#include <stdint.h> | |||
#include <cstdint> | |||
#include <lol/engine/tickable.h> | |||
namespace lol | |||
{ | |||
@@ -44,7 +46,7 @@ struct InitState | |||
class Entity | |||
{ | |||
friend class Scene; | |||
friend class Ticker; | |||
friend class ticker; | |||
friend class TickerData; | |||
friend class Emcee; | |||
@@ -64,58 +66,6 @@ protected: | |||
virtual void tick_game(float seconds); | |||
virtual void tick_draw(float seconds, class Scene &scene); | |||
enum | |||
{ | |||
GAMEGROUP_BEGIN = 0, // must be the first element | |||
GAMEGROUP_INPUT, // input should be polled before everything else | |||
GAMEGROUP_IMGUI, // debug update needs to be called before the rest for init purposes | |||
GAMEGROUP_APP, // main application update | |||
GAMEGROUP_ENTITY, // default entity update | |||
// ----------------- // split entity update: | |||
GAMEGROUP_PLAYER, // player updates before AI to ensure player actions is prevalent | |||
GAMEGROUP_AI, // AI update | |||
GAMEGROUP_OTHER_0, // other misc updates here | |||
GAMEGROUP_OTHER_1, // (same) | |||
GAMEGROUP_OTHER_2, // (same) | |||
GAMEGROUP_OTHER_3, // (same) | |||
// ----------------- // primitives updates | |||
GAMEGROUP_MESH, // update Mesh/Animation to ensure correct sync with PLY/AI | |||
GAMEGROUP_FX, // update FX/other to ensure correct sync with WorldPos and Meshes | |||
GAMEGROUP_LIGHT, // update after FX because it could some | |||
GAMEGROUP_CAMERA, // update camera at the end of the frame, once everything is settled | |||
GAMEGROUP_STATS, // stats update | |||
GAMEGROUP_END // must be the last element | |||
} | |||
m_gamegroup; | |||
enum | |||
{ | |||
DRAWGROUP_BEGIN = GAMEGROUP_END, | |||
DRAWGROUP_CAMERA, // update camera first for rendering | |||
DRAWGROUP_TEXTURE, // texture | |||
DRAWGROUP_LIGHT, // | |||
DRAWGROUP_WORLD, // other misc updates here | |||
DRAWGROUP_ENTITY, // | |||
DRAWGROUP_FX, // | |||
DRAWGROUP_OTHER_0, // other misc updates here | |||
DRAWGROUP_OTHER_1, // (same) | |||
DRAWGROUP_OTHER_2, // (same) | |||
DRAWGROUP_OTHER_3, // (same) | |||
DRAWGROUP_APP, // main application Draw | |||
DRAWGROUP_HUD, | |||
DRAWGROUP_IMGUI, | |||
DRAWGROUP_CAPTURE, | |||
DRAWGROUP_END, // must be the next-to-last element | |||
DRAWGROUP_NONE, // this group is for non draw-ticked | |||
} | |||
m_drawgroup; | |||
static int const ALLGROUP_END = DRAWGROUP_END; | |||
/* The initialisation state */ | |||
InitState m_initstate; | |||
@@ -131,6 +81,9 @@ protected: | |||
m_tickstate; | |||
#endif | |||
tickable::group::game m_gamegroup; | |||
tickable::group::draw m_drawgroup; | |||
// Emcee begin | |||
private: | |||
void SetState(uint32_t newstate); | |||
@@ -0,0 +1,33 @@ | |||
// | |||
// Lol Engine | |||
// | |||
// Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#include <lol/engine-internal.h> | |||
#include <cstdlib> | |||
#include <cstdint> | |||
#include <functional> | |||
namespace lol | |||
{ | |||
//auto p = tickable::create<tickable>(); | |||
tickable::tickable() | |||
{ | |||
} | |||
tickable::~tickable() | |||
{ | |||
} | |||
} /* namespace lol */ | |||
@@ -13,7 +13,7 @@ | |||
#include <lol/engine-internal.h> | |||
#include <cstdlib> | |||
#include <stdint.h> | |||
#include <cstdint> | |||
#include <functional> | |||
namespace lol | |||
@@ -25,7 +25,7 @@ namespace lol | |||
static class TickerData | |||
{ | |||
friend class Ticker; | |||
friend class ticker; | |||
public: | |||
TickerData() : | |||
@@ -57,8 +57,8 @@ public: | |||
private: | |||
/* Entity management */ | |||
array<Entity *> m_todolist, m_todolist_delayed, m_autolist; | |||
array<Entity *> m_list[Entity::ALLGROUP_END]; | |||
array<int> m_scenes[Entity::ALLGROUP_END]; | |||
array<Entity *> m_list[(int)tickable::group::all::end]; | |||
array<int> m_scenes[(int)tickable::group::all::end]; | |||
int nentities; | |||
/* Fixed framerate management */ | |||
@@ -214,10 +214,10 @@ void TickerData::GameThreadTick() | |||
#if 0 | |||
msg::debug("-------------------------------------\n"); | |||
for (int g = 0; g < Entity::ALLGROUP_END; ++g) | |||
for (int g = 0; g < (int)tickable::group::all::end; ++g) | |||
{ | |||
msg::debug("%s Group %d\n", | |||
(g < Entity::GAMEGROUP_END) ? "Game" : "Draw", g); | |||
(g < (int)tickable::group::game::end) ? "Game" : "Draw", g); | |||
for (int i = 0; i < data->m_list[g].count(); ++i) | |||
{ | |||
@@ -269,7 +269,7 @@ void TickerData::GameThreadTick() | |||
int n = 0; | |||
data->panic = 2 * (data->panic + 1); | |||
for (int g = 0; g < Entity::ALLGROUP_END && n < data->panic; ++g) | |||
for (int g = 0; g < (int)tickable::group::all::end && n < data->panic; ++g) | |||
for (int i = 0; i < data->m_list[g].count() && n < data->panic; ++i) | |||
{ | |||
Entity * e = data->m_list[g][i]; | |||
@@ -297,13 +297,13 @@ void TickerData::GameThreadTick() | |||
* in the tick lists can be marked for destruction. */ | |||
array<Entity*> destroy_list; | |||
bool do_reserve = true; | |||
for (int g = 0; g < Entity::ALLGROUP_END; ++g) | |||
for (int g = 0; g < (int)tickable::group::all::end; ++g) | |||
{ | |||
for (int i = data->m_list[g].count(); i--;) | |||
{ | |||
Entity *e = data->m_list[g][i]; | |||
if (e->m_destroy && g < Entity::GAMEGROUP_END) | |||
if (e->m_destroy && g < (int)tickable::group::game::end) | |||
{ | |||
/* Game tick list: | |||
* If entity is to be destroyed, remove it */ | |||
@@ -328,7 +328,7 @@ void TickerData::GameThreadTick() | |||
if (Scene::GetScene(j).IsRelevant(e)) | |||
removal_count++; | |||
//Update scene index | |||
data->m_scenes[e->m_drawgroup][j] -= removal_count; | |||
data->m_scenes[(int)e->m_drawgroup][j] -= removal_count; | |||
} | |||
if (do_reserve) | |||
{ | |||
@@ -339,7 +339,7 @@ void TickerData::GameThreadTick() | |||
} | |||
else | |||
{ | |||
if (e->m_ref <= 0 && g >= Entity::DRAWGROUP_BEGIN) | |||
if (e->m_ref <= 0 && g >= (int)tickable::group::draw::begin) | |||
e->m_destroy = 1; | |||
} | |||
} | |||
@@ -363,11 +363,11 @@ void TickerData::GameThreadTick() | |||
} | |||
data->m_todolist.remove(-1); | |||
data->m_list[e->m_gamegroup].push(e); | |||
if (e->m_drawgroup != Entity::DRAWGROUP_NONE) | |||
data->m_list[(int)e->m_gamegroup].push(e); | |||
if (e->m_drawgroup != tickable::group::draw::none) | |||
{ | |||
if (data->m_scenes[e->m_drawgroup].count() < Scene::GetCount()) | |||
data->m_scenes[e->m_drawgroup].resize(Scene::GetCount()); | |||
if (data->m_scenes[(int)e->m_drawgroup].count() < Scene::GetCount()) | |||
data->m_scenes[(int)e->m_drawgroup].resize(Scene::GetCount()); | |||
int added_count = 0; | |||
for (int i = 0; i < Scene::GetCount(); i++) | |||
@@ -375,11 +375,11 @@ void TickerData::GameThreadTick() | |||
//If entity is concerned by this scene, add it in the list | |||
if (Scene::GetScene(i).IsRelevant(e)) | |||
{ | |||
data->m_list[e->m_drawgroup].insert(e, data->m_scenes[e->m_drawgroup][i]); | |||
data->m_list[(int)e->m_drawgroup].insert(e, data->m_scenes[(int)e->m_drawgroup][i]); | |||
added_count++; | |||
} | |||
//Update scene index | |||
data->m_scenes[e->m_drawgroup][i] += added_count; | |||
data->m_scenes[(int)e->m_drawgroup][i] += added_count; | |||
} | |||
} | |||
@@ -391,7 +391,7 @@ void TickerData::GameThreadTick() | |||
data->m_todolist_delayed.clear(); | |||
/* Tick objects for the game loop */ | |||
for (int g = Entity::GAMEGROUP_BEGIN; g < Entity::GAMEGROUP_END && !data->quit /* Stop as soon as required */; ++g) | |||
for (int g = (int)tickable::group::game::begin; g < (int)tickable::group::game::end && !data->quit /* Stop as soon as required */; ++g) | |||
{ | |||
for (int i = 0; i < data->m_list[g].count() && !data->quit /* Stop as soon as required */; ++i) | |||
{ | |||
@@ -435,11 +435,11 @@ void TickerData::DrawThreadTick() | |||
scene.pre_render(data->deltatime); | |||
/* Tick objects for the draw loop */ | |||
for (int g = Entity::DRAWGROUP_BEGIN; g < Entity::DRAWGROUP_END && !data->quit /* Stop as soon as required */; ++g) | |||
for (int g = (int)tickable::group::draw::begin; g < (int)tickable::group::draw::end && !data->quit /* Stop as soon as required */; ++g) | |||
{ | |||
switch (g) | |||
{ | |||
case Entity::DRAWGROUP_BEGIN: | |||
case (int)tickable::group::draw::begin: | |||
scene.Reset(); | |||
break; | |||
default: | |||
@@ -1,29 +1,31 @@ | |||
// | |||
// Lol Engine | |||
// Lol Engine | |||
// | |||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||
// This program is free software; you can redistribute it and/or | |||
// modify it under the terms of the Do What The Fuck You Want To | |||
// Public License, Version 2, as published by Sam Hocevar. See | |||
// http://www.wtfpl.net/ for more details. | |||
// Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#pragma once | |||
// | |||
// The Ticker class | |||
// ---------------- | |||
// The Ticker is a static class that registers entities and ticks them. | |||
// The ticker class | |||
// ———————————————— | |||
// The ticker is a static class that registers entities and ticks them. | |||
// | |||
#include <stdint.h> | |||
#include <cstdint> | |||
#include "engine/entity.h" | |||
namespace lol | |||
{ | |||
class Ticker | |||
class ticker | |||
{ | |||
public: | |||
static void Register(Entity *entity); | |||
@@ -46,8 +48,10 @@ public: | |||
static int Finished(); | |||
private: | |||
Ticker() {} | |||
ticker() {} | |||
}; | |||
typedef ticker Ticker; | |||
} /* namespace lol */ | |||
@@ -60,7 +60,7 @@ Font::Font(std::string const &path) | |||
data->tileset = TileSet::create(path, ivec2::zero, ivec2(16)); | |||
data->size = data->tileset->GetTileSize(0); | |||
m_drawgroup = DRAWGROUP_TEXTURE; | |||
m_drawgroup = tickable::group::draw::texture; | |||
} | |||
Font::~Font() | |||
@@ -1,11 +1,13 @@ | |||
// | |||
// Lol Engine | |||
// Lol Engine | |||
// | |||
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||
// This program is free software; you can redistribute it and/or | |||
// modify it under the terms of the Do What The Fuck You Want To | |||
// Public License, Version 2, as published by Sam Hocevar. See | |||
// http://www.wtfpl.net/ for more details. | |||
// Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#include <lol/engine-internal.h> | |||
@@ -20,8 +22,8 @@ Light::Light() | |||
: m_color(1.f), | |||
m_type(LightType::Directional) | |||
{ | |||
m_gamegroup = GAMEGROUP_LIGHT; | |||
m_drawgroup = DRAWGROUP_LIGHT; | |||
m_gamegroup = tickable::group::game::light; | |||
m_drawgroup = tickable::group::draw::light; | |||
SetPosition(vec3::zero); | |||
} | |||
@@ -106,6 +106,7 @@ | |||
<ClCompile Include="easymesh\easymeshrender.cpp" /> | |||
<ClCompile Include="easymesh\easymeshtransform.cpp" /> | |||
<ClCompile Include="engine\entity.cpp" /> | |||
<ClCompile Include="engine\tickable.cpp" /> | |||
<ClCompile Include="engine\ticker.cpp" /> | |||
<ClCompile Include="engine\world.cpp" /> | |||
<ClCompile Include="engine\worldentity.cpp" /> | |||
@@ -228,6 +229,8 @@ | |||
<ClInclude Include="lol\base\tuple.h" /> | |||
<ClInclude Include="lol\debug\all.h" /> | |||
<ClInclude Include="lol\debug\lines.h" /> | |||
<ClInclude Include="lol\engine\all.h" /> | |||
<ClInclude Include="lol\engine\tickable.h" /> | |||
<ClInclude Include="lol\engine.h" /> | |||
<ClInclude Include="lol\engine-internal.h" /> | |||
<ClInclude Include="lol\extras.h" /> | |||
@@ -31,6 +31,9 @@ | |||
<Filter Include="lol\algorithm"> | |||
<UniqueIdentifier>{39f6f872-186f-48af-8e87-bcceb06b1b21}</UniqueIdentifier> | |||
</Filter> | |||
<Filter Include="lol\engine"> | |||
<UniqueIdentifier>{a20b47c1-a0f8-4a02-a7a8-6da2ccd8bb02}</UniqueIdentifier> | |||
</Filter> | |||
<Filter Include="lol\image"> | |||
<UniqueIdentifier>{f25b3187-b24c-469a-b038-5a968eaa83f6}</UniqueIdentifier> | |||
</Filter> | |||
@@ -360,6 +363,9 @@ | |||
<ClCompile Include="engine\entity.cpp"> | |||
<Filter>engine</Filter> | |||
</ClCompile> | |||
<ClCompile Include="engine\tickable.cpp"> | |||
<Filter>engine</Filter> | |||
</ClCompile> | |||
<ClCompile Include="engine\ticker.cpp"> | |||
<Filter>engine</Filter> | |||
</ClCompile> | |||
@@ -656,6 +662,12 @@ | |||
<ClInclude Include="lol\debug\lines.h"> | |||
<Filter>lol\debug</Filter> | |||
</ClInclude> | |||
<ClInclude Include="lol\engine\all.h"> | |||
<Filter>lol\engine</Filter> | |||
</ClInclude> | |||
<ClInclude Include="lol\engine\tickable.h"> | |||
<Filter>lol\engine</Filter> | |||
</ClInclude> | |||
<ClInclude Include="lol\image\image.h"> | |||
<Filter>lol\image</Filter> | |||
</ClInclude> | |||
@@ -0,0 +1,16 @@ | |||
// | |||
// Lol Engine | |||
// | |||
// Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#pragma once | |||
#include <lol/engine/tickable.h> | |||
@@ -0,0 +1,111 @@ | |||
// | |||
// Lol Engine | |||
// | |||
// Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#pragma once | |||
// | |||
// The tickable class | |||
// —————————————————— | |||
// Tickables are objects that can be ticked by the game loop and/or the render | |||
// loop. | |||
// | |||
#include <cstdint> | |||
namespace lol | |||
{ | |||
class game_tickable | |||
{ | |||
virtual void tick_game(float seconds) = 0; | |||
}; | |||
class draw_tickable | |||
{ | |||
virtual void tick_draw(float seconds, class Scene &scene) = 0; | |||
}; | |||
class tickable : public std::enable_shared_from_this<tickable> | |||
{ | |||
public: | |||
tickable(); | |||
virtual ~tickable(); | |||
// Auto-registering factory | |||
template<typename T> | |||
static typename std::enable_if<std::is_base_of<tickable, T>::value, std::shared_ptr<T>>::type | |||
create() | |||
{ | |||
auto p = std::make_shared<T>(); | |||
return p; | |||
} | |||
// Tick groups | |||
struct group | |||
{ | |||
enum class game | |||
{ | |||
begin = 0, // must be the first element | |||
input, // input should be polled before everything else | |||
gui, // debug update needs to be called before the rest for init purposes | |||
app, // main application update | |||
entity, // default entity update | |||
// ----------------- // split entity update: | |||
player, // player updates before AI to ensure player actions is prevalent | |||
ai, // AI update | |||
other_0, // other misc updates here | |||
other_1, // (same) | |||
other_2, // (same) | |||
other_3, // (same) | |||
// ----------------- // primitives updates | |||
mesh, // update Mesh/Animation to ensure correct sync with PLY/AI | |||
fx, // update FX/other to ensure correct sync with WorldPos and Meshes | |||
light, // update after FX because it could some | |||
camera, // update camera at the end of the frame, once everything is settled | |||
stats, // stats update | |||
end, // must be the last element | |||
}; | |||
enum class draw | |||
{ | |||
begin = (int)game::end, | |||
camera, // update camera first for rendering | |||
texture, // texture | |||
light, // | |||
world, // other misc updates here | |||
entity, // | |||
fx, // | |||
other_0, // other misc updates here | |||
other_1, // (same) | |||
other_2, // (same) | |||
other_3, // (same) | |||
app, // main application Draw | |||
hud, | |||
gui, | |||
capture, | |||
end, // must be the next-to-last element | |||
none, // this group is for non draw-ticked | |||
}; | |||
enum class all | |||
{ | |||
end = (int)draw::end, | |||
}; | |||
}; | |||
}; | |||
} /* namespace lol */ | |||
@@ -1,7 +1,7 @@ | |||
// | |||
// Lol Engine | |||
// | |||
// Copyright © 2010—2016 Sam Hocevar <sam@hocevar.net> | |||
// Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
@@ -14,7 +14,7 @@ | |||
// | |||
// The main header | |||
// --------------- | |||
// ——————————————— | |||
// | |||
#include <lol/base/all.h> | |||
@@ -25,4 +25,5 @@ | |||
#include <lol/audio/all.h> | |||
#include <lol/gpu/all.h> | |||
#include <lol/debug/all.h> | |||
#include <lol/engine/all.h> | |||
@@ -50,7 +50,7 @@ Text::Text(std::string const &text, char const *font) | |||
data->m_scale = vec2(1.f); | |||
data->m_spacing = 0.f; | |||
m_drawgroup = DRAWGROUP_HUD; | |||
m_drawgroup = tickable::group::draw::entity; | |||
} | |||
void Text::SetText(std::string const &text) | |||
@@ -1,7 +1,7 @@ | |||
// | |||
// Lol Engine | |||
// | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
@@ -12,8 +12,8 @@ | |||
#include <lol/engine-internal.h> | |||
#include <cstdlib> | |||
#include <cstdio> | |||
#include <cstdlib> | |||
#include <cstring> | |||
#if defined _WIN32 | |||
@@ -84,7 +84,7 @@ void TextureImage::Init(std::string const &path, image* img) | |||
m_data->m_texture_size = ivec2(PotUp(m_data->m_image_size.x), | |||
PotUp(m_data->m_image_size.y)); | |||
m_drawgroup = DRAWGROUP_TEXTURE; | |||
m_drawgroup = tickable::group::draw::texture; | |||
} | |||
void TextureImage::tick_draw(float seconds, Scene &scene) | |||
@@ -1,8 +1,8 @@ | |||
// | |||
// Lol Engine | |||
// | |||
// Copyright © 2010—2015 Benjamin Litzelmann | |||
// © 2017—2019 Sam Hocevar <sam@hocevar.net> | |||
// Copyright © 2017—2019 Sam Hocevar <sam@hocevar.net> | |||
// © 2010—2015 Benjamin Litzelmann | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
@@ -223,7 +223,7 @@ static uint32_t g_active_layer = ~((uint32_t)0); | |||
//----------------------------------------------------------------------------- | |||
Controller::Controller(std::string const &name) | |||
{ | |||
m_gamegroup = GAMEGROUP_INPUT; | |||
m_gamegroup = tickable::group::game::input; | |||
m_name = name; | |||
m_activate_nextframe = true; | |||
m_deactivate_nextframe = false; | |||
@@ -103,7 +103,7 @@ D3d9Input::D3d9Input() | |||
} | |||
#endif | |||
m_gamegroup = GAMEGROUP_INPUT; | |||
m_gamegroup = tickable::group::game::input; | |||
} | |||
D3d9Input::~D3d9Input() | |||
@@ -45,8 +45,8 @@ gui::gui(ImFontAtlas *shared_font_atlas) | |||
{ | |||
ImGui::CreateContext(shared_font_atlas); | |||
m_gamegroup = GAMEGROUP_IMGUI; | |||
m_drawgroup = DRAWGROUP_IMGUI; | |||
m_gamegroup = tickable::group::game::gui; | |||
m_drawgroup = tickable::group::draw::gui; | |||
// Build shader code ------------------------------------------------------- | |||
ShaderVar out_vertex = ShaderVar::GetShaderOut(ShaderProgram::Vertex); | |||
@@ -128,7 +128,7 @@ SdlInput::SdlInput(int app_w, int app_h, int screen_w, int screen_h) | |||
} | |||
#endif | |||
m_gamegroup = GAMEGROUP_INPUT; | |||
m_gamegroup = tickable::group::game::input; | |||
} | |||
SdlInput::~SdlInput() | |||