|
|
|
@ -290,39 +290,18 @@ namespace lunarium
|
|
|
|
glBindVertexArray(0);
|
|
|
|
glBindVertexArray(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OglGraphics::DrawFilledBox(glm::vec2 topLeft, glm::vec2 botRight, Color color, float angle)
|
|
|
|
void OglGraphics::DrawFilledBox(Rectangle box, Color color, float angle)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mShapeShader.MakeActive();
|
|
|
|
mShapeShader.MakeActive();
|
|
|
|
mShapeShader.SetUniformMatrix("projection", 1, glm::value_ptr(mProjection));
|
|
|
|
mShapeShader.SetUniformMatrix("projection", 1, glm::value_ptr(mProjection));
|
|
|
|
glm::mat4 model = glm::mat4(1.0f);
|
|
|
|
glm::mat4 model = glm::mat4(1.0f);
|
|
|
|
float width = botRight.x - topLeft.x;
|
|
|
|
model = glm::translate(model, glm::vec3(box.X, box.Y, 0.0f));
|
|
|
|
float height = botRight.y - topLeft.y;
|
|
|
|
|
|
|
|
model = glm::translate(model, glm::vec3(topLeft.x + width / 2, topLeft.y + height / 2 , 0.0f));
|
|
|
|
|
|
|
|
model = glm::rotate(model, angle, glm::vec3(0.0f, 0.0f, 1.0f));
|
|
|
|
model = glm::rotate(model, angle, glm::vec3(0.0f, 0.0f, 1.0f));
|
|
|
|
model = glm::scale(model, glm::vec3(width, height, 1.0f));
|
|
|
|
model = glm::scale(model, glm::vec3(box.HalfWidth * 2, box.HalfHeight * 2, 1.0f));
|
|
|
|
mShapeShader.SetUniformMatrix("model", 1, glm::value_ptr(model));
|
|
|
|
mShapeShader.SetUniformMatrix("model", 1, glm::value_ptr(model));
|
|
|
|
mShapeShader.SetUniformf("shapeColor", { color.Red, color.Green, color.Blue, color.Alpha });
|
|
|
|
mShapeShader.SetUniformf("shapeColor", { color.Red, color.Green, color.Blue, color.Alpha });
|
|
|
|
glBindVertexArray(mRectVAO);
|
|
|
|
glBindVertexArray(mRectVAO);
|
|
|
|
|
|
|
|
|
|
|
|
// GLfloat vertices[6][4] = {
|
|
|
|
|
|
|
|
// { topLeft.x, botRight.y, },
|
|
|
|
|
|
|
|
// { botRight.x, topLeft.y, },
|
|
|
|
|
|
|
|
// { topLeft.x, topLeft.y, },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// { topLeft.x, botRight.y, },
|
|
|
|
|
|
|
|
// { botRight.x, botRight.y, },
|
|
|
|
|
|
|
|
// { botRight.x, topLeft.y, }
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Pos
|
|
|
|
|
|
|
|
// 0.0f, 1.0f,
|
|
|
|
|
|
|
|
// 1.0f, 0.0f,
|
|
|
|
|
|
|
|
// 0.0f, 0.0f,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 0.0f, 1.0f,
|
|
|
|
|
|
|
|
// 1.0f, 1.0f,
|
|
|
|
|
|
|
|
// 1.0f, 0.0f,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GLfloat vertices[6][4] = {
|
|
|
|
GLfloat vertices[6][4] = {
|
|
|
|
{ -0.5f, 0.5f, },
|
|
|
|
{ -0.5f, 0.5f, },
|
|
|
|
{ 0.5f, -0.5f, },
|
|
|
|
{ 0.5f, -0.5f, },
|
|
|
|
@ -342,7 +321,7 @@ namespace lunarium
|
|
|
|
|
|
|
|
|
|
|
|
void OglGraphics::DrawBox(Rectangle dimensions, Color color, float thickness, float angle)
|
|
|
|
void OglGraphics::DrawBox(Rectangle dimensions, Color color, float thickness, float angle)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
glm::vec2 topLeft(dimensions.Left, dimensions.Top);
|
|
|
|
glm::vec2 topLeft(dimensions.left(), dimensions.top());
|
|
|
|
glm::vec2 botRight(dimensions.right(), dimensions.bottom());
|
|
|
|
glm::vec2 botRight(dimensions.right(), dimensions.bottom());
|
|
|
|
|
|
|
|
|
|
|
|
// left side top to bottom
|
|
|
|
// left side top to bottom
|
|
|
|
@ -358,18 +337,21 @@ namespace lunarium
|
|
|
|
DrawLine(glm::vec2(botRight.x, topLeft.y), glm::vec2(topLeft.x, topLeft.y), color, thickness);
|
|
|
|
DrawLine(glm::vec2(botRight.x, topLeft.y), glm::vec2(topLeft.x, topLeft.y), color, thickness);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OglGraphics::DrawImage(Image& image, glm::vec2 topLeft, Color color, float angle)
|
|
|
|
void OglGraphics::DrawImage(Image& image, glm::vec2 position, Color color, float angle)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DrawImage(image, Rectangle(0.0f, 0.0f, (float)image.GetWidth(), (float)image.GetHeight()),
|
|
|
|
float half_width = image.GetWidth() / 2;
|
|
|
|
Rectangle(topLeft.x, topLeft.y, (float)image.GetWidth(), (float)image.GetHeight()), color, angle);
|
|
|
|
float half_height = image.GetHeight() / 2;
|
|
|
|
|
|
|
|
DrawImage(image, Rectangle(half_width, half_height, half_width, half_height),
|
|
|
|
|
|
|
|
Rectangle(position.x, position.y, half_width, half_height), color, angle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OglGraphics::DrawImage(Image& image, Rectangle source, Rectangle destination, Color color, float angle)
|
|
|
|
void OglGraphics::DrawImage(Image& image, Rectangle source, Rectangle destination, Color color, float angle)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
glm::mat4 id = glm::mat4(1.0f);
|
|
|
|
glm::mat4 id = glm::mat4(1.0f);
|
|
|
|
glm::vec3 pos = glm::vec3(destination.Left, destination.Top, 0.0f);
|
|
|
|
glm::vec3 pos = glm::vec3(destination.left(), destination.top(), 0.0f);
|
|
|
|
glm::mat4 trans = glm::translate(id, pos);
|
|
|
|
glm::mat4 trans = glm::translate(id, pos);
|
|
|
|
trans = glm::scale(trans, glm::vec3(destination.Width, destination.Height, 1.0f));
|
|
|
|
trans = glm::rotate(trans, angle, glm::vec3(0.0f, 0.0f, 1.0f));
|
|
|
|
|
|
|
|
trans = glm::scale(trans, glm::vec3(destination.HalfWidth * 2, destination.HalfHeight * 2, 1.0f));
|
|
|
|
|
|
|
|
|
|
|
|
mImageShader.MakeActive();
|
|
|
|
mImageShader.MakeActive();
|
|
|
|
|
|
|
|
|
|
|
|
@ -387,10 +369,10 @@ namespace lunarium
|
|
|
|
// {
|
|
|
|
// {
|
|
|
|
|
|
|
|
|
|
|
|
// NOTE: Pretty sure these values will work out to be correct with out the if check
|
|
|
|
// NOTE: Pretty sure these values will work out to be correct with out the if check
|
|
|
|
float xScale = source.Width / image.GetWidth();
|
|
|
|
float xScale = (source.HalfWidth * 2) / image.GetWidth();
|
|
|
|
float xOffset = source.Left / image.GetWidth();
|
|
|
|
float xOffset = source.left() / image.GetWidth();
|
|
|
|
float yScale = source.Height / image.GetHeight();
|
|
|
|
float yScale = (source.HalfHeight * 2) / image.GetHeight();
|
|
|
|
float yOffset = source.Top / image.GetHeight();
|
|
|
|
float yOffset = source.top() / image.GetHeight();
|
|
|
|
|
|
|
|
|
|
|
|
// Logger::Log(LogCategory::GRAPHICS, LogLevel::INFO_VERBOSE, "uvManip Values: %f, %f, %f, %f", xScale, xOffset, yScale, yOffset);
|
|
|
|
// Logger::Log(LogCategory::GRAPHICS, LogLevel::INFO_VERBOSE, "uvManip Values: %f, %f, %f, %f", xScale, xOffset, yScale, yOffset);
|
|
|
|
|
|
|
|
|
|
|
|
@ -412,7 +394,7 @@ namespace lunarium
|
|
|
|
|
|
|
|
|
|
|
|
void OglGraphics::DrawString(const char* string, Rectangle boundingArea, Color color, float scale, int font)
|
|
|
|
void OglGraphics::DrawString(const char* string, Rectangle boundingArea, Color color, float scale, int font)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mText.DrawString(font, string, glm::vec2(boundingArea.Left, boundingArea.Top),
|
|
|
|
mText.DrawString(font, string, glm::vec2(boundingArea.left(), boundingArea.top()),
|
|
|
|
glm::vec2(boundingArea.right(), boundingArea.bottom()), color, scale, mProjection);
|
|
|
|
glm::vec2(boundingArea.right(), boundingArea.bottom()), color, scale, mProjection);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|