|
|
|
|
@ -231,22 +231,31 @@ namespace lunarium
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glm::mat4 model = glm::mat4(1.0f);
|
|
|
|
|
glm::rotate(model, angle, glm::vec3(0.0f, 0.0f, 1.0f));
|
|
|
|
|
model = glm::translate(model, glm::vec3(point_a.x, point_a.y, 0.0f));
|
|
|
|
|
//model = glm::rotate(model, angle, glm::vec3(0.0f, 0.0f, 1.0f));
|
|
|
|
|
|
|
|
|
|
// V1
|
|
|
|
|
LineData::Vertex v1;
|
|
|
|
|
int vert_size = sizeof(LineData::Vertex);
|
|
|
|
|
//glm::vec4 long_pos = glm::vec4(point_a.x, point_a.y, 0.0f, 1.0f) * model;
|
|
|
|
|
v1.pos = point_a;//glm::vec2(long_pos.x, long_pos.y);
|
|
|
|
|
glm::vec4 long_pos = model * glm::vec4(-0.5f, 0.0f, 0.0f, 1.0f);
|
|
|
|
|
v1.pos = glm::vec2(long_pos.x, long_pos.y);
|
|
|
|
|
// v1.translate = glm::vec3(point_a.x, point_a.y, 0.0f);
|
|
|
|
|
v1.color = color;
|
|
|
|
|
//v1.angle = angle;
|
|
|
|
|
memcpy(&mLineData.RawVertexBuffer[mLineData.RawBufferIndex], &v1, vert_size);
|
|
|
|
|
mLineData.RawBufferIndex += 1;
|
|
|
|
|
|
|
|
|
|
model = glm::mat4(1.0f);
|
|
|
|
|
model = glm::translate(model, glm::vec3(point_b.x, point_b.y, 0.0f));
|
|
|
|
|
// model = glm::rotate(model, angle, glm::vec3(0.0f, 0.0f, 1.0f));
|
|
|
|
|
|
|
|
|
|
// V2
|
|
|
|
|
LineData::Vertex v2;
|
|
|
|
|
//long_pos = glm::vec4(point_b.x, point_b.y, 0.0f, 1.0f) * model;
|
|
|
|
|
v2.pos = point_b;//glm::vec2(long_pos.x, long_pos.y);
|
|
|
|
|
long_pos = model * glm::vec4(0.5f, 0.0f, 0.0f, 1.0f);
|
|
|
|
|
v2.pos = glm::vec2(long_pos.x, long_pos.y);
|
|
|
|
|
// v2.translate = glm::vec3(point_b.x, point_b.y, 0.0f);
|
|
|
|
|
v2.color = color;
|
|
|
|
|
//v2.angle = angle;
|
|
|
|
|
memcpy(&mLineData.RawVertexBuffer[mLineData.RawBufferIndex], &v2, vert_size);
|
|
|
|
|
mLineData.RawBufferIndex += 1;
|
|
|
|
|
|
|
|
|
|
@ -256,7 +265,7 @@ namespace lunarium
|
|
|
|
|
|
|
|
|
|
void Renderer2D::DrawBox(Rectangle box, Color color, float thickness, float angle)
|
|
|
|
|
{
|
|
|
|
|
Logger::Warn(LogCategory::GRAPHICS, "Renderer2D::DrawBox is not implemented yet");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Renderer2D::DrawEllipse(glm::vec2 center_point, glm::vec2 radii, Color color, bool filled, float thickness, float angle)
|
|
|
|
|
@ -304,6 +313,9 @@ namespace lunarium
|
|
|
|
|
|
|
|
|
|
glDrawElements(GL_TRIANGLES, mQuadData.NumQuads * 6, GL_UNSIGNED_INT, nullptr);
|
|
|
|
|
|
|
|
|
|
// Checking how the rotation looks when lines are drawn instead
|
|
|
|
|
//glDrawArrays(GL_LINES, 0, mQuadData.NumQuads * 4);
|
|
|
|
|
|
|
|
|
|
// mQuadData.WireFrameShader->Use();
|
|
|
|
|
// uprojview.Location = -1;
|
|
|
|
|
// mQuadData.WireFrameShader->SetUniform(uprojview, (void*)glm::value_ptr(mpCamera->GetViewProjection())).LogIfFailed(LogCategory::GRAPHICS);
|
|
|
|
|
@ -433,7 +445,9 @@ namespace lunarium
|
|
|
|
|
OpRes Renderer2D::InitLineData()
|
|
|
|
|
{
|
|
|
|
|
mLineData.BufferLayout.PushVertexAttribute(VertexAttribute { VertexAttributeType::FLOAT32, 2 }); // Position
|
|
|
|
|
// mLineData.BufferLayout.PushVertexAttribute(VertexAttribute { VertexAttributeType::FLOAT32, 3 }); // Translate
|
|
|
|
|
mLineData.BufferLayout.PushVertexAttribute(VertexAttribute { VertexAttributeType::FLOAT32, 4 }); // Color
|
|
|
|
|
// mLineData.BufferLayout.PushVertexAttribute(VertexAttribute { VertexAttributeType::FLOAT32, 1 }); // angle
|
|
|
|
|
mLineData.VertexBuffer = VertexBuffer::Create(mLineData.BufferLayout, mLineData.MaxVertices);
|
|
|
|
|
|
|
|
|
|
mLineData.RawVertexBuffer = new LineData::Vertex[mLineData.MaxVertices];
|
|
|
|
|
|