Skip to content

Commit

Permalink
draw grids
Browse files Browse the repository at this point in the history
  • Loading branch information
jonylu7 committed Mar 7, 2024
1 parent a05b511 commit fd8a55e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 25 deletions.
29 changes: 5 additions & 24 deletions src/Grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ void Grid::Start() {
float cellWidth = 48.F;
float cellHeight = 48.F;

for (int i = (WINDOW_WIDTH / 2); i > int(-(WINDOW_WIDTH / 2));
for (int i = (WINDOW_WIDTH / 2); i >= int(-(WINDOW_WIDTH / 2));
i -= cellHeight) {
// vertical
m_lineVector.push_back(Line(glm::vec2(i, int(-(WINDOW_HEIGHT / 2))),
glm::vec2(i, int(WINDOW_HEIGHT / 2))));
}

for (int i = (WINDOW_HEIGHT / 2); i > int(-(WINDOW_HEIGHT / 2));
for (int i = (WINDOW_HEIGHT / 2); i >= int(-(WINDOW_HEIGHT / 2));
i -= cellWidth) {
// horz
m_lineVector.push_back(Line(glm::vec2(int(-(WINDOW_WIDTH / 2)), i),
Expand All @@ -37,30 +37,16 @@ void Grid::Start() {
}

void Grid::Draw(const Util::Transform &transform, const float zindex) {
if (m_Activate == false) {
return;
}
glLineWidth(m_lineWidth);
const float width = WINDOW_WIDTH / 2.0F;
const float height = WINDOW_HEIGHT / 2.0F;

m_Program.Bind();
m_Program.Validate();
m_VertexArray->Bind();


m_VertexArray->Bind();
m_VertexArray->DrawLinesIndices();
//m_VertexArray->DrawLines(m_lineVector.size() * 5 * 2);
//nothing
}

void Grid::DrawUsingCamera(const Util::Transform &transform,
const float zIndex) {


//if (m_Activate == false) {
if (m_Activate == false) {
// return;
//}
}
glLineWidth(m_lineWidth);

m_Program.Bind();
Expand Down Expand Up @@ -116,15 +102,10 @@ void Grid::InitVertexAndColor() {
color.push_back(line.getColor().y);
color.push_back(line.getColor().z);

index.push_back(i);
index.push_back(++i);
i++;

}
m_VertexArray->AddVertexBuffer(
std::make_unique<Core::VertexBuffer>(vertex, 2));
m_VertexArray->AddVertexBuffer(
std::make_unique<Core::VertexBuffer>(color, 3));

//wtf
}
2 changes: 1 addition & 1 deletion src/UI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void UIClass::Update() {
ShowPlayerConstructionMenu();

Util::Transform trans;
int zindex = 200;
int zindex = 20;
m_Grid.DrawUsingCamera(trans, zindex);

ImGui::Render();
Expand Down

0 comments on commit fd8a55e

Please sign in to comment.