mirror of
https://github.com/Ed94/DuctTaped_GL.git
synced 2024-12-22 15:04:47 -08:00
Model buffer doesn't like me, needs superglue.
This commit is contained in:
parent
d9100a3ff5
commit
d272fb6546
@ -123,8 +123,8 @@ namespace DGL
|
|||||||
S = GLFW_KEY_S ,
|
S = GLFW_KEY_S ,
|
||||||
W = GLFW_KEY_W ,
|
W = GLFW_KEY_W ,
|
||||||
LeftShift = GLFW_KEY_LEFT_SHIFT,
|
LeftShift = GLFW_KEY_LEFT_SHIFT,
|
||||||
Escape = GLFW_KEY_ESCAPE,
|
Escape = GLFW_KEY_ESCAPE ,
|
||||||
UpArrow = GLFW_KEY_UP,
|
UpArrow = GLFW_KEY_UP ,
|
||||||
DnArrow = GLFW_KEY_DOWN
|
DnArrow = GLFW_KEY_DOWN
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ namespace DGL
|
|||||||
|
|
||||||
using VertexList = std ::vector < Vector3>;
|
using VertexList = std ::vector < Vector3>;
|
||||||
using UVList = std ::vector < Vector2>;
|
using UVList = std ::vector < Vector2>;
|
||||||
using VecInt = Generic::Vector3< gInt >;
|
using VecInt = Generic::Vector3< gUInt >;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ namespace DGL
|
|||||||
|
|
||||||
struct Face
|
struct Face
|
||||||
{
|
{
|
||||||
VecInt Vertexes, Normals;
|
VecInt Vertexes, uvIndex, Normals;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FaceGenerator
|
struct FaceGenerator
|
||||||
@ -109,7 +109,7 @@ namespace DGL
|
|||||||
{
|
{
|
||||||
for (int index = 0; index < uvIndexes.size(); index++)
|
for (int index = 0; index < uvIndexes.size(); index++)
|
||||||
{
|
{
|
||||||
//generated.UVs[index] = uvIndexes.at(index);
|
generated.uvIndex[index] = uvIndexes.at(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (normals.size() != 0)
|
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;
|
return generated;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -322,24 +331,26 @@ namespace DGL
|
|||||||
|
|
||||||
BufferData(Address(Verticies[0]), Verticies.size() * sizeof(Vector3), EBufferTarget::VertexAttributes, EBufferUsage::StaticDraw);
|
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);
|
BindBuffer(EBufferTarget::VertexIndices, EBO);
|
||||||
|
|
||||||
BufferData(Address(Faces[0]), Faces.size() * sizeof(Face), EBufferTarget::VertexIndices, EBufferUsage::StaticDraw);
|
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);
|
EnableVertexAttributeArray(0);
|
||||||
FormatVertexAttributes<Vector3>(0, EDataType::Float, ZeroOffset(), 3, EBool::False);
|
FormatVertexAttributes<Vector3>(0, EDataType::Float, ZeroOffset(), 3, EBool::False);
|
||||||
|
|
||||||
//EnableVertexAttributeArray(1);
|
/*EnableVertexAttributeArray(1);
|
||||||
//FormatVertexAttributes<Vector3>(1, EDataType::Float, ZeroOffset(), 3, EBool::False);
|
FormatVertexAttributes<gInt>(1, EDataType::Float, ZeroOffset(), 3, EBool::False);*/
|
||||||
|
|
||||||
BindVertexArray(0);
|
BindVertexArray(0);
|
||||||
}
|
}
|
||||||
@ -350,11 +361,11 @@ namespace DGL
|
|||||||
|
|
||||||
BindBuffer(EBufferTarget::VertexIndices, EBO);
|
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);
|
BindVertexArray(0);
|
||||||
}
|
}
|
||||||
|
@ -80,16 +80,16 @@ namespace Execution
|
|||||||
TimeValDec CycleStart , // Snapshot of cycle loop start time.
|
TimeValDec CycleStart , // Snapshot of cycle loop start time.
|
||||||
CycleEnd , // Snapshot of cycle loop end time.
|
CycleEnd , // Snapshot of cycle loop end time.
|
||||||
DeltaTime , // Delta between last cycle start and end.
|
DeltaTime , // Delta between last cycle start and end.
|
||||||
InputInterval = 1.0f / 240.0f, // Interval per second to complete the input process of the cycle.
|
InputInterval = 1.0f / 576.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.
|
PhysicsInterval = 1.0f / 288.0f, // Interval per second to complete the physics process of the cycle.
|
||||||
RenderInterval = 1.0f / 60.0f ; // Interval per second to complete the render 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.
|
ptr<Window> DefaultWindow; // Default window to use for execution.
|
||||||
|
|
||||||
double CursorX, CursorY; // Cursor axis position on the window.
|
double CursorX, CursorY; // Cursor axis position on the window.
|
||||||
|
|
||||||
gFloat CamMoveSpeed = 8.0f, // Rate at which the camera should move.
|
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.
|
TimeValDec InputDelta = 0.0, // Current delta since last input process.
|
||||||
PhysicsDelta = 0.0, // Current delta since last physics process.
|
PhysicsDelta = 0.0, // Current delta since last physics process.
|
||||||
@ -120,13 +120,6 @@ namespace Execution
|
|||||||
// End of temp stuff...
|
// End of temp stuff...
|
||||||
|
|
||||||
|
|
||||||
//sfn PrepareRenderObjects() -> void
|
|
||||||
//{
|
|
||||||
//
|
|
||||||
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
// Currently Does everything required before entering the cycler.
|
// Currently Does everything required before entering the cycler.
|
||||||
sfn PrepWorkspace()
|
sfn PrepWorkspace()
|
||||||
{
|
{
|
||||||
@ -241,7 +234,7 @@ namespace Execution
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sfn ModCamSpeed(bool _isPositive)
|
sfn ModifyCamSpeed(bool _isPositive)
|
||||||
{
|
{
|
||||||
if (_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);
|
deduce SetPolyModeDelegate = Delegate<decltype(SetPolygonMode)>(SetPolygonMode);
|
||||||
|
|
||||||
sfn InputProcedure(ptr<Window> _currentWindowContext)
|
sfn InputProcedure(ptr<Window> _currentWindowContext)
|
||||||
@ -264,26 +255,29 @@ namespace Execution
|
|||||||
{
|
{
|
||||||
ECursorMode cursorMode = ECursorMode(GetMouseInputMode(DefaultWindow, EMouseMode::Cursor));
|
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)
|
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
|
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))
|
if (KeyPressed(_currentWindowContext, EKeyCodes::UpArrow))
|
||||||
{
|
{
|
||||||
ActionsToComplete.AddToQueue(ModCamSpeedDelegate, true);
|
ActionsToComplete.AddToQueue(ModifyCamSpeedDelegate, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (KeysPressed(_currentWindowContext, EKeyCodes::DnArrow))
|
if (KeysPressed(_currentWindowContext, EKeyCodes::DnArrow))
|
||||||
{
|
{
|
||||||
ActionsToComplete.AddToQueue(ModCamSpeedDelegate, false);
|
ActionsToComplete.AddToQueue(ModifyCamSpeedDelegate, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (KeyPressed(_currentWindowContext, EKeyCodes::F2))
|
if (KeyPressed(_currentWindowContext, EKeyCodes::F2))
|
||||||
@ -298,12 +292,12 @@ namespace Execution
|
|||||||
|
|
||||||
if (CursorX != 0)
|
if (CursorX != 0)
|
||||||
{
|
{
|
||||||
ActionsToComplete.AddToQueue(RotateCamDelegate, ERotationAxis::Yaw, CursorX * CamMoveSpeed, PhysicsDelta);
|
ActionsToComplete.AddToQueue(RotateCamDelegate, ERotationAxis::Yaw, CursorX * CamRotationSpeed, PhysicsDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CursorY != 0)
|
if (CursorY != 0)
|
||||||
{
|
{
|
||||||
ActionsToComplete.AddToQueue(RotateCamDelegate, ERotationAxis::Pitch, CursorY * CamMoveSpeed, PhysicsDelta);
|
ActionsToComplete.AddToQueue(RotateCamDelegate, ERotationAxis::Pitch, CursorY * CamRotationSpeed, PhysicsDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (KeyPressed(_currentWindowContext, EKeyCodes::E))
|
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()
|
sfn PhysicsProcedure()
|
||||||
{
|
{
|
||||||
WorldCamera.UpdateCamera();
|
WorldCamera.UpdateCamera();
|
||||||
@ -347,14 +353,22 @@ namespace Execution
|
|||||||
|
|
||||||
//RAW_RotateLitCube(PhysicsDelta);
|
//RAW_RotateLitCube(PhysicsDelta);
|
||||||
|
|
||||||
ProperCube::Rotate();
|
ProperCube::Rotate(PhysicsDelta);
|
||||||
|
|
||||||
|
UpdateThisShit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sfn RenderProcedure() -> void
|
sfn RenderProcedure() -> void
|
||||||
{
|
{
|
||||||
|
glfwSetWindowTitle(DefaultWindow, somethingtoupdate.str().c_str());
|
||||||
|
|
||||||
EnableVertexAttributeArray(VertexAttributeIndex);
|
EnableVertexAttributeArray(VertexAttributeIndex);
|
||||||
|
|
||||||
EnableVertexAttributeArray(1);
|
EnableVertexAttributeArray(1);
|
||||||
|
|
||||||
|
|
||||||
//UseProgramShader(DGL::SS_Transformed::Shader);
|
//UseProgramShader(DGL::SS_Transformed::Shader);
|
||||||
|
|
||||||
//BindVertexArray(VertexArrayObj);
|
//BindVertexArray(VertexArrayObj);
|
||||||
|
@ -467,9 +467,9 @@ namespace ProperCube
|
|||||||
|
|
||||||
CoordSpace transform = Matrix4x4(1.0f);
|
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)
|
sfn Render(Ref(CoordSpace) _projection, Ref(CoordSpace) _viewport)
|
||||||
|
Loading…
Reference in New Issue
Block a user