diff --git a/Actions.hpp b/Actions.hpp new file mode 100644 index 0000000..c2ba08e --- /dev/null +++ b/Actions.hpp @@ -0,0 +1,119 @@ +/* +Title : Actions +Author: Edward R. Gonzalez + +Description: This was a little experiment of mine to mess with action binding... + +Allows for non-member functions to be binded to an action, implements a functioning queue as well. + +TODO: Possibly add support for member functions. Have it so that deduction of delegate typef is not required to add to queue properly (right now it does, see input procedure for example); +*/ + + +#pragma once + +#include "Cpp_Alias.hpp" + + + +namespace Actions +{ + struct IAction + { + virtual void DoAction() = NULL; + }; + + template + struct AAction : IAction + { + using ActionType = Delegate< FunctionType >; + + public: + AAction(ActionType _actionToAssign, ActionParams... _params) : + action(_actionToAssign), + params(_params...) + {}; + + private: + using IndexType = DataSize; + + void DoAction_Implementation(ActionParams... _params) { action(_params...); } + + template // TuplePackSequence + void ExpandTuple_CallDoActionImplementaiton(const Ref(Tuple) _paramsToExpand, std::index_sequence ) + { + // ExpandTuplePack + DoAction_Implementation(std::get (_paramsToExpand)...); + } + + Tuple params; + + ActionType action; + + public: // IAction + + virtual void DoAction() override + { + ExpandTuple_CallDoActionImplementaiton + ( + params, + // MakeTuplePackSequence () + std::index_sequence_for() + ); + }; + }; + + + struct ActionQueue + { + sfn HasAction() + { + return actionQueue.size() > 0; + } + + template + sfn AddToQueue(Delegate< FunctionType> _actionToQueue, ActionParams... _paramsForAction) + { + // This is extremely inefficient, but in order to fix requires an object pool or something else... + SPtr< AAction > ptrToAction = MakeSPtr< AAction >(_actionToQueue, _paramsForAction...); + + if (HasAction()) + { + bool found = false; + + using Element = decltype(actionQueue.begin()); + + for (Element element = actionQueue.begin(); element != actionQueue.end(); element++) + { + if ((*element).get() == ptrToAction.get()) + { + found = true; + } + } + + if (not found) + { + actionQueue.push_front(std::move(ptrToAction)); + } + } + else + { + actionQueue.push_front(std::move(ptrToAction)); + } + } + + sfn DoNextAction() + { + if (actionQueue.size() > 0) + { + actionQueue.back()->DoAction(); + + actionQueue.pop_back(); + } + } + + using QueueType = std::deque< SPtr>; + + QueueType actionQueue; + }; +} diff --git a/Cpp_Alias.hpp b/Cpp_Alias.hpp index 45c9ee8..c894a4f 100644 --- a/Cpp_Alias.hpp +++ b/Cpp_Alias.hpp @@ -12,19 +12,22 @@ This merely removes the need to use operators I don't like and wraps them in eas #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include @@ -43,12 +46,15 @@ _type& _type&& + // Aliases // Fundamental using uInt64 = unsigned long long int; + + // Pointers template @@ -63,12 +69,31 @@ using Delegate = std::function; template using Func = ReturnType(ParamTypes...); +template +using UPtr = std::unique_ptr; + +template +using SPtr = std::shared_ptr; + + + // Strings template using RawString = ptr; +using std::cout; +using std::endl; +using DataSize = std::size_t; + +using Thread = std::thread; + +template +using Tuple = std::tuple; + + + // Enum enum class ExitCode @@ -78,6 +103,7 @@ enum class ExitCode }; + // Functions // Ptr @@ -94,6 +120,19 @@ sfn Dref(ptr _type) -> Ref(Type) return *_type; } +template +sfn MakeUPtr(rRef(ParamTypes)... _params) -> UPtr +{ + return std::make_unique(_params...); +} + +template +sfn MakeSPtr(rRef(ParamTypes)... _params) -> SPtr +{ + return std::make_shared(_params...); +} + + // Exit diff --git a/DGL.hpp b/DGL.hpp index 6094660..408ba77 100644 --- a/DGL.hpp +++ b/DGL.hpp @@ -1,12 +1,12 @@ #pragma once -// GL -//#include -#include -#include -#include +// GLFW, GLEW, GLM +#include +#include +#include #include +// DGL #include "DGL_FundamentalTypes.hpp" #include "DGL_MiscTypes.hpp" #include "DGL_Enum.hpp" @@ -63,6 +63,11 @@ namespace DGL return glfwWindowShouldClose(_theWindow); } + sfn CanUseRawMouse() + { + return glfwRawMouseMotionSupported(); + } + sfn CreateWindow ( int _width, @@ -92,6 +97,11 @@ namespace DGL return Windows.back(); } + sfn CursorPositionUpdateBind(ptr _window, FnPtr _functionToCall) + { + glfwSetCursorPosCallback(_window, GLFWcursorposfun(_functionToCall)); + } + sfn DestoryWindow(const ptr _window) { using ElementType = decltype(Windows.begin()); @@ -109,16 +119,6 @@ namespace DGL return; } - sfn CanUseRawMouse() - { - return glfwRawMouseMotionSupported(); - } - - sfn CursorPositionUpdateBind(ptr _window, FnPtr _functionToCall) - { - glfwSetCursorPosCallback(_window, GLFWcursorposfun(_functionToCall)); - } - sfn DrawArrays(EPrimitives _primitive, gInt _startingIndex, gInt _numToRender) { glDrawArrays(GLenum(_primitive), _startingIndex, _numToRender); // Starting from vertex 0; 3 vertices total -> 1 triangle. @@ -129,15 +129,9 @@ namespace DGL glDrawElements(GLenum(_primitive), _numElements, GLenum(_dataType), _offfsetAddressFromFirstIndex); } - sfn KeyPressed(ptr _contextWindowRef, EKeyCodes _keyToCheck) -> bool + sfn GetCursorPosition(ptr _window, ptr _xAxis, ptr _yAxis) { - return glfwGetKey(_contextWindowRef, int(_keyToCheck)) ; - } - - template - sfn KeysPressed(ptr _contextWindowRef, CodeType... _otherKeys) -> bool - { - return ( KeyPressed(_contextWindowRef, _otherKeys) && ... ) == true; + glfwGetCursorPos(_window, _xAxis, _yAxis); } sfn GetMouseInputMode(ptr _contextWindowRef, EMouseMode _mode) @@ -145,27 +139,14 @@ namespace DGL return glfwGetInputMode(_contextWindowRef, GLenum(_mode)); } - sfn GetTime() -> TimeValDec - { - return glfwGetTime(); - } - sfn GetRawTime() -> TimeValInt { return glfwGetTimerValue(); } - sfn GetCursorPosition(ptr _window, ptr _xAxis, ptr _yAxis) + sfn GetTime() -> TimeValDec { - glfwGetCursorPos(_window, _xAxis, _yAxis); - } - - sfn ResetCursor(ptr _window, gFloat _screenCenterWidth, gFloat _screenCenterHeight) - { - glfwSetCursorPos(_window, _screenCenterWidth, _screenCenterHeight); - - - glfwSetCursorPos(_window, 0, 0); + return glfwGetTime(); } sfn InitalizeGLFW() @@ -219,6 +200,17 @@ namespace DGL } } + sfn KeyPressed(ptr _contextWindowRef, EKeyCodes _keyToCheck) -> bool + { + return glfwGetKey(_contextWindowRef, int(_keyToCheck)); + } + + template + sfn KeysPressed(ptr _contextWindowRef, CodeType... _otherKeys) -> bool + { + return (KeyPressed(_contextWindowRef, _otherKeys) && ...) == true; + } + sfn PollEvents() { glfwPollEvents(); @@ -226,6 +218,14 @@ namespace DGL return; } + sfn ResetCursor(ptr _window, gFloat _screenCenterWidth, gFloat _screenCenterHeight) + { + glfwSetCursorPos(_window, _screenCenterWidth, _screenCenterHeight); + + + glfwSetCursorPos(_window, 0, 0); + } + sfn RunBasicWindowLoop(const ptr _window) { /* Loop until the user closes the window */ @@ -279,17 +279,6 @@ namespace DGL { glClearColor(_colorToSet.Red, _colorToSet.Green, _colorToSet.Blue, _colorToSet.Alpha); } - - template - sfn SetInputMode(ptr _window, EMouseMode _mouseMode, ModeParam _modeParam) - { - glfwSetInputMode(_window, GLenum(_mouseMode), GLenum(_modeParam)); - } - - sfn RunTimingLoop() - { - return; - } sfn SetCurrentContext(const ptr _window) { @@ -316,6 +305,12 @@ namespace DGL return; } + template + sfn SetInputMode(ptr _window, EMouseMode _mouseMode, ModeParam _modeParam) + { + glfwSetInputMode(_window, GLenum(_mouseMode), GLenum(_modeParam)); + } + sfn SetPolygonMode(EFace _desiredFaces, ERenderMode _desiredMode) { glPolygonMode(GLenum(_desiredFaces), GLenum(_desiredMode)); diff --git a/DGL_Enum.hpp b/DGL_Enum.hpp index a305e9e..c02fcb7 100644 --- a/DGL_Enum.hpp +++ b/DGL_Enum.hpp @@ -12,33 +12,12 @@ namespace DGL X, Y, Z }; - enum class ERotationAxis - { - Pitch, Yaw, Roll - }; - enum class EBool { True = GL_TRUE , False = GL_FALSE }; - - enum class EMouseMode - { - Cursor = GLFW_CURSOR , - RawMouse = GLFW_RAW_MOUSE_MOTION , - StickyKeys = GLFW_STICKY_KEYS , - StickMouse = GLFW_STICKY_MOUSE_BUTTONS, - LockKey = GLFW_LOCK_KEY_MODS , - }; - - enum class ECursorMode - { - Normal = GLFW_CURSOR_NORMAL , - Hidden = GLFW_CURSOR_HIDDEN , - Disable = GLFW_CURSOR_DISABLED - }; - + enum class EBufferTarget { VertexAttributes = GL_ARRAY_BUFFER , @@ -78,6 +57,13 @@ namespace DGL None = GL_NONE }; + enum class ECursorMode + { + Normal = GLFW_CURSOR_NORMAL , + Hidden = GLFW_CURSOR_HIDDEN , + Disable = GLFW_CURSOR_DISABLED + }; + enum class EDataType { Byte = GL_BYTE , @@ -126,7 +112,8 @@ namespace DGL Q = GLFW_KEY_Q , S = GLFW_KEY_S , W = GLFW_KEY_W , - LeftShift = GLFW_KEY_LEFT_SHIFT + LeftShift = GLFW_KEY_LEFT_SHIFT, + Escape = GLFW_KEY_ESCAPE }; enum class EKeyState @@ -156,6 +143,15 @@ namespace DGL LinearToLinear = GL_LINEAR_MIPMAP_LINEAR }; + enum class EMouseMode + { + Cursor = GLFW_CURSOR , + RawMouse = GLFW_RAW_MOUSE_MOTION , + StickyKeys = GLFW_STICKY_KEYS , + StickMouse = GLFW_STICKY_MOUSE_BUTTONS, + LockKey = GLFW_LOCK_KEY_MODS , + }; + enum class ERenderMode { Point = GL_POINT, @@ -163,8 +159,11 @@ namespace DGL Fill = GL_FILL }; + enum class ERotationAxis + { + Pitch, Yaw, Roll + }; - enum class EPrimitives { Points = GL_POINTS, diff --git a/DGL_MiscTypes.hpp b/DGL_MiscTypes.hpp index 1471d2e..c244b19 100644 --- a/DGL_MiscTypes.hpp +++ b/DGL_MiscTypes.hpp @@ -1,7 +1,7 @@ #pragma once // OpenGL -#include +#include #include @@ -37,11 +37,11 @@ namespace DGL // ID Reference Types - class Buffer; - class Matrix; - class Shader; + class Buffer ; + class Matrix ; + class Shader ; class ShaderProgram; - class VertexBuffer; + class VertexBuffer ; class ElementBuffer; using Matrix4x4 = glm::mat4; diff --git a/DGL_Primitive.hpp b/DGL_Primitive.hpp index 52e93f0..f9e9a2d 100644 --- a/DGL_Primitive.hpp +++ b/DGL_Primitive.hpp @@ -4,7 +4,6 @@ - namespace DGL { diff --git a/DGL_Shader.hpp b/DGL_Shader.hpp index a756c96..1d462d1 100644 --- a/DGL_Shader.hpp +++ b/DGL_Shader.hpp @@ -36,19 +36,17 @@ namespace DGL // Default Shaders - ID RawShader , - SimpleShader , - SimpleShader_Transformed ; - - ID ScreenSpaceVarID; + ID RawShader , + SimpleShader ; + // Forward Declarations - sfn GetShaderInfo ( ID _shader , gSize _logLength , ptr _infoLengthRef , RawString _infoLogRef) -> void; - sfn QueryShader ( ID _shaderToQuery , EShaderInfo _shaderInfoDesired, ptr _requestedInfoObject ) -> void; - sfn MakeShader (Ref(ID) _shaderIDHolder , EShaderType _typeOfShader , uInt64 _numberOfStringElements, ptr> _sourceCode, ptr _lengthsOfStrings) -> void; - sfn MakeShaderProgram(Ref(ID) _shaderProgramIDHolder, const ID _vertexShader, const ID _fragShader) -> void; + sfn GetShaderInfo ( ID _shader , gSize _logLength , ptr _infoLengthRef , RawString _infoLogRef ) -> void; + sfn QueryShader ( ID _shaderToQuery , EShaderInfo _shaderInfoDesired, ptr _requestedInfoObject ) -> void; + sfn MakeShader (Ref(ID) _shaderIDHolder , EShaderType _typeOfShader , uInt64 _numberOfStringElements , ptr> _sourceCode, ptr _lengthsOfStrings) -> void; + sfn MakeShaderProgram(Ref(ID) _shaderProgramIDHolder, const ID _vertexShader , const ID _fragShader ) -> void; @@ -60,7 +58,7 @@ namespace DGL glGetProgramiv(_shaderToQueryForUniforms, GL_ACTIVE_UNIFORMS, &uniforms); - for (int i = 0; i < uniforms; i++) + for (int uniformIndex = 0; uniformIndex < uniforms; uniformIndex++) { int name_len = -1, num = -1; @@ -68,7 +66,7 @@ namespace DGL char name[100]; - glGetActiveUniform(_shaderToQueryForUniforms, GLuint(i), sizeof(name) - 1, &name_len, &num, &type, name); + glGetActiveUniform(_shaderToQueryForUniforms, GLuint(uniformIndex), sizeof(name) - 1, &name_len, &num, &type, name); name[name_len] = 0; } @@ -264,47 +262,6 @@ namespace DGL } } - sfn LoadRawShader() - { - ID VertexShader ; - ID FragmentShader; - - MakeShader(VertexShader , EShaderType::Vertex , 1, Address(DGL::RawVertextShaderSource ), NULL); - MakeShader(FragmentShader, EShaderType::Fragment, 1, Address(DGL::RawFragmentShaderSource), NULL); - - DGL::MakeShaderProgram(RawShader, VertexShader, FragmentShader); - - DGL::DeleteShader(VertexShader ); - DGL::DeleteShader(FragmentShader); - - return; - } - - sfn LoadSimpleShader() - { - SimpleShader = LoadShaders("SimpleVertexShader.vert", "SimpleFragmentShader.frag"); - - return; - } - - sfn LoadSimpleShader_Transformed() - { - SimpleShader_Transformed = LoadShaders("SimpleTransform.vert", "SingleColor.frag"); - - ScreenSpaceVarID = DGL::GetUniformVariable(DGL::SimpleShader_Transformed, "modelViewProjection"); - - return; - } - - sfn LoadDefaultShaders() - { - LoadRawShader (); - LoadSimpleShader (); - LoadSimpleShader_Transformed(); - - return; - } - sfn MakeShader ( Ref(ID) _shaderIDHolder , @@ -363,7 +320,8 @@ namespace DGL return; } - sfn SetUniformVariable_MatrixVariableArray(const ID _matrixID, const gSize _numMatricies, const EBool _shouldTransposeValues, ptr _dataPtr) + // MVA: MatrixVariableArray + sfn SetUniformVariable_MVA(const ID _matrixID, const gSize _numMatricies, const EBool _shouldTransposeValues, ptr _dataPtr) { glUniformMatrix4fv(_matrixID, _numMatricies, GLenum(_shouldTransposeValues), _dataPtr); @@ -376,4 +334,60 @@ namespace DGL return; } + + + namespace SS_Transformed + { + ID Shader; + + ID ScreenSpaceVarID; + + sfn UpdateShader(Ref(CoordSpace) _screenSpace) + { + SetUniformVariable_MVA(ScreenSpaceVarID, 1, DGL::EBool::False, Address(_screenSpace[0][0])); + + return; + } + + sfn LoadShader() + { + Shader = LoadShaders("SimpleTransform.vert", "SingleColor.frag"); + + ScreenSpaceVarID = DGL::GetUniformVariable(Shader, "ScreenSpaceTransform"); + + return; + } + } + + sfn LoadRawShader() + { + ID VertexShader; + ID FragmentShader; + + MakeShader(VertexShader, EShaderType::Vertex, 1, Address(DGL::RawVertextShaderSource), NULL); + MakeShader(FragmentShader, EShaderType::Fragment, 1, Address(DGL::RawFragmentShaderSource), NULL); + + MakeShaderProgram(RawShader, VertexShader, FragmentShader); + + DeleteShader(VertexShader); + DeleteShader(FragmentShader); + + return; + } + + sfn LoadSimpleShader() + { + SimpleShader = LoadShaders("SimpleVertexShader.vert", "SimpleFragmentShader.frag"); + + return; + } + + sfn LoadDefaultShaders() + { + LoadRawShader (); + LoadSimpleShader(); + SS_Transformed::LoadShader (); + + return; + } } diff --git a/DGL_Space.hpp b/DGL_Space.hpp index 244b5dc..859868a 100644 --- a/DGL_Space.hpp +++ b/DGL_Space.hpp @@ -1,6 +1,11 @@ #pragma once +// GLM +#include +#include +#include +// DGL #include "DGL_FundamentalTypes.hpp" #include "DGL_MiscTypes.hpp" @@ -45,9 +50,14 @@ namespace DGL return glm::perspective(_fieldOfView, _aspectRatio, _nearPlane, _farPlane); } - sfn Translate(const Matrix4x4 _matrix, Vector3 _translationAmount) + sfn GetCrossNormal(Vector3 _subj, Vector3 _ref) -> Vector3 { - return glm::translate(_matrix, _translationAmount); + return glm::cross(_subj, _ref); + } + + sfn GetDirection(Vector3 _vectorSpecified) + { + return glm::normalize(_vectorSpecified); } sfn Rotate(const Matrix4x4 _matrix, gFloat _rotationAngleAmount, Vector3 _axis) -> Matrix4x4 @@ -61,14 +71,9 @@ namespace DGL return glm::radians(_degrees); } - sfn GetCrossNormal(Vector3 _subj, Vector3 _ref) -> Vector3 + sfn Translate(const Matrix4x4 _matrix, Vector3 _translationAmount) { - return glm::cross(_subj, _ref); - } - - sfn GetDirection(Vector3 _vectorSpecified) - { - return glm::normalize(_vectorSpecified); + return glm::translate(_matrix, _translationAmount); } @@ -97,8 +102,6 @@ namespace DGL gFloat ScreenWidth = 720.0f, ScreenHeight = 540.0f, ScreenCenterWidth = ScreenWidth / 2, ScreenCenterHeight = ScreenHeight / 2; } - using std::cout; using std::endl; - struct Camera { gFloat AspectRatio, FieldOfView, Yaw, Pitch, Roll; @@ -130,16 +133,10 @@ namespace DGL UpDirection (_upDirection ), FrontDirection(_frontDirection) { - std::cout << UpDirection.x << ", " << UpDirection.y << ", " << UpDirection.z << std::endl; - Yaw = -90.0f; Pitch = 0; Roll = 0; - //Yaw = 0; - UpdateCamera(); - std::cout << UpDirection.x << ", " << UpDirection.y << ", " << UpDirection.z << std::endl; - Orthographic = CreateOrthographic(0.0f, DefaultSpace::ScreenWidth, 0.0f, DefaultSpace::ScreenHeight, ClipSpace.Near, ClipSpace.Far); Perspective = CreatePerspective(ToRadians(FieldOfView), AspectRatio, ClipSpace.Near, ClipSpace.Far); @@ -152,49 +149,37 @@ namespace DGL { case EDirection::Up: { - Position += UpDirection * _translationAmount * _deltaTime; - - LookAtPosition += UpDirection * _translationAmount * _deltaTime; + Position -= UpDirection * _translationAmount * _deltaTime; break; } case EDirection::Down: { - Position -= UpDirection * _translationAmount * _deltaTime; - - LookAtPosition -= UpDirection * _translationAmount * _deltaTime; + Position += UpDirection * _translationAmount * _deltaTime; break; } case EDirection::Left: { - Position += GetDirection(GetCrossNormal(FrontDirection, UpDirection)) * _translationAmount * _deltaTime; - - //LookAtPosition += GetDirection(GetCrossNormal(FrontDirection, UpDirection)) * _translationAmount * _deltaTime; + Position -= GetDirection(GetCrossNormal(FrontDirection, UpDirection)) * _translationAmount * _deltaTime; break; } case EDirection::Right: { - Position -= GetDirection(GetCrossNormal(FrontDirection, UpDirection)) * _translationAmount * _deltaTime; - - //LookAtPosition -= GetDirection(GetCrossNormal(FrontDirection, UpDirection)) * _translationAmount * _deltaTime; + Position += GetDirection(GetCrossNormal(FrontDirection, UpDirection)) * _translationAmount * _deltaTime; break; } case EDirection::Forward: { - Position -= FrontDirection * _translationAmount * _deltaTime; - - LookAtPosition -= FrontDirection * _translationAmount * _deltaTime; + Position += FrontDirection * _translationAmount * _deltaTime; break; } case EDirection::Backward: { - Position += FrontDirection * _translationAmount * _deltaTime; - - LookAtPosition += FrontDirection * _translationAmount * _deltaTime; + Position -= FrontDirection * _translationAmount * _deltaTime; break; } @@ -203,11 +188,15 @@ namespace DGL throw std::logic_error("Direction move not defined."); } } + + return; } sfn Move(Vector3 _translationAmount, Ref(gFloat) _deltaTime) { Position += _translationAmount * _deltaTime; + + return; } sfn Rotate(ERotationAxis _pivot, gFloat _rotationAmount, gFloat _deltaTime) @@ -227,8 +216,6 @@ namespace DGL Pitch = -89.9f; } - //std::cout << "Pitch: " << Pitch << std::endl; - break; } case ERotationAxis::Roll: @@ -250,34 +237,16 @@ namespace DGL { Yaw += _rotationAmount * _deltaTime; - /*if (Yaw > 89.9f) - { - Yaw = 89.9f; - } - else if (Yaw < -89.9f) - { - Pitch = -89.9f; - }*/ - - //std::cout << "Yaw: " << Yaw << std::endl; - break; } } - - /*std::cout << "Front Direction: " << FrontDirection.x << ", " << FrontDirection.y << ", " << FrontDirection.z << std::endl; - std::cout << "Right Direction: " << RightDirection.x << ", " << RightDirection.y << ", " << RightDirection.z << std::endl; - std::cout << "Up Direction: " << UpDirection.x << ", " << UpDirection.y << ", " << UpDirection.z << std::endl;*/ + return; } sfn UpdateCamera() -> void { - //cout << Pitch << Yaw << Roll << endl; - - //cout << "Cosine: " << Cosine(ToRadians(Yaw)) << endl; - FrontDirection.x = Cosine(ToRadians(Yaw )) * Cosine(ToRadians(Pitch)); FrontDirection.y = Sine (ToRadians(Pitch)) ; FrontDirection.z = Sine (ToRadians(Yaw )) * Cosine(ToRadians(Pitch)); @@ -286,19 +255,11 @@ namespace DGL RightDirection = GetDirection(GetCrossNormal(FrontDirection, DefaultSpace::UpDirection )); UpDirection = GetDirection(GetCrossNormal(RightDirection, FrontDirection)); - //Matrix4x4 mRoll = glm::rotate(mRoll , Roll , DefaultSpace::FrontDirection); - //Matrix4x4 mPitch = glm::rotate(mPitch, Pitch, DefaultSpace::RightDirection); - //Matrix4x4 mYaw = glm::rotate(mYaw , Roll , DefaultSpace::UpDirection ); + LookAtPosition = Position + FrontDirection; - //Matrix4x4 rotation = mPitch * mYaw; + Viewport = CreateLookAtView(Position, LookAtPosition, UpDirection); - Viewport = CreateLookAtView(Position, LookAtPosition - FrontDirection, UpDirection); - - //glm::mat4 translate = glm::mat4(1.0f); - - //translate = glm::translate(translate, -LookAtPosition); - - //Viewport = rotation * translate; + return; } }; @@ -321,9 +282,9 @@ namespace DGL sfn UpdateScreenspace() { - //Screenspace = WorldCamera.Perspective * WorldCamera.Viewport * WorldSpace; + Screenspace = WorldCamera.Perspective * WorldCamera.Viewport * WorldSpace; + + return; } } - - } \ No newline at end of file diff --git a/Execution.cpp b/Execution.cpp index 78fd468..3412366 100644 --- a/Execution.cpp +++ b/Execution.cpp @@ -2,225 +2,212 @@ // Project #include "DGL.hpp" -#include "TriangleRaw.hpp" +#include "Actions.hpp" +#include "Testing.hpp" #include "Cpp_Alias.hpp" -#include -#include -#include - namespace Execution { - // C++ STL + inline namespace Alias + { + // DGL - using std::thread; + 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 ; + 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; + } + // Globals + + bool Exist = true; // Determines if the the execution should exit cycler. + + TimeValDec CycleStart , // Snapshot of cycle loop start time. + CycleEnd , // Snapshot of cycle loop end time. + DeltaTime , // Delta between last cycle start and end. + InputInterval = 1.0f / 240.0f, // Interval per second to complete the input process of the cycle. + PhysicsInterval = 1.0f / 120.0f, // Interval per second to complete the physics process of hte cycle. + RenderInterval = 1.0f / 60.0f ; // Interval per second to complete the render process of the cycle. + + ptr DefaultWindow; // Default window to use for execution. + + double CursorX, CursorY; // Cursor axis position on the window. + + gFloat CamMoveSpeed = 8.0f, // Rate at which the camera should move. + CamRotationSpeed = 5.0f ; // Rate at which the camera should rotate. + + 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. + + ActionQueue ActionsToComplete; // Actions queue to run during the physics process of the cycle. + + + + // Functionality + + // Temp fix for now... not sure how to make proper action handling that can reference member function delegates... + + sfn RotateCamera(ERotationAxis _rotationAxis, gFloat _rotationAmount, gFloat _delta) + { + WorldCamera.Rotate(_rotationAxis, _rotationAmount, _delta); + } - template - using UPtr = std::unique_ptr; + deduce RotateCamDelegate = Delegate(RotateCamera); - template - sfn MakeUPtr(rRef(ParamTypes)... _params) -> UPtr + sfn MoveCamera(EDirection _direction, gFloat _translationAmount, gFloat _delta) { - return std::make_unique(_params...); - } + WorldCamera.Move(_direction, _translationAmount, _delta); + } + + deduce MoveCamDelegate = Delegate(MoveCamera); + + // End of temp stuff... - // GL - - using DGL::TimeValDec; - using DGL::Window ; - using DGL::Matrix ; - using DGL::Matrix4x4 ; - using DGL::Vector3 ; - using DGL::gFloat ; - - - bool Exist = true; - - TimeValDec CycleStart, CycleEnd, DeltaTime, InputPollingInterval = 1.0f / 240.0f, PhysicsInterval = 1.0f / 120.0f, RenderInterval = 1.0f / 60.0f; - - UPtr BasicLoop, BasicTimedLoop; - - ptr DefaultWindow; - - - gFloat CamMoveSpeed = 3.0f, CamRotationSpeed = 1.0f; - - - - enum class CameraActions + // Currently Does everything required before entering the cycler. + sfn PrepWorkspace() { + InitalizeGLFW(); - }; + DefaultWindow = CreateWindow(ScreenWidth, ScreenHeight, "Assignment 1: Lighting Test", WindowedMode(), NotShared()); - enum class EMovement - { + SetCurrentContext(DefaultWindow); - }; + InitalizeGLEW(); // Glew must initialize only after a context is set. + // Cursor stuff + SetInputMode(DefaultWindow, DGL::EMouseMode::Cursor, DGL::ECursorMode::Disable); - template - struct ActionBind - { + ResetCursor(DefaultWindow, ScreenCenterWidth, ScreenCenterHeight); + if (CanUseRawMouse()) + { + SetInputMode(DefaultWindow, DGL::EMouseMode::RawMouse, DGL::EBool::True); + } - Delegate< Func> Action; - }; - - - - struct Keyboard - { - - }; - - struct ActionBinds - { - static ActionBind MoveFoward; - }; - - - - // Testing - - // Forward Declares - - sfn RenderProcedure () -> void; - sfn PrepareRenderObjects() -> void; - - sfn CreateWindow_BasicLoop() - { - DGL::InitalizeGLFW(); - - deduce windowObj = DGL::CreateWindow(720, 540, "Assignment 1: RawLoop", DGL::WindowedMode(), DGL::NotShared()); - - DGL::SetCurrentContext(windowObj); - - DGL::RunBasicWindowLoop(windowObj); - } - - sfn CreateWindow_TimedRender() - { - DGL::InitalizeGLFW(); - - deduce windowObj = DGL::CreateWindow(720, 540, "Assignment 1: Timed Render", DGL::WindowedMode(), DGL::NotShared()); - - DGL::SetCurrentContext(windowObj); - - DGL::InitalizeGLEW(); + // End of cursor stuff... PrepareRenderObjects(); - DGL::RunBasicWindowLoop_Timed(windowObj, 1.0 / 60.0, Address(RenderProcedure)); + SetPolygonMode(DGL::EFace::Front_and_Back, DGL::ERenderMode::Fill); } - sfn PrepareRenderObjects() -> void - { - RAW_SetupBuffers(); - - RAW_BindAndBufferDataToIDs(); - - DGL::LoadDefaultShaders(); - - DGL::FormatVertexAttributes(VertexAttributeIndex, EDataType::Float, ZeroOffset(), Vertex3::ValueCount(), EBool::False); - - DGL::BindBuffer(EBufferTarget::VertexAttributes, 0); // Dunno. Prob unbinding... - - DGL::BindVertexArray(0); - } - - using DGL::EFrameBuffer; - using DGL::LinearColor; - using DGL::DefaultSpace::WorldCamera; - - using std::cout; using std::endl; - - using DGL::KeyPressed; - using DGL::EKeyCodes; - - using DGL::DefaultSpace::WorldCamera; - using DGL::EDirection; - struct CamShouldMove - { - bool Up, Down, Left, Right, Forward, Backward; + /* + Cycles the process of what to do while a window is open. - short int numActive; - }; + The input, physics, and render procedures can be specified with extra functionality by specifying delegates to those procedures. - CamShouldMove CamMoveRequests = { false, false, false, false, false, false, 0 }; - - double CursorX, CursorY; - - using DGL::DefaultSpace::ScreenCenterWidth; using DGL::DefaultSpace::ScreenCenterHeight; - - - TimeValDec InputDelta = 0.0, PhysicsDelta = 0.0, RenderDelta = 0.0; - - using DGL::DefaultSpace::Screenspace; - - sfn Cycler(Delegate< Func> > _inputProcedure, Delegate< Func> _renderProcedure) + Cycler is hardcoded to exit if escape key is pressed. + */ + sfn Cycler(Delegate< Func> > _inputProcedure, Delegate< Func> _physicsProcedure, Delegate< Func> _renderProcedure) { while (Exist) { - CycleStart = DGL::GetTime(); + CycleStart = GetTime(); - if (InputDelta >= InputPollingInterval) + if (InputDelta >= InputInterval) { - DGL::PollEvents(); + PollEvents(); - glfwGetCursorPos(DefaultWindow, Address(CursorX), Address(CursorY)); + if (KeyPressed(DefaultWindow, EKeyCodes::Escape)) + { + Exist = false; + } + + GetCursorPosition(DefaultWindow, Address(CursorX), Address(CursorY)); _inputProcedure(DefaultWindow); - DGL::ResetCursor(DefaultWindow, ScreenCenterWidth, ScreenCenterHeight); + ResetCursor(DefaultWindow, ScreenCenterWidth, ScreenCenterHeight); InputDelta = 0.0; } if (PhysicsDelta >= PhysicsInterval) { - if (CamMoveRequests.Up ) WorldCamera.Move(EDirection::Up , CamMoveSpeed / CamMoveRequests.numActive, PhysicsDelta); - if (CamMoveRequests.Down ) WorldCamera.Move(EDirection::Down , CamMoveSpeed / CamMoveRequests.numActive, PhysicsDelta); - if (CamMoveRequests.Left ) WorldCamera.Move(EDirection::Left , CamMoveSpeed / CamMoveRequests.numActive, PhysicsDelta); - if (CamMoveRequests.Right ) WorldCamera.Move(EDirection::Right , CamMoveSpeed / CamMoveRequests.numActive, PhysicsDelta); - if (CamMoveRequests.Forward ) WorldCamera.Move(EDirection::Forward , CamMoveSpeed / CamMoveRequests.numActive, PhysicsDelta); - if (CamMoveRequests.Backward) WorldCamera.Move(EDirection::Backward, CamMoveSpeed / CamMoveRequests.numActive, PhysicsDelta); + while (ActionsToComplete.HasAction()) + { + ActionsToComplete.DoNextAction(); + } - WorldCamera.UpdateCamera(); - - //WorldCamera.Position.y = 0.0; - //WorldCamera.LookAtPosition.y = 0.0; - - DGL::DefaultSpace::UpdateScreenspace(); - - CamMoveRequests = { false, false, false, false, false, false, 0 }; + _physicsProcedure(); PhysicsDelta = 0.0; } if (RenderDelta >= RenderInterval) { - DGL::ClearBuffer(EFrameBuffer::Color, EFrameBuffer::Depth); + ClearBuffer(EFrameBuffer::Color, EFrameBuffer::Depth); - DGL::SetClearColor(LinearColor(0.12f, 0.12f, 0.12f, 1.0f)); + SetClearColor(LinearColor(0.12f, 0.12f, 0.12f, 1.0f)); _renderProcedure(); - DGL::SwapBuffers(DefaultWindow); + SwapBuffers(DefaultWindow); RenderDelta = 0.0; } - CycleEnd = DGL::GetTime(); + CycleEnd = GetTime(); DeltaTime = CycleEnd - CycleStart; @@ -232,9 +219,7 @@ namespace Execution return; } - using DGL::EMouseMode; using DGL::ECursorMode; - using DGL::DefaultSpace::ScreenCenterWidth; using DGL::DefaultSpace::ScreenCenterHeight; sfn InputProcedure(ptr _currentWindowContext) { @@ -242,145 +227,96 @@ namespace Execution { ECursorMode cursorMode = ECursorMode(GetMouseInputMode(DefaultWindow, EMouseMode::Cursor)); + deduce delegate = Delegate)>(SetInputMode); + if (cursorMode == ECursorMode::Normal || cursorMode == ECursorMode::Hidden) { - SetInputMode(_currentWindowContext, EMouseMode::Cursor, ECursorMode::Disable); + ActionsToComplete.AddToQueue(delegate, _currentWindowContext, EMouseMode::Cursor, ECursorMode::Disable); } else { - SetInputMode(_currentWindowContext, EMouseMode::Cursor, ECursorMode::Normal); + ActionsToComplete.AddToQueue(delegate, _currentWindowContext, EMouseMode::Cursor, ECursorMode::Normal); } } - if (CursorX != 0)//!= ScreenCenterWidth) + if (CursorX != 0) { - WorldCamera.Rotate(DGL::ERotationAxis::Yaw, CursorX * CamMoveSpeed, InputDelta); - - //cout << "Cursor X: " << CursorX << endl; + ActionsToComplete.AddToQueue(RotateCamDelegate, ERotationAxis::Yaw, CursorX * CamMoveSpeed, PhysicsDelta); } if (CursorY != 0) { - WorldCamera.Rotate(DGL::ERotationAxis::Pitch, CursorY * CamMoveSpeed, InputDelta); - - //cout << "Cursor Y: " << CursorX << endl; + ActionsToComplete.AddToQueue(RotateCamDelegate, ERotationAxis::Pitch, CursorY * CamMoveSpeed, PhysicsDelta); } if (KeyPressed(_currentWindowContext, EKeyCodes::E)) { - WorldCamera.Move(EDirection::Up, CamMoveSpeed, InputDelta); - - CamMoveRequests.Up = true; - - CamMoveRequests.numActive++; + ActionsToComplete.AddToQueue(MoveCamDelegate, EDirection::Up, CamMoveSpeed, PhysicsDelta); } if (KeyPressed(_currentWindowContext, EKeyCodes::Q)) { - WorldCamera.Move(EDirection::Down, CamMoveSpeed, InputDelta); - - CamMoveRequests.Down = true; - - CamMoveRequests.numActive++; + ActionsToComplete.AddToQueue(MoveCamDelegate, EDirection::Down, CamMoveSpeed, PhysicsDelta); } if (KeyPressed(_currentWindowContext, EKeyCodes::A)) { - WorldCamera.Move(EDirection::Left, CamMoveSpeed, InputDelta); - - CamMoveRequests.Left = true; - - CamMoveRequests.numActive++; + ActionsToComplete.AddToQueue(MoveCamDelegate, EDirection::Left, CamMoveSpeed, PhysicsDelta); } if (KeyPressed(_currentWindowContext, EKeyCodes::D)) { - WorldCamera.Move(EDirection::Right, CamMoveSpeed, InputDelta); - - CamMoveRequests.Right = true; - - CamMoveRequests.numActive++; + ActionsToComplete.AddToQueue(MoveCamDelegate, EDirection::Right, CamMoveSpeed, PhysicsDelta); } if (KeyPressed(_currentWindowContext, EKeyCodes::W)) { - WorldCamera.Move(EDirection::Forward, CamMoveSpeed, InputDelta); - - CamMoveRequests.Forward = true; - - CamMoveRequests.numActive++; + ActionsToComplete.AddToQueue(MoveCamDelegate, EDirection::Forward, CamMoveSpeed, PhysicsDelta); } if (KeyPressed(_currentWindowContext, EKeyCodes::S)) { - WorldCamera.Move(EDirection::Backward, CamMoveSpeed, InputDelta); - - CamMoveRequests.Backward = true; - - CamMoveRequests.numActive++; + ActionsToComplete.AddToQueue(MoveCamDelegate, EDirection::Backward, CamMoveSpeed, PhysicsDelta); } } + + + sfn PhysicsProcedure() + { + WorldCamera.UpdateCamera(); + + UpdateScreenspace(); + + DGL::SS_Transformed::UpdateShader(Screenspace); + } + + + sfn RenderProcedure() -> void { - DGL::EnableVertexAttributeArray(VertexAttributeIndex); + EnableVertexAttributeArray(VertexAttributeIndex); - DGL::SetPolygonMode(DGL::EFace::Front_and_Back, DGL::ERenderMode::Line); + UseProgramShader(DGL::SS_Transformed::Shader); - DGL::DefaultSpace::WorldSpace = DGL::Rotate(DGL::DefaultSpace::WorldSpace, 0.0035f, Vector3(0.0f, 0.5f, 0.0f)); + BindVertexArray(VertexArrayObj); - DGL::DefaultSpace::Screenspace = DGL::DefaultSpace::WorldCamera.Perspective * DGL::DefaultSpace::WorldCamera.Viewport * DGL::DefaultSpace::WorldSpace; + DrawElements(EPrimitives::Triangles, 6, EDataType::UnsignedInt, ZeroOffset()); - DGL::UseProgramShader(DGL::SimpleShader_Transformed); - - DGL::SetUniformVariable_MatrixVariableArray(DGL::ScreenSpaceVarID, 1, DGL::EBool::False, Address(DGL::DefaultSpace::Screenspace[0][0])); - - DGL::BindVertexArray(VertexArrayObj); - - DGL::DrawArrays(DGL::EPrimitives::Triangles, 0, TriangleRaw::VertexCount()); - - DGL::DrawElements(DGL::EPrimitives::Triangles, 6, EDataType::UnsignedInt, ZeroOffset()); - - //GL::BindVertexArray(0); - - DGL::DisableVertexAttributeArray(VertexAttributeIndex); - } - - sfn PrepWorkspace() - { - using DGL::DefaultSpace::ScreenWidth ; - using DGL::DefaultSpace::ScreenHeight; - - DGL::InitalizeGLFW(); - - DefaultWindow = DGL::CreateWindow(ScreenWidth, ScreenHeight, "Assignment 1: Cam Movement Test", DGL::WindowedMode(), DGL::NotShared()); - - DGL::SetCurrentContext(DefaultWindow); - - DGL::SetInputMode(DefaultWindow, DGL::EMouseMode::Cursor, DGL::ECursorMode::Disable); - - DGL::ResetCursor(DefaultWindow, ScreenCenterWidth, ScreenCenterHeight); - - if (DGL::CanUseRawMouse()) - { - DGL::SetInputMode(DefaultWindow, DGL::EMouseMode::RawMouse, DGL::EBool::True); - } - - DGL::InitalizeGLEW(); - - PrepareRenderObjects(); + DisableVertexAttributeArray(VertexAttributeIndex); } + - // Runtime Execution: Loop must be specified here to use. + // Runtime Execution: Default Execution sfn Execute() -> ExitCode { PrepWorkspace(); - Cycler(InputProcedure, RenderProcedure); + Cycler(InputProcedure, PhysicsProcedure, RenderProcedure); - DGL::TerminateGLFW(); + TerminateGLFW(); return ExitCode::Success; } diff --git a/SimpleTransform.vert b/SimpleTransform.vert index b8d2f73..4f6dc73 100644 --- a/SimpleTransform.vert +++ b/SimpleTransform.vert @@ -5,11 +5,11 @@ layout (location = 0) in vec3 aPos; // uniform mat4 view; // uniform mat4 projection; -uniform mat4 modelViewProjection; +uniform mat4 ScreenSpaceTransform; void main() { //gl_Position = projection * view * model * vec4(aPos, 1.0); - gl_Position = modelViewProjection * vec4(aPos, 1.0); + gl_Position = ScreenSpaceTransform * vec4(aPos, 1.0); } \ No newline at end of file diff --git a/Testing.hpp b/Testing.hpp new file mode 100644 index 0000000..d5124b4 --- /dev/null +++ b/Testing.hpp @@ -0,0 +1,212 @@ +#pragma once + +#include "DGL.hpp" + +#include "Cpp_Alias.hpp" + + + +using DGL::gFloat; +using DGL::VertexBuffer; +using DGL::EBufferTarget; +using DGL::EBufferUsage; +using DGL::Buffer; +using DGL::ID; +using DGL::gInt; +using DGL::gSize; + + + +//DGL::DefaultSpace::WorldSpace = DGL::Rotate(DGL::DefaultSpace::WorldSpace, 0.015f, Vector3(0.0f, 1.0f, 0.0f)); + +// This will identify our vertex buffer +ID VertexBufferObj; + +struct Vertex3 +{ + gFloat x, y, z; + + static constexpr sfn ValueCount() -> gSize { return 3; } +}; + +struct TriangleRaw +{ + Vertex3 a, b, c; + + static constexpr sfn VertexCount() -> gSize { return 3; } +}; + + +TriangleRaw EquilateralTriangleVerticies = +{ + { -1.0f, -1.0f, 0.0f }, // Vert1 + { 1.0f, -1.0f, 0.0f }, // Vert2 + { 0.0f, 1.0f, 0.0f } // Vert 3 +}; + + +struct RectangleRaw +{ + TriangleRaw first, second; + + static constexpr sfn VertexCount() -> gSize { return 6; } +}; + + +RectangleRaw SquareVerticies = +{ + { + { -0.5f, -0.5f, 0.0f }, + { 0.5f, -0.5f, 0.0f }, + { 0.0f, 0.5f, 0.0f } + }, + { + { 0.5f, -0.5f, 0.0f }, + { -0.5f, -0.5f, 0.0f }, + { -0.5f, 0.5f, 0.0f } + } +}; + +ID VertexArrayObj; + +struct RectangleCompressed +{ + Vertex3 a, b, c, d; + + static constexpr sfn VertexCount() -> gSize { return 4; } +}; + +struct TriIndex +{ + gInt a, b, c; +}; + +struct RectangleIndices +{ + TriIndex first, second; +}; + + +RectangleCompressed rectCompress = +{ + { 1.0f, 1.0f, 0.0f }, + { 1.0f, -1.0f, 0.0f }, + { -1.0f, -1.0f, 0.0f }, + { -1.0f, 1.0f, 0.0f } +}; + +RectangleIndices rectIndices = +{ + { 0, 1, 3 }, + { 1, 2, 3 } +}; + +using DGL::ElementBuffer; + +ID ElemBufferObj; + +struct Vertex2 +{ + gFloat x, y; +}; + +struct TriTexCoords +{ + Vertex2 a, b, c; +}; + + +TriTexCoords textureCoords = +{ + { 0.0f, 0.0f }, + { 1.0f, 0.0f }, + { 0.5f, 1.0f } +}; + + +sfn RAW_SetupBuffers() +{ + DGL::GenerateVertexBuffers(Address(VertexArrayObj ), 1); + DGL::GenerateBuffers (Address(VertexBufferObj), 1); + DGL::GenerateBuffers (Address(ElemBufferObj ), 1); +} + +sfn RAW_SetupTriangleBuffer() +{ + DGL::GenerateBuffers(Address(VertexBufferObj), 1); +} + +sfn RAW_BindAndBufferDataToIDs() +{ + DGL::BindVertexArray(VertexArrayObj); + + DGL::BindBuffer(EBufferTarget::VertexAttributes, VertexBufferObj); + + //GL::BufferData(Address(EquilateralTriangleVerticies), EBufferTarget::VertexAttributes, EBufferUsage::StaticDraw); + + DGL::BufferData(Address(rectCompress), EBufferTarget::VertexAttributes, EBufferUsage::StaticDraw); + + DGL::BindBuffer(EBufferTarget::VertexIndices, ElemBufferObj); + + DGL::BufferData(Address(rectIndices), EBufferTarget::VertexIndices, EBufferUsage::StaticDraw); +} + +DGL::gInt VertexAttributeIndex = 0; // See shader source: (layout = 0). + +using DGL::EBool; +using DGL::EDataType; + +constexpr sfn ZeroOffset() -> ptr +{ + return 0; +} + +// Testing + + // Forward Declares + +sfn RenderProcedure () -> void; +sfn PrepareRenderObjects() -> void; + +sfn CreateWindow_BasicLoop() +{ + DGL::InitalizeGLFW(); + + deduce windowObj = DGL::CreateWindow(720, 540, "Assignment 1: RawLoop", DGL::WindowedMode(), DGL::NotShared()); + + DGL::SetCurrentContext(windowObj); + + DGL::RunBasicWindowLoop(windowObj); +} + +sfn CreateWindow_TimedRender() +{ + DGL::InitalizeGLFW(); + + deduce windowObj = DGL::CreateWindow(720, 540, "Assignment 1: Timed Render", DGL::WindowedMode(), DGL::NotShared()); + + DGL::SetCurrentContext(windowObj); + + DGL::InitalizeGLEW(); + + PrepareRenderObjects(); + + //DGL::RunBasicWindowLoop_Timed(windowObj, 1.0 / 60.0, Address(RenderProcedure)); +} + +sfn PrepareRenderObjects() -> void +{ + RAW_SetupBuffers(); + + RAW_BindAndBufferDataToIDs(); + + DGL::LoadDefaultShaders(); + + DGL::FormatVertexAttributes(VertexAttributeIndex, EDataType::Float, ZeroOffset(), Vertex3::ValueCount(), EBool::False); + + DGL::BindBuffer(EBufferTarget::VertexAttributes, 0); // Dunno. Prob unbinding... + + DGL::BindVertexArray(0); +} + +