Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1f2258bc01 |
+20
-5
@@ -4,6 +4,7 @@
|
|||||||
#define STB_IMAGE_IMPLEMENTATION
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
#include "stb_image.h"
|
#include "stb_image.h"
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include <opencv2/core.hpp>
|
#include <opencv2/core.hpp>
|
||||||
#include <opencv2/videoio.hpp>
|
#include <opencv2/videoio.hpp>
|
||||||
@@ -16,6 +17,10 @@
|
|||||||
#include "shaders/static_shader.h"
|
#include "shaders/static_shader.h"
|
||||||
#include "toolbox/toolbox.h"
|
#include "toolbox/toolbox.h"
|
||||||
|
|
||||||
|
#include "scenes/scene.h"
|
||||||
|
#include "scenes/startupScene.h"
|
||||||
|
#include "scenes/inGameScene.h"
|
||||||
|
|
||||||
#include "computervision/ObjectDetection.h"
|
#include "computervision/ObjectDetection.h"
|
||||||
|
|
||||||
#pragma comment(lib, "glfw3.lib")
|
#pragma comment(lib, "glfw3.lib")
|
||||||
@@ -26,6 +31,10 @@ static double UpdateDelta();
|
|||||||
|
|
||||||
static GLFWwindow* window;
|
static GLFWwindow* window;
|
||||||
|
|
||||||
|
//Scene management variables
|
||||||
|
std::map<Scenes, Scene*> scenes;
|
||||||
|
Scene* current_scene = nullptr;
|
||||||
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
@@ -44,11 +53,14 @@ int main(void)
|
|||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
glfwSetKeyCallback(window, [](GLFWwindow* window, int key, int scancode, int action, int mods)
|
glfwSetKeyCallback(window, [](GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||||
{
|
{
|
||||||
if (key == GLFW_KEY_ESCAPE)
|
current_scene->onKey(key, scancode, action, mods);
|
||||||
glfwSetWindowShouldClose(window, true);
|
if (key == GLFW_KEY_ESCAPE)
|
||||||
});
|
glfwSetWindowShouldClose(window, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
scenes[Scenes::STARTUP] = new StartupScene();
|
||||||
|
scenes[Scenes::INGAME] = new InGameScene();
|
||||||
|
|
||||||
models::RawModel raw_model = LoadObjModel("res/Tree.obj");
|
models::RawModel raw_model = LoadObjModel("res/Tree.obj");
|
||||||
models::ModelTexture texture = { render_engine::loader::LoadTexture("res/TreeTexture.png") };
|
models::ModelTexture texture = { render_engine::loader::LoadTexture("res/TreeTexture.png") };
|
||||||
@@ -68,6 +80,7 @@ int main(void)
|
|||||||
// set up object detection
|
// set up object detection
|
||||||
//objDetect.setup();
|
//objDetect.setup();
|
||||||
|
|
||||||
|
current_scene->start();
|
||||||
// Main game loop
|
// Main game loop
|
||||||
while (!glfwWindowShouldClose(window))
|
while (!glfwWindowShouldClose(window))
|
||||||
{
|
{
|
||||||
@@ -75,12 +88,13 @@ int main(void)
|
|||||||
const double delta = UpdateDelta();
|
const double delta = UpdateDelta();
|
||||||
entity.IncreaseRotation(glm::vec3(0, 1, 0));
|
entity.IncreaseRotation(glm::vec3(0, 1, 0));
|
||||||
camera.Move(window);
|
camera.Move(window);
|
||||||
|
current_scene->update(window);
|
||||||
|
|
||||||
// Render
|
// Render
|
||||||
render_engine::renderer::Prepare();
|
render_engine::renderer::Prepare();
|
||||||
shader.Start();
|
shader.Start();
|
||||||
shader.LoadViewMatrix(camera);
|
shader.LoadViewMatrix(camera);
|
||||||
|
current_scene->render();
|
||||||
render_engine::renderer::Render(entity, shader);
|
render_engine::renderer::Render(entity, shader);
|
||||||
|
|
||||||
//objDetect.setup();
|
//objDetect.setup();
|
||||||
@@ -95,6 +109,7 @@ int main(void)
|
|||||||
// Clean up
|
// Clean up
|
||||||
shader.CleanUp();
|
shader.CleanUp();
|
||||||
render_engine::loader::CleanUp();
|
render_engine::loader::CleanUp();
|
||||||
|
current_scene->stop();
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
#include "inGameScene.h"
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
void start()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void stop()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void render()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void update(GLFWwindow* window)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void onKey(int key, int scancode, int action, int mods)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* misschien iets van als niet in settings dan hoeft alleen escape een knop zijn als reserve optie. Als wel in settings, dan heb je hetzelfde hoe je in het in het begin scherm hebt.
|
||||||
|
**/
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "scene.h"
|
||||||
|
class InGameScene : public Scene
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual void start() override;
|
||||||
|
virtual void stop() override;
|
||||||
|
virtual void render() override;
|
||||||
|
virtual void update(GLFWwindow* window) override;
|
||||||
|
virtual void onKey(int key, int scancode, int action, int mods) override;
|
||||||
|
};
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include "scene.h"
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
class Scene
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void start() = 0;
|
||||||
|
virtual void stop() = 0;
|
||||||
|
virtual void render() = 0;
|
||||||
|
virtual void update(GLFWwindow* window) = 0;
|
||||||
|
virtual void onKey(int key, int scancode, int action, int mods) {};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
enum class Scenes
|
||||||
|
{
|
||||||
|
STARTUP,
|
||||||
|
INGAME,
|
||||||
|
GAMEOVER,
|
||||||
|
SETTINGS,
|
||||||
|
CALIBRATION
|
||||||
|
};
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
#include "startupScene.h"
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
void start()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void stop()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void render()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void update(GLFWwindow* window)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void onKey(int key, int scancode, int action, int mods)
|
||||||
|
{
|
||||||
|
if (key == GLFW_KEY_DOWN && action == GLFW_RELEASE)
|
||||||
|
{
|
||||||
|
//ideetje voor het scrollen door het menu heen
|
||||||
|
menuIndex = (menuIndex + 1) % 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "scene.h"
|
||||||
|
class StartupScene : public Scene
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
int menuIndex;
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual void start() override;
|
||||||
|
virtual void stop() override;
|
||||||
|
virtual void render() override;
|
||||||
|
virtual void update(GLFWwindow* window) override;
|
||||||
|
virtual void onKey(int key, int scancode, int action, int mods) override;
|
||||||
|
};
|
||||||
|
|
||||||
@@ -19,6 +19,8 @@
|
|||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="src\scenes\inGameScene.cpp" />
|
||||||
|
<ClCompile Include="src\scenes\scene.cpp" />
|
||||||
<ClCompile Include="src\computervision\FaceDetector.cpp" />
|
<ClCompile Include="src\computervision\FaceDetector.cpp" />
|
||||||
<ClCompile Include="src\computervision\ObjectDetection.cpp" />
|
<ClCompile Include="src\computervision\ObjectDetection.cpp" />
|
||||||
<ClCompile Include="src\computervision\SkinDetector.cpp" />
|
<ClCompile Include="src\computervision\SkinDetector.cpp" />
|
||||||
@@ -33,8 +35,11 @@
|
|||||||
<ClCompile Include="src\shaders\shader_program.cpp" />
|
<ClCompile Include="src\shaders\shader_program.cpp" />
|
||||||
<ClCompile Include="src\shaders\static_shader.cpp" />
|
<ClCompile Include="src\shaders\static_shader.cpp" />
|
||||||
<ClCompile Include="src\toolbox\toolbox.cpp" />
|
<ClCompile Include="src\toolbox\toolbox.cpp" />
|
||||||
|
<ClCompile Include="src\scenes\startupScene.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="src\scenes\inGameScene.h" />
|
||||||
|
<ClInclude Include="src\scenes\scene.h" />
|
||||||
<ClInclude Include="src\computervision\FaceDetector.h" />
|
<ClInclude Include="src\computervision\FaceDetector.h" />
|
||||||
<ClInclude Include="src\computervision\FingerCount.h" />
|
<ClInclude Include="src\computervision\FingerCount.h" />
|
||||||
<ClInclude Include="src\computervision\BackgroundRemover.h" />
|
<ClInclude Include="src\computervision\BackgroundRemover.h" />
|
||||||
@@ -50,6 +55,7 @@
|
|||||||
<ClInclude Include="src\shaders\static_shader.h" />
|
<ClInclude Include="src\shaders\static_shader.h" />
|
||||||
<ClInclude Include="src\stb_image.h" />
|
<ClInclude Include="src\stb_image.h" />
|
||||||
<ClInclude Include="src\toolbox\toolbox.h" />
|
<ClInclude Include="src\toolbox\toolbox.h" />
|
||||||
|
<ClInclude Include="src\scenes\startupScene.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Xml Include="res\haarcascade_frontalface_alt.xml" />
|
<Xml Include="res\haarcascade_frontalface_alt.xml" />
|
||||||
|
|||||||
@@ -57,6 +57,15 @@
|
|||||||
<ClCompile Include="src\computervision\BackgroundRemover.cpp">
|
<ClCompile Include="src\computervision\BackgroundRemover.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\scenes\scene.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\scenes\startupScene.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\scenes\inGameScene.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="src\entities\Camera.h">
|
<ClInclude Include="src\entities\Camera.h">
|
||||||
@@ -104,6 +113,15 @@
|
|||||||
<ClInclude Include="src\computervision\BackgroundRemover.h">
|
<ClInclude Include="src\computervision\BackgroundRemover.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\scenes\scene.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\scenes\startupScene.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\scenes\inGameScene.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Xml Include="res\haarcascade_frontalface_alt.xml" />
|
<Xml Include="res\haarcascade_frontalface_alt.xml" />
|
||||||
|
|||||||
Reference in New Issue
Block a user