Skip to content

Commit 6dd8f39

Browse files
committed
new state code, fixed editor map format, etc.
1 parent 9267b14 commit 6dd8f39

32 files changed

+179
-353
lines changed

bin/data/base/shaders/bump.fp

+4-4
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ void main(void)
7979
else
8080
atten_frag = 1.0;
8181

82-
vec4 fog_color = vec4(0.0, 0.0, 0.0, 1.0);
83-
float fog_factor = eye_dist / 20.0f;
82+
/*vec4 fog_color = vec4(0.0, 0.0, 0.0, 1.0);*/
83+
/*float fog_factor = eye_dist / 20.0f;*/
8484

8585
vec4 lit = color_frag * occ * atten_frag * lightcolor;
8686

87-
/*gl_FragColor = lit;*/
88-
gl_FragColor = mix(lit, fog_color, clamp(fog_factor,0.0,1.0));
87+
gl_FragColor = lit;
88+
/*gl_FragColor = mix(lit, fog_color, clamp(fog_factor,0.0,1.0));*/
8989
}
9090

qor.vcxproj

+4-1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
<ClInclude Include="src\Audio.h" />
120120
<ClInclude Include="src\Material.h" />
121121
<ClInclude Include="src\TrackerNode.h" />
122+
<ClInclude Include="src\ResourcePath.h" />
122123
<ClInclude Include="src\ISingleton.h" />
123124
<ClInclude Include="src\Renderer.h" />
124125
<ClInclude Include="src\NodeAttributes.h" />
@@ -130,15 +131,17 @@
130131
<ClInclude Include="src\EulerNode.h" />
131132
<ClInclude Include="src\PropertyList.h" />
132133
<ClInclude Include="src\ITrackable.h" />
134+
<ClInclude Include="src\IRealtime.h" />
133135
<ClInclude Include="src\Node.h" />
134136
<ClInclude Include="src\ISuperParent.h" />
135137
<ClInclude Include="src\EnvironmentNode.h" />
136138
<ClInclude Include="src\Scene.h" />
137139
<ClInclude Include="src\IConfig.h" />
138140
<ClInclude Include="src\ResourceMap.h" />
139141
<ClInclude Include="src\Engine.h" />
142+
<ClInclude Include="src\IPartitioner.h" />
140143
<ClInclude Include="src\Graphics.h" />
141-
<ClInclude Include="src\Partitioner.h" />
144+
<ClInclude Include="src\IRenderable.h" />
142145
<ClInclude Include="src\DumbyPartitioner.h" />
143146
<ClInclude Include="src\IListenable.h" />
144147
<ClInclude Include="src\Version.h" />

qor.vcxproj.filters

+17-8
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<ItemGroup>
44
<Filter Include="src">
5-
<UniqueIdentifier>{4846D870-AE69-A6D4-0E1B-12FF03C3C4D5}</UniqueIdentifier>
5+
<UniqueIdentifier>{8A4886AA-2805-8B06-09D4-E39BB01F8A3F}</UniqueIdentifier>
66
</Filter>
77
<Filter Include="src\game">
8-
<UniqueIdentifier>{1ECD4A8C-8ADA-48C2-4D1B-927A482D1BC2}</UniqueIdentifier>
8+
<UniqueIdentifier>{E611BAF6-D965-AE60-8046-FE1D88088D2F}</UniqueIdentifier>
99
</Filter>
1010
<Filter Include="src\LuaScript">
11-
<UniqueIdentifier>{AE580DC4-54E6-119D-4433-A512D4C81832}</UniqueIdentifier>
11+
<UniqueIdentifier>{005D2F9F-E9F4-10AC-D780-EF2350C159E5}</UniqueIdentifier>
1212
</Filter>
1313
<Filter Include="src\pn">
14-
<UniqueIdentifier>{D8BF61A9-DC8B-4B00-46A1-C18CF775D380}</UniqueIdentifier>
14+
<UniqueIdentifier>{C2785254-3CEF-687A-69FB-CFDD39D39D10}</UniqueIdentifier>
1515
</Filter>
1616
<Filter Include="src\math">
17-
<UniqueIdentifier>{38C15624-32E7-A08D-E322-EBFDA097954F}</UniqueIdentifier>
17+
<UniqueIdentifier>{0854E8E5-976B-D02D-C24C-DE8806CDC896}</UniqueIdentifier>
1818
</Filter>
1919
<Filter Include="src\transition">
20-
<UniqueIdentifier>{6171B3E9-E424-8788-B9A3-3FB9C55F5ABC}</UniqueIdentifier>
20+
<UniqueIdentifier>{D1AC1A5D-01B8-8F97-6573-A4500BCD590B}</UniqueIdentifier>
2121
</Filter>
2222
<Filter Include="src\editor">
23-
<UniqueIdentifier>{FD89CF90-AB86-C9CA-1E85-45743C86D760}</UniqueIdentifier>
23+
<UniqueIdentifier>{FE4B678A-FBD5-E47E-B7B9-96E332907E5B}</UniqueIdentifier>
2424
</Filter>
2525
</ItemGroup>
2626
<ItemGroup>
@@ -63,6 +63,9 @@
6363
<ClInclude Include="src\TrackerNode.h">
6464
<Filter>src</Filter>
6565
</ClInclude>
66+
<ClInclude Include="src\ResourcePath.h">
67+
<Filter>src</Filter>
68+
</ClInclude>
6669
<ClInclude Include="src\ISingleton.h">
6770
<Filter>src</Filter>
6871
</ClInclude>
@@ -96,6 +99,9 @@
9699
<ClInclude Include="src\ITrackable.h">
97100
<Filter>src</Filter>
98101
</ClInclude>
102+
<ClInclude Include="src\IRealtime.h">
103+
<Filter>src</Filter>
104+
</ClInclude>
99105
<ClInclude Include="src\Node.h">
100106
<Filter>src</Filter>
101107
</ClInclude>
@@ -117,10 +123,13 @@
117123
<ClInclude Include="src\Engine.h">
118124
<Filter>src</Filter>
119125
</ClInclude>
126+
<ClInclude Include="src\IPartitioner.h">
127+
<Filter>src</Filter>
128+
</ClInclude>
120129
<ClInclude Include="src\Graphics.h">
121130
<Filter>src</Filter>
122131
</ClInclude>
123-
<ClInclude Include="src\Partitioner.h">
132+
<ClInclude Include="src\IRenderable.h">
124133
<Filter>src</Filter>
125134
</ClInclude>
126135
<ClInclude Include="src\DumbyPartitioner.h">

src/Developer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ Developer :: ~Developer()
1414
int Developer :: logic(unsigned int a)
1515
{
1616
if(m_pInput->keyd(SDLK_F1))
17-
m_pEngine->setState("game");
17+
m_pEngine->clearToState("game");
1818
else if(m_pInput->keyd(SDLK_F2))
19-
m_pEngine->setState("editor");
19+
m_pEngine->clearToState("editor");
2020

2121
if(m_pInput->keyd(SDLK_F12))
2222
m_pInput->toggleHideMouse();

src/DumbyPartitioner.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
#define _DUMBYPARTITIONER_H
33

44
#include "NodeAttributes.h"
5-
#include "Partitioner.h"
5+
#include "IPartitioner.h"
66
#include "Light.h"
77

88
// A unoptimized implementation of the Partitioner base
99

10-
class DumbyPartitioner : public Partitioner
10+
class DumbyPartitioner : public IPartitioner
1111
{
1212
public:
1313
DumbyPartitioner() {}

src/Engine.cpp

+25-71
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
using namespace std;
1414

15-
Engine::State :: ~State() {}
16-
1715
//Engine::Engine()
1816
//{
1917
// nullify();
@@ -28,16 +26,14 @@ Engine::Engine(std::vector<std::string>& args)
2826

2927
Engine::~Engine()
3028
{
31-
// cleanup() not needed, runs at the end of run()
29+
3230
}
3331

3432
void Engine::nullify()
3533
{
36-
m_sStateDest = "";
3734
//m_pRenderer = NULL;
3835
m_pInput = NULL;
3936
//m_pTimer = NULL;
40-
m_pState = NULL;
4137
m_pConsole = NULL;
4238
//m_pSettings = NULL;
4339
m_pAudio = NULL;
@@ -70,7 +66,7 @@ bool Engine::run()
7066
FPSAlarm.setSeconds(fpsRefresh);
7167
int frames = 0;
7268

73-
while(logic() != 1 && !quitFlag())
69+
while(pollState() && logic() != 1 && !quitFlag())
7470
{
7571
render();
7672
Renderer::get().draw();
@@ -94,12 +90,6 @@ bool Engine::run()
9490

9591
bool Engine::init()
9692
{
97-
Settings::get(new Settings("settings.ini"));
98-
99-
Log::get(new Log());
100-
Log::get().setStdOut(Settings::get().getProperty("Console", "StandardOut", "true")=="true"); // output to stdout
101-
Log::get().write("Logging system initialized.");
102-
10393
if(!Renderer::ptr())
10494
{
10595
Renderer::get(new Renderer(
@@ -151,9 +141,7 @@ bool Engine::init()
151141
if(Settings::get().getProperty("Developer", "Enabled", "true") == "true")
152142
m_spDeveloper.reset(new Developer(this, input()));
153143

154-
setState("game");
155-
if(!verifyState())
156-
return false;
144+
clearToState("game");
157145
return true;
158146
}
159147

@@ -169,14 +157,12 @@ int Engine::logic()
169157
m_spDeveloper->logic(a);
170158
if(m_pConsole)
171159
m_pConsole->logic(a, m_pInput);
172-
if(m_pState)
173-
m_pState->logic(a);
160+
if(currentState())
161+
if(!currentState()->logic(a))
162+
return 1;
174163

175164
m_uiLastAdv = now;
176165

177-
if(!verifyState())
178-
return 1;
179-
180166
return 0;
181167
}
182168

@@ -186,8 +172,8 @@ void Engine::render() const
186172
Renderer::get().shaders(Renderer::BIND_SHADERS);
187173
Renderer::get().lighting(Renderer::BIND_LIGHTING);
188174

189-
if(m_pState)
190-
m_pState->render();
175+
if(currentState())
176+
currentState()->render();
191177

192178
Renderer::get().viewport(Renderer::VIEW_ORTHO);
193179
Renderer::get().lighting(Renderer::UNBIND_LIGHTING);
@@ -201,8 +187,10 @@ void Engine::render() const
201187

202188
void Engine::cleanup()
203189
{
204-
Log::get().write("Unloading state...");
205-
delete m_pState;
190+
destroyStateManager();
191+
192+
//Log::get().write("Unloading state...");
193+
//delete m_pState;
206194
Log::get().write("Unloading console...");
207195
delete m_pConsole;
208196
//Log::get().write("Unloading renderer...");
@@ -219,57 +207,23 @@ void Engine::cleanup()
219207
}
220208

221209

222-
bool Engine :: verifyState()
210+
IState* Engine :: newState(const std::string id)
223211
{
224-
if(m_sStateDest=="")
225-
return true;
226-
//Log::get().write("Changing state to: " + m_sStateDest);
227-
228-
if(m_pState)
229-
{
230-
delete m_pState;
231-
m_pState = NULL;
212+
IState* state = nullptr;
213+
if(id == "game")
214+
state = new GameState();
215+
else if(id == "editor")
216+
state = new EditorState();
217+
else {
218+
Log::get().error("Unknown state request.");
219+
return nullptr;
232220
}
233221

234-
if(m_sStateDest == "game")
235-
m_pState = new GameState(this);
236-
else if(m_sStateDest == "editor")
237-
m_pState = new EditorState(this);
238-
else
239-
Log::get().warning("Unknown state request.");
240-
241-
//switch(m_eStateDest)
242-
//{
243-
// case STATE_GAME:
244-
// break;
245-
// case STATE:EDITOR:
246-
// break;
247-
// default:
248-
//}
249-
250-
if(m_sStateDest != "" && m_pState)
251-
{
252-
Log::get().write("State Change: " + boost::to_upper_copy(m_sStateDest));
222+
Log::get().write("State Change: " + boost::to_upper_copy(id));
253223

254-
if(m_pState->hasError())
255-
{
256-
Log::get().error(m_pState->getError());
257-
delete m_pState;
258-
m_pState = NULL;
259-
return false;
260-
}
261-
}
224+
if(state && state->hasError())
225+
Log::get().error(state->getError());
262226

263-
m_sStateDest = "";
264-
return true;
265-
}
266-
267-
void Engine :: swapState(State* next_state)
268-
{
269-
if(m_pState)
270-
{
271-
delete m_pState;
272-
m_pState = next_state;
273-
}
227+
return state;
274228
}
275229

0 commit comments

Comments
 (0)