Model buffer doesn't like me, needs superglue.

This commit is contained in:
Edward R. Gonzalez 2020-02-17 03:38:40 -05:00
parent d9100a3ff5
commit d272fb6546
4 changed files with 65 additions and 40 deletions

View File

@ -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
};

View File

@ -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<Vector3>(0, EDataType::Float, ZeroOffset(), 3, EBool::False);
//EnableVertexAttributeArray(1);
//FormatVertexAttributes<Vector3>(1, EDataType::Float, ZeroOffset(), 3, EBool::False);
/*EnableVertexAttributeArray(1);
FormatVertexAttributes<gInt>(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);
}

View File

@ -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<Window> 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<decltype(ModCamSpeed)>(ModCamSpeed);
deduce ModifyCamSpeedDelegate = Delegate<decltype(ModifyCamSpeed)>(ModifyCamSpeed);
deduce SetPolyModeDelegate = Delegate<decltype(SetPolygonMode)>(SetPolygonMode);
sfn InputProcedure(ptr<Window> _currentWindowContext)
@ -264,26 +255,29 @@ namespace Execution
{
ECursorMode cursorMode = ECursorMode(GetMouseInputMode(DefaultWindow, EMouseMode::Cursor));
deduce delegate = Delegate<decltype(SetInputMode<ECursorMode>)>(SetInputMode<ECursorMode>);
deduce delegate = Delegate<decltype(SetInputMode<ECursorMode>)>(SetInputMode<ECursorMode>);
deduce delegateRaw = Delegate<decltype(SetInputMode<EBool >)>(SetInputMode<EBool >);
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);

View File

@ -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)