Skip to content

Commit

Permalink
Add FaceCulling
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubPrzystasz committed Jan 14, 2021
1 parent 7cd9a63 commit 098ba6d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,10 @@ Engine::Engine()
screenHeight = 600;
screenWidth = 800;
crossHairSize = 8;
RenderDistance = 8;
ChunkSize = 8;
RenderDistance = 6;
ChunkSize = 6;
ChunkOffset = 2;
RayRange = 7;
RayRange = 6;
flyMode = false;
SelectedBlock = BlockName::Cobble;
StartPosition = glm::vec3(0, 40, 0);
Expand Down
3 changes: 2 additions & 1 deletion Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,9 @@ void Model::Draw()
texture.second->Bind(i);
shadingProgram->SetData(texture.first.c_str(), i++);
}

glBindVertexArray(VAO);
glDrawElements(GL_TRIANGLES, indices.size(), GL_UNSIGNED_INT, nullptr);
glBindVertexArray(0);

}
3 changes: 3 additions & 0 deletions Text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ void Text::RenderText(std::string text, float x, float y, float scale, glm::vec3
glBindTexture(GL_TEXTURE_2D, ch->texture);

ch->BindData();

glDisable(GL_CULL_FACE);

ch->Draw();

x += (ch->Advance >> 6) * scale; // bitshift by 6 to get value in pixels (2^6 = 64 (divide amount of 1/64th pixels by 64 to get amount of pixels))
Expand Down
3 changes: 3 additions & 0 deletions World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ void World::DrawChunks(Camera& camera)
chunk->model->shadingProgram->SetData("projection", camera.Projection);
chunk->model->shadingProgram->SetData("view", camera.GetViewMatrix());
chunk->model->shadingProgram->SetData("model", glm::mat4(1.0f));
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glFrontFace(GL_CW);
chunk->model->Draw();
}
else {
Expand Down
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
int main() {

Engine engine = Engine();
engine.InitializeWindow(1240, 700, "Minecraft ++");
engine.InitializeWindow(1240, 700, "Minecraft++");
engine.WindowLoop();

return 0;
Expand Down

0 comments on commit 098ba6d

Please sign in to comment.