From d272fb6546121c70b4e817ded578251092059893 Mon Sep 17 00:00:00 2001 From: Ed94 Date: Mon, 17 Feb 2020 03:38:40 -0500 Subject: [PATCH] Model buffer doesn't like me, needs superglue. --- DGL_Enum.hpp | 4 ++-- DGL_Model.hpp | 37 ++++++++++++++++++++----------- Execution.cpp | 60 +++++++++++++++++++++++++++++++-------------------- Testing.hpp | 4 ++-- 4 files changed, 65 insertions(+), 40 deletions(-) diff --git a/DGL_Enum.hpp b/DGL_Enum.hpp index db11921..dc55bc7 100644 --- a/DGL_Enum.hpp +++ b/DGL_Enum.hpp @@ -123,8 +123,8 @@ namespace DGL S = GLFW_KEY_S , W = GLFW_KEY_W , LeftShift = GLFW_KEY_LEFT_SHIFT, - Escape = GLFW_KEY_ESCAPE, - UpArrow = GLFW_KEY_UP, + Escape = GLFW_KEY_ESCAPE , + UpArrow = GLFW_KEY_UP , DnArrow = GLFW_KEY_DOWN }; diff --git a/DGL_Model.hpp b/DGL_Model.hpp index 3c0a4f3..6166429 100644 --- a/DGL_Model.hpp +++ b/DGL_Model.hpp @@ -23,7 +23,7 @@ namespace DGL using VertexList = std ::vector < Vector3>; using UVList = std ::vector < Vector2>; - using VecInt = Generic::Vector3< gInt >; + using VecInt = Generic::Vector3< gUInt >; @@ -70,7 +70,7 @@ namespace DGL struct Face { - VecInt Vertexes, Normals; + VecInt Vertexes, uvIndex, Normals; }; struct FaceGenerator @@ -109,7 +109,7 @@ namespace DGL { for (int index = 0; index < uvIndexes.size(); index++) { - //generated.UVs[index] = uvIndexes.at(index); + generated.uvIndex[index] = uvIndexes.at(index); } } if (normals.size() != 0) @@ -120,6 +120,15 @@ namespace DGL } } + if (uvIndexes.size() == 0) + { + generated.uvIndex = VecInt(0, 0, 0); + } + if (normals.size() == 0) + { + generated.Normals = VecInt(0, 0, 0); + } + return generated; } }; @@ -322,24 +331,26 @@ namespace DGL BufferData(Address(Verticies[0]), Verticies.size() * sizeof(Vector3), EBufferTarget::VertexAttributes, EBufferUsage::StaticDraw); + if (VertNormals.size() != 0) + { + BindBuffer(EBufferTarget::VertexAttributes, NBO); - BindBuffer(EBufferTarget::VertexAttributes, NBO); - - BufferData(Address(VertNormals[0]), VertNormals.size() * sizeof(Vector3), EBufferTarget::VertexAttributes, EBufferUsage::StaticDraw); - + BufferData(Address(VertNormals[0]), VertNormals.size() * sizeof(Vector3), EBufferTarget::VertexAttributes, EBufferUsage::StaticDraw); + } + BindBuffer(EBufferTarget::VertexIndices, EBO); BufferData(Address(Faces[0]), Faces.size() * sizeof(Face), EBufferTarget::VertexIndices, EBufferUsage::StaticDraw); + //BufferData(Address(Indicies[0]), Indicies.size() * sizeof(gUInt), EBufferTarget::VertexIndices, EBufferUsage::StaticDraw); - //BufferData(Address(Indicies[0]), Indicies.size() * sizeof(gInt), EBufferTarget::VertexIndices, EBufferUsage::StaticDraw); EnableVertexAttributeArray(0); FormatVertexAttributes(0, EDataType::Float, ZeroOffset(), 3, EBool::False); - //EnableVertexAttributeArray(1); - //FormatVertexAttributes(1, EDataType::Float, ZeroOffset(), 3, EBool::False); + /*EnableVertexAttributeArray(1); + FormatVertexAttributes(1, EDataType::Float, ZeroOffset(), 3, EBool::False);*/ BindVertexArray(0); } @@ -350,11 +361,11 @@ namespace DGL BindBuffer(EBufferTarget::VertexIndices, EBO); - gInt Size; GetBufferParameterIV(EBufferTarget::VertexIndices, DGL::EBufferParam::Size, Address(Size)); + gInt Size; GetBufferParameterIV(EBufferTarget::VertexIndices, EBufferParam::Size, Address(Size)); - Size /= sizeof(Face); + Size /= sizeof(gFloat); - DrawElements(DGL::EPrimitives::Triangles, Size, EDataType::UnsignedInt, ZeroOffset()); + DrawElements(EPrimitives::Triangles, Size, EDataType::UnsignedInt, ZeroOffset()); BindVertexArray(0); } diff --git a/Execution.cpp b/Execution.cpp index 56fb621..9296b4b 100644 --- a/Execution.cpp +++ b/Execution.cpp @@ -80,16 +80,16 @@ namespace Execution 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. + InputInterval = 1.0f / 576.0f, // Interval per second to complete the input process of the cycle. + PhysicsInterval = 1.0f / 288.0f, // Interval per second to complete the physics process of the cycle. + RenderInterval = 1.0f / 144.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. + CamRotationSpeed = 27.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. @@ -120,13 +120,6 @@ namespace Execution // End of temp stuff... - //sfn PrepareRenderObjects() -> void - //{ - // - - //} - - // Currently Does everything required before entering the cycler. sfn PrepWorkspace() { @@ -241,7 +234,7 @@ namespace Execution return; } - sfn ModCamSpeed(bool _isPositive) + sfn ModifyCamSpeed(bool _isPositive) { if (_isPositive) { @@ -253,9 +246,7 @@ namespace Execution } } - deduce ModCamSpeedDelegate = Delegate(ModCamSpeed); - - + deduce ModifyCamSpeedDelegate = Delegate(ModifyCamSpeed); deduce SetPolyModeDelegate = Delegate(SetPolygonMode); sfn InputProcedure(ptr _currentWindowContext) @@ -264,26 +255,29 @@ namespace Execution { ECursorMode cursorMode = ECursorMode(GetMouseInputMode(DefaultWindow, EMouseMode::Cursor)); - deduce delegate = Delegate)>(SetInputMode); + deduce delegate = Delegate)>(SetInputMode); + deduce delegateRaw = Delegate)>(SetInputMode); if (cursorMode == ECursorMode::Normal || cursorMode == ECursorMode::Hidden) { - ActionsToComplete.AddToQueue(delegate, _currentWindowContext, EMouseMode::Cursor, ECursorMode::Disable); + ActionsToComplete.AddToQueue(delegate , _currentWindowContext, EMouseMode::Cursor , ECursorMode::Disable); + ActionsToComplete.AddToQueue(delegateRaw, _currentWindowContext, EMouseMode::RawMouse, EBool ::True ); } else { - ActionsToComplete.AddToQueue(delegate, _currentWindowContext, EMouseMode::Cursor, ECursorMode::Normal); + ActionsToComplete.AddToQueue(delegate , _currentWindowContext, EMouseMode::Cursor , ECursorMode::Normal); + ActionsToComplete.AddToQueue(delegateRaw, _currentWindowContext, EMouseMode::RawMouse, EBool ::False ); } } if (KeyPressed(_currentWindowContext, EKeyCodes::UpArrow)) { - ActionsToComplete.AddToQueue(ModCamSpeedDelegate, true); + ActionsToComplete.AddToQueue(ModifyCamSpeedDelegate, true); } if (KeysPressed(_currentWindowContext, EKeyCodes::DnArrow)) { - ActionsToComplete.AddToQueue(ModCamSpeedDelegate, false); + ActionsToComplete.AddToQueue(ModifyCamSpeedDelegate, false); } if (KeyPressed(_currentWindowContext, EKeyCodes::F2)) @@ -298,12 +292,12 @@ namespace Execution if (CursorX != 0) { - ActionsToComplete.AddToQueue(RotateCamDelegate, ERotationAxis::Yaw, CursorX * CamMoveSpeed, PhysicsDelta); + ActionsToComplete.AddToQueue(RotateCamDelegate, ERotationAxis::Yaw, CursorX * CamRotationSpeed, PhysicsDelta); } if (CursorY != 0) { - ActionsToComplete.AddToQueue(RotateCamDelegate, ERotationAxis::Pitch, CursorY * CamMoveSpeed, PhysicsDelta); + ActionsToComplete.AddToQueue(RotateCamDelegate, ERotationAxis::Pitch, CursorY * CamRotationSpeed, PhysicsDelta); } if (KeyPressed(_currentWindowContext, EKeyCodes::E)) @@ -337,6 +331,18 @@ namespace Execution } } + + 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; + } + sfn PhysicsProcedure() { WorldCamera.UpdateCamera(); @@ -347,14 +353,22 @@ namespace Execution //RAW_RotateLitCube(PhysicsDelta); - ProperCube::Rotate(); + ProperCube::Rotate(PhysicsDelta); + + UpdateThisShit(); } + + sfn RenderProcedure() -> void { + glfwSetWindowTitle(DefaultWindow, somethingtoupdate.str().c_str()); + EnableVertexAttributeArray(VertexAttributeIndex); EnableVertexAttributeArray(1); + + //UseProgramShader(DGL::SS_Transformed::Shader); //BindVertexArray(VertexArrayObj); diff --git a/Testing.hpp b/Testing.hpp index 3999085..b4faa31 100644 --- a/Testing.hpp +++ b/Testing.hpp @@ -467,9 +467,9 @@ namespace ProperCube CoordSpace transform = Matrix4x4(1.0f); - sfn Rotate() + sfn Rotate(gFloat _delta) { - transform = DGL::Rotate(transform, 0.035f, Vector3(0, 1, 0)); + transform = DGL::Rotate(transform, 3.5f * _delta, Vector3(0, 1, 0)); } sfn Render(Ref(CoordSpace) _projection, Ref(CoordSpace) _viewport)