From e4dbfa672ca83df3e0b6791ed7e513711aa512b0 Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 20 May 2020 01:12:18 +0100 Subject: [PATCH] done barely anything smh --- src/Rendering/camera.hpp | 4 +- src/Rendering/face.hpp | 127 +++++++++++++++++++++++++++++++++++++ src/Rendering/frustrum.hpp | 4 +- src/Rendering/shader.hpp | 4 +- src/Rendering/texture.hpp | 4 +- src/display.cpp | 5 +- src/main.cpp | 4 +- src/threadpool.hpp | 1 + 8 files changed, 142 insertions(+), 11 deletions(-) create mode 100644 src/Rendering/face.hpp create mode 100644 src/threadpool.hpp diff --git a/src/Rendering/camera.hpp b/src/Rendering/camera.hpp index 239348a..f14d0eb 100644 --- a/src/Rendering/camera.hpp +++ b/src/Rendering/camera.hpp @@ -1,5 +1,5 @@ -#ifndef MINECRAFT_RENDERER_CAMERA_H_ -#define MINECRAFT_RENDERER_CAMERA_H_ +#ifndef MINECRAFT_RENDERING_CAMERA_H_ +#define MINECRAFT_RENDERING_CAMERA_H_ #include #include diff --git a/src/Rendering/face.hpp b/src/Rendering/face.hpp new file mode 100644 index 0000000..9a9695f --- /dev/null +++ b/src/Rendering/face.hpp @@ -0,0 +1,127 @@ +#ifndef MINECRAFT_RENDERING_FACE_H_ +#define MINECRAFT_RENDERING_FACE_H_ + +#include "../../common.hpp" + +namespace EFaceType { + + enum Face : uint8_t { + Top, + Bottom, + Left, + Right, + Front, + Back, + }; + +} + +static std::vector CubeTopFace = { + { -0.5f, 0.5f, -0.5f }, + { 0.5f, 0.5f, -0.5f }, + { 0.5f, 0.5f, 0.5f }, + { 0.5f, 0.5f, 0.5f }, + { -0.5f, 0.5f, 0.5f }, + { -0.5f, 0.5f, -0.5f } +}; + +static std::vector CubeTopFaceUVs = { + { 0.0f, 0.0f }, + { 1.0f, 0.0f }, + { 1.0f, 1.0f }, + { 1.0f, 1.0f }, + { 0.0f, 1.0f }, + { 0.0f, 0.0f } +}; + +static std::vector CubeBottomFace = { + { -0.5f, -0.5f, -0.5f }, + { 0.5f, -0.5f, -0.5f }, + { 0.5f, -0.5f, 0.5f }, + { 0.5f, -0.5f, 0.5f }, + { -0.5f, -0.5f, 0.5f }, + { -0.5f, -0.5f, -0.5f } +}; + +static std::vector CubeBottomFaceUVs = { + { 0.0f, 0.0f }, + { 1.0f, 0.0f }, + { 1.0f, 1.0f }, + { 1.0f, 1.0f }, + { 0.0f, 1.0f }, + { 0.0f, 0.0f } +}; + +static std::vector CubeLeftFace = { + { -0.5f, 0.5f, 0.5f }, + { -0.5f, 0.5f, -0.5f }, + { -0.5f, -0.5f, -0.5f }, + { -0.5f, -0.5f, -0.5f }, + { -0.5f, -0.5f, 0.5f }, + { -0.5f, 0.5f, 0.5f } +}; + +static std::vector CubeLeftFaceUVs = { + { 0.0f, 0.0f }, + { 1.0f, 0.0f }, + { 1.0f, 1.0f }, + { 1.0f, 1.0f }, + { 0.0f, 1.0f }, + { 0.0f, 0.0f } +}; + +static std::vector CubeRightFace = { + { 0.5f, 0.5f, 0.5f }, + { 0.5f, 0.5f, -0.5f }, + { 0.5f, -0.5f, -0.5f }, + { 0.5f, -0.5f, -0.5f }, + { 0.5f, -0.5f, 0.5f }, + { 0.5f, 0.5f, 0.5f }, +}; + +static std::vector CubeRightFaceUVs = { + { 0.0f, 0.0f }, + { 1.0f, 0.0f }, + { 1.0f, 1.0f }, + { 1.0f, 1.0f }, + { 0.0f, 1.0f }, + { 0.0f, 0.0f } +}; + +static std::vector CubeFrontFace = { + { -0.5f, -0.5f, 0.5f }, + { 0.5f, -0.5f, 0.5f }, + { 0.5f, 0.5f, 0.5f }, + { 0.5f, 0.5f, 0.5f }, + { -0.5f, 0.5f, 0.5f }, + { -0.5f, -0.5f, 0.5f } +}; + +static std::vector CubeFrontFaceUVs = { + { 1.0f, 1.0f }, + { 0.0f, 1.0f }, + { 0.0f, 0.0f }, + { 0.0f, 0.0f }, + { 1.0f, 0.0f }, + { 1.0f, 1.0f } +}; + +static std::vector CubeBackFace = { + { -0.5f, -0.5f, -0.5f }, + { 0.5f, -0.5f, -0.5f }, + { 0.5f, 0.5f, -0.5f }, + { 0.5f, 0.5f, -0.5f }, + { -0.5f, 0.5f, -0.5f }, + { -0.5f, -0.5f, -0.5f } +}; + +static std::vector CubeBackFaceUVs = { + { 1.0f, 1.0f }, + { 0.0f, 1.0f }, + { 0.0f, 0.0f }, + { 0.0f, 0.0f }, + { 1.0f, 0.0f }, + { 1.0f, 1.0f } +}; + +#endif diff --git a/src/Rendering/frustrum.hpp b/src/Rendering/frustrum.hpp index ebf0368..a29f37b 100644 --- a/src/Rendering/frustrum.hpp +++ b/src/Rendering/frustrum.hpp @@ -1,5 +1,5 @@ -#ifndef MINECRAFT_RENDERER_FRUSTRUM_H_ -#define MINECRAFT_RENDERER_FRUSTRUM_H_ +#ifndef MINECRAFT_RENDERING_FRUSTRUM_H_ +#define MINECRAFT_RENDERING_FRUSTRUM_H_ namespace EFrustrumPlanes { diff --git a/src/Rendering/shader.hpp b/src/Rendering/shader.hpp index a5a746f..7f7e709 100644 --- a/src/Rendering/shader.hpp +++ b/src/Rendering/shader.hpp @@ -1,5 +1,5 @@ -#ifndef MINECRAFT_RENDERER_SHADER_H_ -#define MINECRAFT_RENDERER_SHADER_H_ +#ifndef MINECRAFT_RENDERING_SHADER_H_ +#define MINECRAFT_RENDERING_SHADER_H_ #include diff --git a/src/Rendering/texture.hpp b/src/Rendering/texture.hpp index dd6a123..cffbcb1 100644 --- a/src/Rendering/texture.hpp +++ b/src/Rendering/texture.hpp @@ -1,5 +1,5 @@ -#ifndef MINECRAFT_RENDERER_TEXTURE_H_ -#define MINECRAFT_RENDERER_TEXTURE_H_ +#ifndef MINECRAFT_RENDERING_TEXTURE_H_ +#define MINECRAFT_RENDERING_TEXTURE_H_ #include #include diff --git a/src/display.cpp b/src/display.cpp index 5ce00fe..7b38153 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -82,8 +82,9 @@ void Display::Input( SDL_Event* e ) { if ( e->window.event == SDL_WINDOWEVENT_RESIZED ) { - // CameraUpdateProjection( e->window.data1, e->window.data2 ); - glViewport( 0, 0, e->window.data1, e->window.data2 ); + mW = e->window.data1; mH = e->window.data2; + // CameraUpdateProjection( mW, mH ); + glViewport( 0, 0, mW, mH ); } break; diff --git a/src/main.cpp b/src/main.cpp index 3bfc896..68ce3b1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,6 +13,7 @@ #include "display.hpp" #include "settings.hpp" +#include "Rendering/texture.hpp" #define __DEBUG @@ -45,7 +46,6 @@ void Loop( Display* display ) // make framerate agnostic display->Input( &e ); - // rendering here display->NextFrame(); @@ -73,6 +73,8 @@ int main( int argc, char** argv ) Display display { WindowWidth, WindowHeight, version.str() }; + + Loop( &display ); } diff --git a/src/threadpool.hpp b/src/threadpool.hpp new file mode 100644 index 0000000..507ae11 --- /dev/null +++ b/src/threadpool.hpp @@ -0,0 +1 @@ +// Threadpool for asset management and other such tasks \ No newline at end of file