diff --git a/Game/Game.vcxproj b/Game/Game.vcxproj index 3c4b186..9d7491b 100644 --- a/Game/Game.vcxproj +++ b/Game/Game.vcxproj @@ -1,210 +1,210 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {b7fec2d6-1d8f-487e-89cb-fd611fd1aeb6} - Game - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - $(ProjectDir)bin\$(Platform)$(Configuration)\ - $(ProjectDir)int\$(Platform)$(Configuration)\ - - - false - $(ProjectDir)bin\$(Platform)$(Configuration)\ - $(ProjectDir)int\$(Platform)$(Configuration)\ - - - true - $(ProjectDir)bin\$(Platform)$(Configuration)\ - $(ProjectDir)int\$(Platform)$(Configuration)\ - - - false - $(ProjectDir)bin\$(Platform)$(Configuration)\ - $(ProjectDir)int\$(Platform)$(Configuration)\ - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - $(ProjectDir)src\include\;$(SolutionDir)NothinFancy\src\include\ - $(IntDir)obj\ - - - Console - true - mainCRTStartup - libcmt.lib - /ignore:4099 %(AdditionalOptions) - $(ProjectDir)dep\;%(AdditionalLibraryDirectories) - nf.res;%(AdditionalDependencies) - - - cd "$(SolutionDir)NFPackCreator\bin\AssetBuild" && "$(SolutionDir)NFPackCreator\bin\Win32$(Configuration)\NFPackCreator.exe" && del "$(OutDir)assets\" /Q /S && move "$(SolutionDir)NFPackCreator\bin\AssetBuild\*.nfpack" "$(OutDir)assets\" - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - $(ProjectDir)src\include\;$(SolutionDir)NothinFancy\src\include\ - $(IntDir)obj\ - - - Windows - true - true - true - mainCRTStartup - libcmt.lib - /ignore:4099 %(AdditionalOptions) - $(ProjectDir)dep\;%(AdditionalLibraryDirectories) - nf.res;%(AdditionalDependencies) - - - cd "$(SolutionDir)NFPackCreator\bin\AssetBuild" && "$(SolutionDir)NFPackCreator\bin\Win32$(Configuration)\NFPackCreator.exe" && del "$(OutDir)assets\" /Q /S && move "$(SolutionDir)NFPackCreator\bin\AssetBuild\*.nfpack" "$(OutDir)assets\" - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - $(ProjectDir)src\include\;$(SolutionDir)NothinFancy\src\include\ - $(IntDir)obj\ - - - Console - true - mainCRTStartup - libcmt.lib - /ignore:4099 %(AdditionalOptions) - $(ProjectDir)dep\;%(AdditionalLibraryDirectories) - nf.res;%(AdditionalDependencies) - - - cd "$(SolutionDir)NFPackCreator\bin\AssetBuild" && "$(SolutionDir)NFPackCreator\bin\Win32$(Configuration)\NFPackCreator.exe" && del "$(OutDir)assets\" /Q /S && move "$(SolutionDir)NFPackCreator\bin\AssetBuild\*.nfpack" "$(OutDir)assets\" - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - $(ProjectDir)src\include\;$(SolutionDir)NothinFancy\src\include\ - $(IntDir)obj\ - - - Windows - true - true - true - mainCRTStartup - libcmt.lib - /ignore:4099 %(AdditionalOptions) - $(ProjectDir)dep\;%(AdditionalLibraryDirectories) - nf.res;%(AdditionalDependencies) - - - cd "$(SolutionDir)NFPackCreator\bin\AssetBuild" && "$(SolutionDir)NFPackCreator\bin\Win32$(Configuration)\NFPackCreator.exe" && del "$(OutDir)assets\" /Q /S && move "$(SolutionDir)NFPackCreator\bin\AssetBuild\*.nfpack" "$(OutDir)assets\" - - - - - {1b9c5361-e301-41bf-97e7-56d65f11e2bb} - - - - - - - - - - - - - - - <_delete Include="$(OutDir)**\*" /> - - - + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {b7fec2d6-1d8f-487e-89cb-fd611fd1aeb6} + Game + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + $(ProjectDir)bin\$(Platform)$(Configuration)\ + $(ProjectDir)int\$(Platform)$(Configuration)\ + + + false + $(ProjectDir)bin\$(Platform)$(Configuration)\ + $(ProjectDir)int\$(Platform)$(Configuration)\ + + + true + $(ProjectDir)bin\$(Platform)$(Configuration)\ + $(ProjectDir)int\$(Platform)$(Configuration)\ + + + false + $(ProjectDir)bin\$(Platform)$(Configuration)\ + $(ProjectDir)int\$(Platform)$(Configuration)\ + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(ProjectDir)src\include\;$(SolutionDir)NothinFancy\src\include\ + $(IntDir)obj\ + + + Console + true + mainCRTStartup + libcmt.lib + /ignore:4099 %(AdditionalOptions) + $(ProjectDir)dep\;%(AdditionalLibraryDirectories) + nf.res;%(AdditionalDependencies) + + + cd "$(SolutionDir)NFPackCreator\AssetBuild" && "$(SolutionDir)NFPackCreator\bin\Win32$(Configuration)\NFPackCreator.exe" && del "$(OutDir)assets\" /Q /S && move "$(SolutionDir)NFPackCreator\AssetBuild\*.nfpack" "$(OutDir)assets\" + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(ProjectDir)src\include\;$(SolutionDir)NothinFancy\src\include\ + $(IntDir)obj\ + + + Windows + true + true + true + mainCRTStartup + libcmt.lib + /ignore:4099 %(AdditionalOptions) + $(ProjectDir)dep\;%(AdditionalLibraryDirectories) + nf.res;%(AdditionalDependencies) + + + cd "$(SolutionDir)NFPackCreator\AssetBuild" && "$(SolutionDir)NFPackCreator\bin\Win32$(Configuration)\NFPackCreator.exe" && del "$(OutDir)assets\" /Q /S && move "$(SolutionDir)NFPackCreator\AssetBuild\*.nfpack" "$(OutDir)assets\" + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(ProjectDir)src\include\;$(SolutionDir)NothinFancy\src\include\ + $(IntDir)obj\ + + + Console + true + mainCRTStartup + libcmt.lib + /ignore:4099 %(AdditionalOptions) + $(ProjectDir)dep\;%(AdditionalLibraryDirectories) + nf.res;%(AdditionalDependencies) + + + cd "$(SolutionDir)NFPackCreator\AssetBuild" && "$(SolutionDir)NFPackCreator\bin\Win32$(Configuration)\NFPackCreator.exe" && del "$(OutDir)assets\" /Q /S && move "$(SolutionDir)NFPackCreator\AssetBuild\*.nfpack" "$(OutDir)assets\" + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(ProjectDir)src\include\;$(SolutionDir)NothinFancy\src\include\ + $(IntDir)obj\ + + + Windows + true + true + true + mainCRTStartup + libcmt.lib + /ignore:4099 %(AdditionalOptions) + $(ProjectDir)dep\;%(AdditionalLibraryDirectories) + nf.res;%(AdditionalDependencies) + + + cd "$(SolutionDir)NFPackCreator\AssetBuild" && "$(SolutionDir)NFPackCreator\bin\Win32$(Configuration)\NFPackCreator.exe" && del "$(OutDir)assets\" /Q /S && move "$(SolutionDir)NFPackCreator\AssetBuild\*.nfpack" "$(OutDir)assets\" + + + + + {1b9c5361-e301-41bf-97e7-56d65f11e2bb} + + + + + + + + + + + + + + + <_delete Include="$(OutDir)**\*" /> + + + \ No newline at end of file diff --git a/Game/src/MainState.cpp b/Game/src/MainState.cpp index 5d4f146..bbabee9 100644 --- a/Game/src/MainState.cpp +++ b/Game/src/MainState.cpp @@ -1,24 +1,24 @@ -#include "MainState.h" - -MainState::MainState(nf::Application* app) : - Gamestate(app) -{ - -} - -void MainState::onEnter() { - Log("MainState onEnter!"); - -} - -void MainState::update(double deltaTime) { - -} - -void MainState::render(nf::Renderer& renderer) { - -} - -void MainState::onExit() { - Log("MainState onExit!"); +#include "MainState.h" + +MainState::MainState(nf::Application* app) : + Gamestate(app) +{ + +} + +void MainState::onEnter() { + Log("MainState onEnter!"); + +} + +void MainState::update(double deltaTime) { + +} + +void MainState::render(nf::Renderer& renderer) { + +} + +void MainState::onExit() { + Log("MainState onExit!"); } \ No newline at end of file diff --git a/Game/src/include/MainState.h b/Game/src/include/MainState.h index 3335fb6..15c6cc1 100644 --- a/Game/src/include/MainState.h +++ b/Game/src/include/MainState.h @@ -1,16 +1,16 @@ -#pragma once -#include "NothinFancy.h" - -class MainState : public nf::Gamestate { -public: - MainState(nf::Application* app); - - void onEnter() override; - - void update(double deltaTime) override; - void render(nf::Renderer& renderer) override; - - void onExit() override; -private: - +#pragma once +#include "NothinFancy.h" + +class MainState : public nf::Gamestate { +public: + MainState(nf::Application* app); + + void onEnter() override; + + void update(double deltaTime) override; + void render(nf::Renderer& renderer) override; + + void onExit() override; +private: + }; \ No newline at end of file diff --git a/NFPackCreator/AssetBuild/CubeTest/models/cube.obj b/NFPackCreator/AssetBuild/CubeTest/models/cube.obj new file mode 100644 index 0000000..1f50dcb --- /dev/null +++ b/NFPackCreator/AssetBuild/CubeTest/models/cube.obj @@ -0,0 +1,40 @@ +# Blender v2.93.3 OBJ File: '' +# www.blender.org +o Cube_Cube.001 +v -1.000000 -1.000000 -1.000000 +v -1.000000 1.000000 -1.000000 +v 1.000000 -1.000000 -1.000000 +v 1.000000 1.000000 -1.000000 +v -1.000000 -1.000000 1.000000 +v -1.000000 1.000000 1.000000 +v 1.000000 -1.000000 1.000000 +v 1.000000 1.000000 1.000000 +vt 0.375000 0.003906 +vt 0.625000 0.253906 +vt 0.375000 0.253906 +vt 0.875000 0.750000 +vt 0.625000 0.500000 +vt 0.875000 0.500000 +vt 0.625000 0.750000 +vt 0.375000 0.500000 +vt 0.375000 0.750000 +vt 0.125000 0.500000 +vt 0.375000 0.250000 +vt 0.625000 0.250000 +vt 0.625000 1.000000 +vt 0.625000 0.003906 +vt 0.125000 0.750000 +vt 0.375000 1.000000 +s off +f 2/1 3/2 1/3 +f 4/4 7/5 3/6 +f 8/7 5/8 7/5 +f 6/9 1/10 5/8 +f 7/5 1/11 3/12 +f 4/13 6/9 8/7 +f 2/1 4/14 3/2 +f 4/4 8/7 7/5 +f 8/7 6/9 5/8 +f 6/9 2/15 1/10 +f 7/5 5/8 1/11 +f 4/13 2/16 6/9 diff --git a/NFPackCreator/AssetBuild/CubeTest/textures/cube.png b/NFPackCreator/AssetBuild/CubeTest/textures/cube.png new file mode 100644 index 0000000..61abd60 Binary files /dev/null and b/NFPackCreator/AssetBuild/CubeTest/textures/cube.png differ diff --git a/NothinFancy/src/Application.cpp b/NothinFancy/src/Application.cpp index 2c376e5..7e0c437 100644 --- a/NothinFancy/src/Application.cpp +++ b/NothinFancy/src/Application.cpp @@ -78,6 +78,7 @@ namespace nf { break; } } + updateInput(); std::this_thread::sleep_for(std::chrono::milliseconds(5)); } mainThread.join(); @@ -185,33 +186,40 @@ namespace nf { } } + void Application::updateInput() { + for (unsigned int i = 0; i < 164; i++) { + if (GetFocus() == m_window) + m_input[i] = GetKeyState(i) & 0x8000; + else + m_input[i] = false; + } + } + void Application::runMainGameThread() { m_renderer = new Renderer(this); startIntroState(); - std::chrono::steady_clock::time_point start_time = std::chrono::steady_clock::now(); - const std::chrono::duration wait_time = std::chrono::nanoseconds(1000000000 / 60); - auto next_time = start_time + wait_time; - m_deltaTime = 0.0167; + std::chrono::steady_clock::time_point currentTime = std::chrono::steady_clock::now(); + std::chrono::steady_clock::time_point lastFrame = std::chrono::steady_clock::now(); while (m_running) { - start_time = std::chrono::steady_clock::now(); - m_currentState->update(m_deltaTime); - m_currentState->render(*m_renderer); - m_renderer->doFrame(); - m_frames++; - if (m_stateChange) - doStateChange(); + currentTime = std::chrono::steady_clock::now(); + m_deltaTime = std::chrono::duration(currentTime - lastFrame).count(); + if (m_deltaTime >= m_minFrametime) { + lastFrame = std::chrono::steady_clock::now(); + m_currentState->update(m_deltaTime); + m_currentState->render(*m_renderer); + m_renderer->doFrame(); + m_frames++; + if (m_stateChange) + doStateChange(); + } m_fpsClock2 = std::chrono::steady_clock::now(); m_fpsDuration = m_fpsClock2 - m_fpsClock1; if (m_fpsDuration.count() >= 1.0) { - m_FPS = m_frames - 1; + m_FPS = m_frames; m_frames = 0; Log("FPS: " + std::to_string(m_FPS)); m_fpsClock1 = std::chrono::steady_clock::now(); } - std::this_thread::sleep_until(next_time); - m_deltaTime = (double)(std::chrono::steady_clock::now() - start_time).count(); - next_time += wait_time; - //TODO: Redo FPS AGAIN like how I did it in PongClone } m_currentState->onExit(); delete m_renderer; @@ -255,42 +263,6 @@ namespace nf { case WM_MENUCHAR: { return MNC_CLOSE << 16; } - case WM_LBUTTONDOWN: { - app->m_input[1] = true; - return 0; - } - case WM_LBUTTONUP: { - app->m_input[1] = false; - return 0; - } - case WM_RBUTTONDOWN: { - app->m_input[2] = true; - return 0; - } - case WM_RBUTTONUP: { - app->m_input[2] = false; - return 0; - } - case WM_MBUTTONDOWN: { - app->m_input[4] = true; - return 0; - } - case WM_MBUTTONUP: { - app->m_input[4] = false; - return 0; - } - case WM_KEYDOWN: { - if (wParam < 164 && !(lParam & (1 << 30))) { - app->m_input[wParam] = true; - } - break; - } - case WM_KEYUP: { - if (wParam < 164) { - app->m_input[wParam] = false; - } - break; - } case WM_CLOSE: { DestroyWindow(hWnd); return 0; diff --git a/NothinFancy/src/Renderer/Renderer.cpp b/NothinFancy/src/Renderer/Renderer.cpp index e31c301..55d8b1c 100644 --- a/NothinFancy/src/Renderer/Renderer.cpp +++ b/NothinFancy/src/Renderer/Renderer.cpp @@ -70,7 +70,7 @@ namespace nf { void Renderer::doFrame() { glViewport(0, 0, m_app->getConfig().width, m_app->getConfig().height); - proj = glm::perspective(glm::radians(45.0f), (float)m_app->getConfig().width / (float)m_app->getConfig().height, 0.1f, 100.0f); + proj = glm::perspective(glm::radians(45.0f), (float)m_app->getConfig().width / (float)m_app->getConfig().height, 0.1f, 100000.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); for (Entity* draw : m_lGame) { diff --git a/NothinFancy/src/include/Application.h b/NothinFancy/src/include/Application.h index 6465717..d99c7e1 100644 --- a/NothinFancy/src/include/Application.h +++ b/NothinFancy/src/include/Application.h @@ -35,6 +35,7 @@ namespace nf { RECT getWindowRect() const; void calculateNewWindowPos(int& x, int& y); void toggleFullscreen(); + void updateInput(); void runMainGameThread(); void startIntroState(); void doStateChange();