2020-02-13 22:13:16 -08:00
|
|
|
// Cpp STL
|
|
|
|
|
|
|
|
// Project
|
|
|
|
#include "DGL.hpp"
|
2020-02-15 19:32:26 -08:00
|
|
|
#include "Actions.hpp"
|
|
|
|
#include "Testing.hpp"
|
2020-02-13 22:13:16 -08:00
|
|
|
|
|
|
|
#include "Cpp_Alias.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Execution
|
|
|
|
{
|
2020-02-15 19:32:26 -08:00
|
|
|
inline namespace Alias
|
2020-02-13 22:13:16 -08:00
|
|
|
{
|
2020-02-15 19:32:26 -08:00
|
|
|
// DGL
|
|
|
|
|
|
|
|
using DGL::Camera ;
|
|
|
|
using DGL::ECursorMode ;
|
|
|
|
using DGL::EDirection ;
|
|
|
|
using DGL::EFrameBuffer ;
|
|
|
|
using DGL::EKeyCodes ;
|
|
|
|
using DGL::EMouseMode ;
|
|
|
|
using DGL::EPrimitives ;
|
|
|
|
using DGL::ERotationAxis;
|
|
|
|
using DGL::gFloat ;
|
|
|
|
using DGL::LinearColor ;
|
|
|
|
using DGL::Matrix ;
|
|
|
|
using DGL::Matrix4x4 ;
|
|
|
|
using DGL::TimeValDec ;
|
|
|
|
using DGL::Vector3 ;
|
|
|
|
using DGL::Window ;
|
|
|
|
|
|
|
|
using DGL::SimpleShader;
|
|
|
|
|
|
|
|
using DGL::CanUseRawMouse ;
|
|
|
|
using DGL::ClearBuffer ;
|
|
|
|
using DGL::CreateWindow ;
|
|
|
|
using DGL::BindVertexArray ;
|
|
|
|
using DGL::DisableVertexAttributeArray;
|
|
|
|
using DGL::EnableVertexAttributeArray ;
|
|
|
|
using DGL::GetCursorPosition ;
|
|
|
|
using DGL::GetTime ;
|
|
|
|
using DGL::InitalizeGLEW ;
|
|
|
|
using DGL::InitalizeGLFW ;
|
2020-02-16 22:28:24 -08:00
|
|
|
using DGL::LoadDefaultShaders ;
|
2020-02-15 19:32:26 -08:00
|
|
|
using DGL::KeyPressed ;
|
|
|
|
using DGL::NotShared ;
|
|
|
|
using DGL::PollEvents ;
|
|
|
|
using DGL::ResetCursor ;
|
|
|
|
using DGL::SetClearColor ;
|
|
|
|
using DGL::SetCurrentContext ;
|
|
|
|
using DGL::SetInputMode ;
|
|
|
|
using DGL::SetPolygonMode ;
|
|
|
|
using DGL::SetUniformVariable_MVA ;
|
|
|
|
using DGL::SwapBuffers ;
|
|
|
|
using DGL::UseProgramShader ;
|
|
|
|
using DGL::TerminateGLFW ;
|
|
|
|
using DGL::WindowedMode ;
|
|
|
|
|
|
|
|
using DGL::DefaultSpace::ScreenWidth ;
|
|
|
|
using DGL::DefaultSpace::ScreenHeight ;
|
|
|
|
using DGL::DefaultSpace::ScreenCenterHeight;
|
|
|
|
using DGL::DefaultSpace::ScreenCenterWidth ;
|
|
|
|
using DGL::DefaultSpace::Screenspace ;
|
|
|
|
using DGL::DefaultSpace::WorldCamera ;
|
|
|
|
|
|
|
|
using DGL::DefaultSpace::UpdateScreenspace;
|
|
|
|
|
|
|
|
// Actions
|
|
|
|
|
|
|
|
using Actions::ActionQueue;
|
2020-02-13 22:13:16 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
// Globals
|
2020-02-13 22:13:16 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
bool Exist = true; // Determines if the the execution should exit cycler.
|
2020-02-13 22:13:16 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
TimeValDec CycleStart , // Snapshot of cycle loop start time.
|
|
|
|
CycleEnd , // Snapshot of cycle loop end time.
|
|
|
|
DeltaTime , // Delta between last cycle start and end.
|
2020-02-17 09:39:31 -08:00
|
|
|
InputInterval = 1.0f / 400.0f, // Interval per second to complete the input process of the cycle.
|
|
|
|
PhysicsInterval = 1.0f / 240.0f, // Interval per second to complete the physics process of the cycle.
|
2020-02-17 00:38:40 -08:00
|
|
|
RenderInterval = 1.0f / 144.0f ; // Interval per second to complete the render process of the cycle.
|
2020-02-13 22:13:16 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
ptr<Window> DefaultWindow; // Default window to use for execution.
|
2020-02-13 22:13:16 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
double CursorX, CursorY; // Cursor axis position on the window.
|
2020-02-13 22:13:16 -08:00
|
|
|
|
2020-02-17 18:10:15 -08:00
|
|
|
bool CursorOff = true;
|
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
gFloat CamMoveSpeed = 8.0f, // Rate at which the camera should move.
|
2020-02-17 00:38:40 -08:00
|
|
|
CamRotationSpeed = 27.0f ; // Rate at which the camera should rotate.
|
2020-02-13 22:13:16 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
TimeValDec InputDelta = 0.0, // Current delta since last input process.
|
|
|
|
PhysicsDelta = 0.0, // Current delta since last physics process.
|
|
|
|
RenderDelta = 0.0 ; // Current delta since last render process.
|
2020-02-13 22:13:16 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
ActionQueue ActionsToComplete; // Actions queue to run during the physics process of the cycle.
|
2020-02-14 23:21:27 -08:00
|
|
|
|
2020-02-18 11:37:17 -08:00
|
|
|
|
2020-02-14 23:21:27 -08:00
|
|
|
|
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
// Functionality
|
2020-02-14 23:21:27 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
// Temp fix for now... not sure how to make proper action handling that can reference member function delegates...
|
2020-02-14 23:21:27 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
sfn RotateCamera(ERotationAxis _rotationAxis, gFloat _rotationAmount, gFloat _delta)
|
2020-02-14 23:21:27 -08:00
|
|
|
{
|
2020-02-15 19:32:26 -08:00
|
|
|
WorldCamera.Rotate(_rotationAxis, _rotationAmount, _delta);
|
|
|
|
}
|
|
|
|
|
|
|
|
deduce RotateCamDelegate = Delegate<decltype(RotateCamera)>(RotateCamera);
|
2020-02-14 23:21:27 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
sfn MoveCamera(EDirection _direction, gFloat _translationAmount, gFloat _delta)
|
2020-02-14 23:21:27 -08:00
|
|
|
{
|
2020-02-15 19:32:26 -08:00
|
|
|
WorldCamera.Move(_direction, _translationAmount, _delta);
|
|
|
|
}
|
|
|
|
|
|
|
|
deduce MoveCamDelegate = Delegate<decltype(MoveCamera)>(MoveCamera);
|
2020-02-14 23:21:27 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
// End of temp stuff...
|
2020-02-14 23:21:27 -08:00
|
|
|
|
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
// Currently Does everything required before entering the cycler.
|
|
|
|
sfn PrepWorkspace()
|
2020-02-14 23:21:27 -08:00
|
|
|
{
|
2020-02-15 19:32:26 -08:00
|
|
|
InitalizeGLFW();
|
2020-02-13 22:13:16 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
DefaultWindow = CreateWindow(ScreenWidth, ScreenHeight, "Assignment 1: Lighting Test", WindowedMode(), NotShared());
|
2020-02-13 22:13:16 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
SetCurrentContext(DefaultWindow);
|
2020-02-13 22:13:16 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
InitalizeGLEW(); // Glew must initialize only after a context is set.
|
2020-02-13 22:13:16 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
// Cursor stuff
|
2020-02-13 22:13:16 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
SetInputMode(DefaultWindow, DGL::EMouseMode::Cursor, DGL::ECursorMode::Disable);
|
2020-02-13 22:13:16 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
ResetCursor(DefaultWindow, ScreenCenterWidth, ScreenCenterHeight);
|
2020-02-13 22:13:16 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
if (CanUseRawMouse())
|
|
|
|
{
|
|
|
|
SetInputMode(DefaultWindow, DGL::EMouseMode::RawMouse, DGL::EBool::True);
|
|
|
|
}
|
2020-02-13 22:13:16 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
// End of cursor stuff...
|
2020-02-13 22:13:16 -08:00
|
|
|
|
2020-02-16 22:28:24 -08:00
|
|
|
LoadDefaultShaders();
|
|
|
|
|
|
|
|
//PrepareRenderObjects();
|
2020-02-13 22:13:16 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
SetPolygonMode(DGL::EFace::Front_and_Back, DGL::ERenderMode::Fill);
|
2020-02-13 22:13:16 -08:00
|
|
|
|
2020-02-16 22:28:24 -08:00
|
|
|
RAW_MakeCube();
|
|
|
|
|
|
|
|
RAW_MakeLightVAO();
|
|
|
|
|
|
|
|
ProperCube::Setup();
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Clean THIS
|
|
|
|
|
|
|
|
// Enable depth test
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
// Accept fragment if it closer to the camera than the former one
|
|
|
|
glDepthFunc(GL_LESS);
|
|
|
|
}
|
2020-02-14 23:21:27 -08:00
|
|
|
|
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
/*
|
|
|
|
Cycles the process of what to do while a window is open.
|
2020-02-14 23:21:27 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
The input, physics, and render procedures can be specified with extra functionality by specifying delegates to those procedures.
|
2020-02-14 23:21:27 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
Cycler is hardcoded to exit if escape key is pressed.
|
|
|
|
*/
|
|
|
|
sfn Cycler(Delegate< Func<void, ptr<Window>> > _inputProcedure, Delegate< Func<void>> _physicsProcedure, Delegate< Func<void>> _renderProcedure)
|
2020-02-13 22:13:16 -08:00
|
|
|
{
|
|
|
|
while (Exist)
|
|
|
|
{
|
2020-02-15 19:32:26 -08:00
|
|
|
CycleStart = GetTime();
|
2020-02-13 22:13:16 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
if (InputDelta >= InputInterval)
|
2020-02-13 22:13:16 -08:00
|
|
|
{
|
2020-02-15 19:32:26 -08:00
|
|
|
PollEvents();
|
2020-02-14 23:21:27 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
if (KeyPressed(DefaultWindow, EKeyCodes::Escape))
|
|
|
|
{
|
|
|
|
Exist = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetCursorPosition(DefaultWindow, Address(CursorX), Address(CursorY));
|
2020-02-14 23:21:27 -08:00
|
|
|
|
|
|
|
_inputProcedure(DefaultWindow);
|
|
|
|
|
2020-02-17 18:10:15 -08:00
|
|
|
if (CursorOff)
|
|
|
|
{
|
|
|
|
ResetCursor(DefaultWindow, ScreenCenterWidth, ScreenCenterHeight);
|
|
|
|
}
|
2020-02-13 22:13:16 -08:00
|
|
|
|
2020-02-14 23:21:27 -08:00
|
|
|
InputDelta = 0.0;
|
2020-02-13 22:13:16 -08:00
|
|
|
}
|
|
|
|
|
2020-02-14 23:21:27 -08:00
|
|
|
if (PhysicsDelta >= PhysicsInterval)
|
2020-02-13 22:13:16 -08:00
|
|
|
{
|
2020-02-15 19:32:26 -08:00
|
|
|
while (ActionsToComplete.HasAction())
|
|
|
|
{
|
|
|
|
ActionsToComplete.DoNextAction();
|
|
|
|
}
|
2020-02-14 23:21:27 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
_physicsProcedure();
|
2020-02-14 23:21:27 -08:00
|
|
|
|
|
|
|
PhysicsDelta = 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RenderDelta >= RenderInterval)
|
|
|
|
{
|
2020-02-15 19:32:26 -08:00
|
|
|
ClearBuffer(EFrameBuffer::Color, EFrameBuffer::Depth);
|
2020-02-14 23:21:27 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
SetClearColor(LinearColor(0.12f, 0.12f, 0.12f, 1.0f));
|
2020-02-14 23:21:27 -08:00
|
|
|
|
2020-02-13 22:13:16 -08:00
|
|
|
_renderProcedure();
|
2020-02-14 23:21:27 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
SwapBuffers(DefaultWindow);
|
2020-02-14 23:21:27 -08:00
|
|
|
|
|
|
|
RenderDelta = 0.0;
|
2020-02-13 22:13:16 -08:00
|
|
|
}
|
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
CycleEnd = GetTime();
|
2020-02-14 23:21:27 -08:00
|
|
|
|
|
|
|
DeltaTime = CycleEnd - CycleStart;
|
2020-02-13 22:13:16 -08:00
|
|
|
|
2020-02-14 23:21:27 -08:00
|
|
|
InputDelta += DeltaTime;
|
|
|
|
PhysicsDelta += DeltaTime;
|
|
|
|
RenderDelta += DeltaTime;
|
2020-02-13 22:13:16 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-02-17 09:39:31 -08:00
|
|
|
sfn ModifyCamSpeed(bool _isPositive, gFloat _delta)
|
2020-02-16 22:28:24 -08:00
|
|
|
{
|
|
|
|
if (_isPositive)
|
|
|
|
{
|
2020-02-17 09:39:31 -08:00
|
|
|
CamMoveSpeed += CamMoveSpeed * _delta;
|
2020-02-16 22:28:24 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-02-17 09:39:31 -08:00
|
|
|
CamMoveSpeed -= CamMoveSpeed * _delta;
|
2020-02-16 22:28:24 -08:00
|
|
|
}
|
|
|
|
}
|
2020-02-14 23:21:27 -08:00
|
|
|
|
2020-02-17 00:38:40 -08:00
|
|
|
deduce ModifyCamSpeedDelegate = Delegate<decltype(ModifyCamSpeed)>(ModifyCamSpeed);
|
2020-02-17 18:10:15 -08:00
|
|
|
deduce SetPolyModeDelegate = Delegate<decltype(SetPolygonMode)>(SetPolygonMode);
|
2020-02-14 23:21:27 -08:00
|
|
|
|
|
|
|
sfn InputProcedure(ptr<Window> _currentWindowContext)
|
2020-02-13 22:13:16 -08:00
|
|
|
{
|
2020-02-14 23:21:27 -08:00
|
|
|
if (KeysPressed(_currentWindowContext, EKeyCodes::LeftShift, EKeyCodes::F1))
|
|
|
|
{
|
|
|
|
ECursorMode cursorMode = ECursorMode(GetMouseInputMode(DefaultWindow, EMouseMode::Cursor));
|
|
|
|
|
2020-02-17 00:38:40 -08:00
|
|
|
deduce delegate = Delegate<decltype(SetInputMode<ECursorMode>)>(SetInputMode<ECursorMode>);
|
|
|
|
deduce delegateRaw = Delegate<decltype(SetInputMode<EBool >)>(SetInputMode<EBool >);
|
2020-02-15 19:32:26 -08:00
|
|
|
|
2020-02-14 23:21:27 -08:00
|
|
|
if (cursorMode == ECursorMode::Normal || cursorMode == ECursorMode::Hidden)
|
|
|
|
{
|
2020-02-17 00:38:40 -08:00
|
|
|
ActionsToComplete.AddToQueue(delegate , _currentWindowContext, EMouseMode::Cursor , ECursorMode::Disable);
|
|
|
|
ActionsToComplete.AddToQueue(delegateRaw, _currentWindowContext, EMouseMode::RawMouse, EBool ::True );
|
2020-02-17 18:10:15 -08:00
|
|
|
|
|
|
|
CursorOff = true;
|
2020-02-14 23:21:27 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-02-17 00:38:40 -08:00
|
|
|
ActionsToComplete.AddToQueue(delegate , _currentWindowContext, EMouseMode::Cursor , ECursorMode::Normal);
|
|
|
|
ActionsToComplete.AddToQueue(delegateRaw, _currentWindowContext, EMouseMode::RawMouse, EBool ::False );
|
2020-02-17 18:10:15 -08:00
|
|
|
|
|
|
|
CursorOff = false;
|
2020-02-14 23:21:27 -08:00
|
|
|
}
|
|
|
|
}
|
2020-02-13 22:13:16 -08:00
|
|
|
|
2020-02-16 22:28:24 -08:00
|
|
|
if (KeyPressed(_currentWindowContext, EKeyCodes::UpArrow))
|
|
|
|
{
|
2020-02-17 09:39:31 -08:00
|
|
|
ActionsToComplete.AddToQueue(ModifyCamSpeedDelegate, true, PhysicsDelta);
|
2020-02-16 22:28:24 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (KeysPressed(_currentWindowContext, EKeyCodes::DnArrow))
|
|
|
|
{
|
2020-02-17 09:39:31 -08:00
|
|
|
ActionsToComplete.AddToQueue(ModifyCamSpeedDelegate, false, PhysicsDelta);
|
2020-02-16 22:28:24 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (KeyPressed(_currentWindowContext, EKeyCodes::F2))
|
|
|
|
{
|
|
|
|
ActionsToComplete.AddToQueue(SetPolyModeDelegate, DGL::EFace::Front_and_Back, DGL::ERenderMode::Line);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (KeyPressed(_currentWindowContext, EKeyCodes::F3))
|
|
|
|
{
|
|
|
|
ActionsToComplete.AddToQueue(SetPolyModeDelegate, DGL::EFace::Front_and_Back, DGL::ERenderMode::Fill);
|
|
|
|
}
|
|
|
|
|
2020-02-17 18:10:15 -08:00
|
|
|
if (CursorOff)
|
2020-02-14 23:21:27 -08:00
|
|
|
{
|
2020-02-17 18:10:15 -08:00
|
|
|
if (CursorX != 0)
|
|
|
|
{
|
|
|
|
ActionsToComplete.AddToQueue(RotateCamDelegate, ERotationAxis::Yaw, CursorX * CamRotationSpeed, PhysicsDelta);
|
|
|
|
}
|
2020-02-14 23:21:27 -08:00
|
|
|
|
2020-02-17 18:10:15 -08:00
|
|
|
if (CursorY != 0)
|
|
|
|
{
|
|
|
|
ActionsToComplete.AddToQueue(RotateCamDelegate, ERotationAxis::Pitch, CursorY * CamRotationSpeed, PhysicsDelta);
|
|
|
|
}
|
2020-02-14 23:21:27 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (KeyPressed(_currentWindowContext, EKeyCodes::E))
|
|
|
|
{
|
2020-02-15 19:32:26 -08:00
|
|
|
ActionsToComplete.AddToQueue(MoveCamDelegate, EDirection::Up, CamMoveSpeed, PhysicsDelta);
|
2020-02-14 23:21:27 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (KeyPressed(_currentWindowContext, EKeyCodes::Q))
|
|
|
|
{
|
2020-02-15 19:32:26 -08:00
|
|
|
ActionsToComplete.AddToQueue(MoveCamDelegate, EDirection::Down, CamMoveSpeed, PhysicsDelta);
|
2020-02-14 23:21:27 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (KeyPressed(_currentWindowContext, EKeyCodes::A))
|
|
|
|
{
|
2020-02-15 19:32:26 -08:00
|
|
|
ActionsToComplete.AddToQueue(MoveCamDelegate, EDirection::Left, CamMoveSpeed, PhysicsDelta);
|
2020-02-14 23:21:27 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (KeyPressed(_currentWindowContext, EKeyCodes::D))
|
|
|
|
{
|
2020-02-15 19:32:26 -08:00
|
|
|
ActionsToComplete.AddToQueue(MoveCamDelegate, EDirection::Right, CamMoveSpeed, PhysicsDelta);
|
2020-02-14 23:21:27 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (KeyPressed(_currentWindowContext, EKeyCodes::W))
|
|
|
|
{
|
2020-02-15 19:32:26 -08:00
|
|
|
ActionsToComplete.AddToQueue(MoveCamDelegate, EDirection::Forward, CamMoveSpeed, PhysicsDelta);
|
2020-02-14 23:21:27 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (KeyPressed(_currentWindowContext, EKeyCodes::S))
|
|
|
|
{
|
2020-02-15 19:32:26 -08:00
|
|
|
ActionsToComplete.AddToQueue(MoveCamDelegate, EDirection::Backward, CamMoveSpeed, PhysicsDelta);
|
2020-02-14 23:21:27 -08:00
|
|
|
}
|
2020-02-17 18:10:15 -08:00
|
|
|
|
|
|
|
if (KeyPressed(_currentWindowContext, EKeyCodes::I))
|
|
|
|
{
|
|
|
|
ActionsToComplete.AddToQueue(RotateCamDelegate, ERotationAxis::Pitch, -6.0f * CamRotationSpeed, PhysicsDelta);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (KeyPressed(_currentWindowContext, EKeyCodes::K))
|
|
|
|
{
|
|
|
|
ActionsToComplete.AddToQueue(RotateCamDelegate, ERotationAxis::Pitch, 6.0f * CamRotationSpeed, PhysicsDelta);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (KeyPressed(_currentWindowContext, EKeyCodes::J))
|
|
|
|
{
|
|
|
|
ActionsToComplete.AddToQueue(RotateCamDelegate, ERotationAxis::Yaw, -6.0f * CamRotationSpeed, PhysicsDelta);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (KeyPressed(_currentWindowContext, EKeyCodes::L))
|
|
|
|
{
|
|
|
|
ActionsToComplete.AddToQueue(RotateCamDelegate, ERotationAxis::Yaw, 6.0f * CamRotationSpeed, PhysicsDelta);
|
|
|
|
}
|
2020-02-13 22:13:16 -08:00
|
|
|
}
|
|
|
|
|
2020-02-17 00:38:40 -08:00
|
|
|
|
|
|
|
std::string windowTitle = "Assignment 1", deltaStr = "Delta: ", inputDeltaStr = "Input Delta: ", physicsDeltaStr = "Physics Delta: ", renderDeltaStr = "RenderDeltaStr: ";
|
|
|
|
|
|
|
|
std::stringstream somethingtoupdate;
|
|
|
|
|
|
|
|
sfn UpdateThisShit()
|
|
|
|
{
|
|
|
|
somethingtoupdate.str("");
|
|
|
|
|
|
|
|
somethingtoupdate << windowTitle << " " << deltaStr << DeltaTime << " " << inputDeltaStr << InputDelta << " " << physicsDeltaStr << PhysicsDelta << " " << renderDeltaStr << RenderDelta;
|
|
|
|
}
|
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
sfn PhysicsProcedure()
|
2020-02-13 22:13:16 -08:00
|
|
|
{
|
2020-02-15 19:32:26 -08:00
|
|
|
WorldCamera.UpdateCamera();
|
2020-02-14 23:21:27 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
UpdateScreenspace();
|
2020-02-14 23:21:27 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
DGL::SS_Transformed::UpdateShader(Screenspace);
|
2020-02-14 23:21:27 -08:00
|
|
|
|
2020-02-16 22:28:24 -08:00
|
|
|
//RAW_RotateLitCube(PhysicsDelta);
|
|
|
|
|
2020-02-17 18:10:15 -08:00
|
|
|
RAW_LightRotate(PhysicsDelta);
|
|
|
|
|
2020-02-17 00:38:40 -08:00
|
|
|
ProperCube::Rotate(PhysicsDelta);
|
|
|
|
|
|
|
|
UpdateThisShit();
|
2020-02-16 22:28:24 -08:00
|
|
|
}
|
2020-02-17 00:38:40 -08:00
|
|
|
|
|
|
|
|
2020-02-14 23:21:27 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
sfn RenderProcedure() -> void
|
|
|
|
{
|
2020-02-17 00:38:40 -08:00
|
|
|
glfwSetWindowTitle(DefaultWindow, somethingtoupdate.str().c_str());
|
|
|
|
|
2020-02-16 22:28:24 -08:00
|
|
|
RAW_RenderLight(WorldCamera.Perspective, WorldCamera.Viewport);
|
|
|
|
|
2020-02-17 18:10:15 -08:00
|
|
|
ProperCube::Render(WorldCamera.Perspective, WorldCamera.Viewport, WorldCamera.Position);
|
2020-02-13 22:13:16 -08:00
|
|
|
}
|
2020-02-15 19:32:26 -08:00
|
|
|
|
2020-02-13 22:13:16 -08:00
|
|
|
|
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
// Runtime Execution: Default Execution
|
2020-02-13 22:13:16 -08:00
|
|
|
|
|
|
|
sfn Execute() -> ExitCode
|
|
|
|
{
|
2020-02-14 23:21:27 -08:00
|
|
|
PrepWorkspace();
|
2020-02-13 22:13:16 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
Cycler(InputProcedure, PhysicsProcedure, RenderProcedure);
|
2020-02-13 22:13:16 -08:00
|
|
|
|
2020-02-15 19:32:26 -08:00
|
|
|
TerminateGLFW();
|
2020-02-13 22:13:16 -08:00
|
|
|
|
|
|
|
return ExitCode::Success;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
return int(Execution::Execute());
|
|
|
|
}
|
|
|
|
|