Non-filled box drawing method added to graphics system

World system design started
Gui_Panel_Refactor
Joeyrp 4 years ago
parent 8ad6eb2880
commit 212545c67c

@ -92,7 +92,7 @@ namespace lunarium
else
{
Logger::Log(LogCategory::CORE, LogLevel::WARNING,
"Can not find Run Mode in state file: %s, defaulting to MODE_TEST", filename);
"Can not find Run Mode in state file: %s, defaulting to MODE_TEST", filename.c_str());
state.Mode = RunMode::MODE_TEST;
}

@ -0,0 +1,57 @@
/******************************************************************************
* File - world.h
* Author - Joey Pollack
* Date - 2022/01/12 (y/m/d)
* Mod Date - 2022/01/12 (y/m/d)
* Description - Manages a game "world". A world is made up of regions which
* are subdivisions of the world. Each region contains: a set
* of images for the maps layers, a list of objects that spawn
* in this region and static collision data.
******************************************************************************/
#ifndef WORLD_H_
#define WORLD_H_
#include <vector>
#include <map>
#include <utils/types.h>
namespace lunarium
{
class Graphics;
class Camera;
class GameObject;
class Script;
class Image;
class World
{
public:
struct Region
{
Script* mRegionScript;
Point2Di mCoords;
std::vector<GameObject*> mObjects;
std::vector<Image*> mLayers;
};
public: // INTERFACE
void OnLoad();
void OnUnload();
void Update(float dt);
void Render(Graphics* pGraphics);
void RenderToTexture(Graphics* pGraphics, Image* pTexture);
private:
Camera* mpCamera;
std::vector<GameObject*> mWorldObjects;
std::vector<Script*> mWorldScripts; // Maybe just want 1 script?
Sizei mRegionSize;
std::map<Point2Di, Region*> mRegions;
};
}
#endif // WORLD_H_

@ -328,16 +328,46 @@ namespace lunarium
glm::vec2 botRight(dimensions.right(), dimensions.bottom());
// left side top to bottom
DrawLine(glm::vec2(topLeft.x, topLeft.y), glm::vec2(topLeft.x, botRight.y), color, thickness);
// DrawLine(glm::vec2(topLeft.x, topLeft.y), glm::vec2(topLeft.x, botRight.y), color, thickness, angle);
// // bottom left to right
// DrawLine(glm::vec2(topLeft.x, botRight.y), glm::vec2(botRight.x, botRight.y), color, thickness, angle);
// // right side bottom to top
// DrawLine(glm::vec2(botRight.x, botRight.y), glm::vec2(botRight.x, topLeft.y), color, thickness, angle);
// // top right to left
// DrawLine(glm::vec2(botRight.x, topLeft.y), glm::vec2(topLeft.x, topLeft.y), color, thickness, angle);
mShapeShader.MakeActive();
mShapeShader.SetUniformMatrix("projection", 1, glm::value_ptr(mProjection));
glm::mat4 model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(dimensions.CenterPoint().x, dimensions.CenterPoint().y, 0.0f));
model = glm::scale(model, glm::vec3(dimensions.HalfWidth * 2, dimensions.HalfHeight * 2, 1.0f));
model = glm::rotate(model, angle, glm::vec3(0.0f, 0.0f, 1.0f));
mShapeShader.SetUniformMatrix("model", 1, glm::value_ptr(model));
mShapeShader.SetUniformf("shapeColor", { color.Red, color.Green, color.Blue, color.Alpha });
glBindVertexArray(mRectVAO);
GLfloat lineVerts[4][4] = {
{ -0.5f, -0.5f, },
{ 0.5f, -0.5f },
{ 0.5f, 0.5f, },
{ -0.5f, 0.5f, },
};
glBindBuffer(GL_ARRAY_BUFFER, mRectVBO);
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(lineVerts), lineVerts);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glLineWidth(thickness);
glDrawArrays(GL_LINE_LOOP, 0, 4);
glBindVertexArray(0);
// bottom left to right
DrawLine(glm::vec2(topLeft.x, botRight.y), glm::vec2(botRight.x, botRight.y), color, thickness);
// right side bottom to top
DrawLine(glm::vec2(botRight.x, botRight.y), glm::vec2(botRight.x, topLeft.y), color, thickness);
// top right to left
DrawLine(glm::vec2(botRight.x, topLeft.y), glm::vec2(topLeft.x, topLeft.y), color, thickness);
}
void OglGraphics::DrawImage(Image& image, glm::vec2 position, Color color, float angle)

@ -68,6 +68,7 @@ namespace lunarium
Core::Graphics().RegisterImage(*mUpArrowIcon);
mUpArrowIcon->FreeRawData();
//////////////////////////////////////////
}
void DataManager::Shutdown()

@ -77,6 +77,11 @@ namespace lunarium
return true;
}
glm::vec2 Rectangle::CenterPoint() const
{
return glm::vec2(X, Y);
}
bool Rectangle::Intersects(const Rectangle& other, glm::vec2& centers) const
{
glm::vec2 myCenter = glm::vec2(X, Y);

@ -15,6 +15,20 @@
namespace lunarium
{
////////////////////////////////////////////////////////////
// POINT
////////////////////////////////////////////////////////////
template <typename T>
struct Point2D
{
T X;
T Y;
};
typedef Point2D<int> Point2Di;
typedef Point2D<unsigned> Point2Du;
typedef Point2D<float> Point2Df;
///////////////////////////////////////////////////////
// SIZE
//////////////////////////////////////////////////////

@ -26,11 +26,13 @@ namespace lunarium
Logger::Log(mLogCat, LogLevel::INFO, "Running Simple Render Test Scene");
mTextBoxWidth = 500;
// Currently the full default window size
mImageSize.Width = 1280;
mImageSize.Height = 720;
angle = 0.0f;
box_angle = 0.0f;
}
void SimpleRenderScene::OnTick(double delta)
@ -94,13 +96,17 @@ namespace lunarium
Color(0.0f, 1.0f, 1.0f, 1.0f), 0.5f, g.DefaultFont());
mpRenderedImage = Core::GetInstance().EndRenderToTexture();
box_angle += 0.01f;
}
void SimpleRenderScene::OnRender(IGraphics* g)
{
g->DrawImage(*mpRenderedImage, Rectangle::MakeFromTopLeft(0.0f, 0.0f, (float)mpRenderedImage->GetWidth(), (float)mpRenderedImage->GetHeight()),
Rectangle::MakeFromTopLeft(0.0f, 0.0f, (float)mImageSize.Width, (float)mImageSize.Height), Color(1.0f, 1.0f, 1.0f, 1.0f), angle);
Rectangle::MakeFromTopLeft(0.0f, 0.0f, (float)mImageSize.Width, (float)mImageSize.Height), Color(1.0f, 1.0f, 1.0f, 1.0f), angle);
g->DrawBox(Rectangle::MakeFromTopLeft(0.0f, 0.0f, (float)mImageSize.Width, (float)mImageSize.Height), Color(0.0f, 0.0f, 0.0f, 1.0f), 1.0f, angle);
g->DrawBox(Rectangle(400, 400, 128.0f, 128.0f), Color(0.0f, 1.0f, 0.0f, 1.0f), 2.0f, box_angle);
}
}

@ -29,6 +29,7 @@ namespace lunarium
Sizei mImageSize;
Image* mpRenderedImage;
float angle;
float box_angle;
};
}

Loading…
Cancel
Save