|
|
|
|
@ -57,6 +57,9 @@ namespace lunarium
|
|
|
|
|
mQuadData.mBufferLayout.PushVertexAttribute(VertexAttribute { VertexAttributeType::FLOAT32, 2 }); // Tex_coords
|
|
|
|
|
mQuadData.mBufferLayout.PushVertexAttribute(VertexAttribute { VertexAttributeType::FLOAT32, 4 }); // Color
|
|
|
|
|
mQuadData.mBufferLayout.PushVertexAttribute(VertexAttribute { VertexAttributeType::INT32, 1 }); // Texture Sampler Index
|
|
|
|
|
mQuadData.mBufferLayout.PushVertexAttribute(VertexAttribute { VertexAttributeType::FLOAT32, 3 }); // translation
|
|
|
|
|
mQuadData.mBufferLayout.PushVertexAttribute(VertexAttribute { VertexAttributeType::FLOAT32, 1 }); // angle
|
|
|
|
|
mQuadData.mBufferLayout.PushVertexAttribute(VertexAttribute { VertexAttributeType::FLOAT32, 3 }); // Scale
|
|
|
|
|
mQuadData.mVertexBuffer = VertexBuffer::Create(mQuadData.mBufferLayout, mQuadData.MaxVertices, nullptr, mQuadData.MaxIndices, indices);
|
|
|
|
|
|
|
|
|
|
// RAW VERTEX BUFFER
|
|
|
|
|
@ -215,61 +218,76 @@ namespace lunarium
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
float vertices[40];
|
|
|
|
|
unsigned char* vertices_wl = (unsigned char*)vertices; // vertices write location pointer
|
|
|
|
|
|
|
|
|
|
//unsigned char* vertices_wl = (unsigned char*)vertices; // vertices write location pointer
|
|
|
|
|
|
|
|
|
|
// glm::mat4 model(1.0f);
|
|
|
|
|
// model = glm::translate(model, glm::vec3(quad.CenterPoint().x, quad.CenterPoint().y, 0.0f));
|
|
|
|
|
// model = glm::rotate(model, angle, glm::vec3(0.0f, 0.0f, 1.0f));
|
|
|
|
|
|
|
|
|
|
glm::mat4 model = glm::mat4(1.0f);
|
|
|
|
|
model = glm::translate(model, glm::vec3(quad.X, quad.Y, 0.0f));
|
|
|
|
|
model = glm::rotate(model, angle, glm::vec3(0.0f, 0.0f, 1.0f));
|
|
|
|
|
model = glm::scale(model, glm::vec3(quad.HalfWidth * 2, quad.HalfHeight * 2, 1.0f));
|
|
|
|
|
// glm::mat4 model = glm::mat4(1.0f);
|
|
|
|
|
// model = glm::translate(model, glm::vec3(quad.X, quad.Y, 0.0f));
|
|
|
|
|
// model = glm::rotate(model, angle, glm::vec3(0.0f, 0.0f, 1.0f));
|
|
|
|
|
// model = glm::scale(model, glm::vec3(quad.HalfWidth * 2, quad.HalfHeight * 2, 1.0f));
|
|
|
|
|
|
|
|
|
|
if (mQuadData.mRawBufferIndex + 4 > mQuadData.MaxVertices)
|
|
|
|
|
{
|
|
|
|
|
Flush();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FIRST
|
|
|
|
|
QuadData::Vertex v1;
|
|
|
|
|
int vert_size = sizeof(QuadData::Vertex);
|
|
|
|
|
v1.pos = model * mQuadData.vert_pos[0];
|
|
|
|
|
v1.pos = /*model * */mQuadData.vert_pos[0];
|
|
|
|
|
v1.tex_coord = mQuadData.vert_tex[0];
|
|
|
|
|
v1.color = color;
|
|
|
|
|
v1.tex_slot = texture_slot;
|
|
|
|
|
memcpy(vertices_wl, &v1, vert_size);
|
|
|
|
|
vertices_wl += vert_size;
|
|
|
|
|
v1.translation = glm::vec3(quad.CenterPoint().x, quad.CenterPoint().y, 0.0f);
|
|
|
|
|
v1.angle = angle;
|
|
|
|
|
v1.scale = glm::vec3(quad.HalfWidth * 2, quad.HalfHeight * 2, 1.0f);
|
|
|
|
|
memcpy(&mQuadData.mRawVertexBuffer[mQuadData.mRawBufferIndex], &v1, vert_size);
|
|
|
|
|
mQuadData.mRawBufferIndex += 1;
|
|
|
|
|
|
|
|
|
|
// SECOND
|
|
|
|
|
QuadData::Vertex v2;
|
|
|
|
|
v2.pos = model * mQuadData.vert_pos[1];
|
|
|
|
|
v2.pos = /*model * */ mQuadData.vert_pos[1];
|
|
|
|
|
v2.tex_coord = mQuadData.vert_tex[1];
|
|
|
|
|
v2.color = color;
|
|
|
|
|
v2.tex_slot = texture_slot;
|
|
|
|
|
memcpy(vertices_wl, &v2, vert_size);
|
|
|
|
|
vertices_wl += vert_size;
|
|
|
|
|
v2.translation = glm::vec3(quad.CenterPoint().x, quad.CenterPoint().y, 0.0f);
|
|
|
|
|
v2.angle = angle;
|
|
|
|
|
v2.scale = glm::vec3(quad.HalfWidth * 2, quad.HalfHeight * 2, 1.0f);
|
|
|
|
|
memcpy(&mQuadData.mRawVertexBuffer[mQuadData.mRawBufferIndex], &v2, vert_size);
|
|
|
|
|
mQuadData.mRawBufferIndex += 1;
|
|
|
|
|
|
|
|
|
|
// THIRD
|
|
|
|
|
QuadData::Vertex v3;
|
|
|
|
|
v3.pos =model * mQuadData.vert_pos[2];
|
|
|
|
|
v3.pos = /*model * */ mQuadData.vert_pos[2];
|
|
|
|
|
v3.tex_coord = mQuadData.vert_tex[2];
|
|
|
|
|
v3.color = color;
|
|
|
|
|
v3.tex_slot = texture_slot;
|
|
|
|
|
memcpy(vertices_wl, &v3, vert_size);
|
|
|
|
|
vertices_wl += vert_size;
|
|
|
|
|
v3.translation = glm::vec3(quad.CenterPoint().x, quad.CenterPoint().y, 0.0f);
|
|
|
|
|
v3.angle = angle;
|
|
|
|
|
v3.scale = glm::vec3(quad.HalfWidth * 2, quad.HalfHeight * 2, 1.0f);
|
|
|
|
|
memcpy(&mQuadData.mRawVertexBuffer[mQuadData.mRawBufferIndex], &v3, vert_size);
|
|
|
|
|
mQuadData.mRawBufferIndex += 1;
|
|
|
|
|
|
|
|
|
|
// FOURTH
|
|
|
|
|
QuadData::Vertex v4;
|
|
|
|
|
v4.pos = model * mQuadData.vert_pos[3];
|
|
|
|
|
v4.pos = /*model * */ mQuadData.vert_pos[3];
|
|
|
|
|
v4.tex_coord = mQuadData.vert_tex[3];
|
|
|
|
|
v4.color = color;
|
|
|
|
|
v4.tex_slot = texture_slot;
|
|
|
|
|
memcpy(vertices_wl, &v4, vert_size);
|
|
|
|
|
v4.translation = glm::vec3(quad.CenterPoint().x, quad.CenterPoint().y, 0.0f);
|
|
|
|
|
v4.angle = angle;
|
|
|
|
|
v4.scale = glm::vec3(quad.HalfWidth * 2, quad.HalfHeight * 2, 1.0f);
|
|
|
|
|
memcpy(&mQuadData.mRawVertexBuffer[mQuadData.mRawBufferIndex], &v4, vert_size);
|
|
|
|
|
mQuadData.mRawBufferIndex += 1;
|
|
|
|
|
|
|
|
|
|
if (mQuadData.mRawBufferIndex + 4 > mQuadData.MaxVertices)
|
|
|
|
|
{
|
|
|
|
|
Flush();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memcpy(mQuadData.mRawVertexBuffer + mQuadData.mRawBufferIndex, vertices, sizeof(QuadData::Vertex) * 4);
|
|
|
|
|
mQuadData.mRawBufferIndex += 4;
|
|
|
|
|
// memcpy(mQuadData.mRawVertexBuffer + mQuadData.mRawBufferIndex, vertices, sizeof(QuadData::Vertex) * 4);
|
|
|
|
|
// mQuadData.mRawBufferIndex += 4;
|
|
|
|
|
|
|
|
|
|
// if (!mQuadData.mVertexBuffer->PushVertices(vertices, 4))
|
|
|
|
|
// {
|
|
|
|
|
|