add face culling

This commit is contained in:
2023-06-26 09:59:08 +02:00
parent c9ee8216be
commit 6b9528c2ae
2 changed files with 15 additions and 13 deletions

View File

@@ -50,8 +50,10 @@ bool Renderer::Init() {
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthFunc(GL_LESS);
glFrontFace(GL_CW);
InitShaders();
return true;
}

View File

@@ -71,12 +71,12 @@ GL::VertexArray LoadWorldModel(const td::game::World* world) {
continue;
positions.insert(positions.end(), {
static_cast<float>(chunkX + tileX), 0, static_cast<float>(chunkY + tileY),
static_cast<float>(chunkX + tileX + 1), 0, static_cast<float>(chunkY + tileY),
static_cast<float>(chunkX + tileX), 0, static_cast<float>(chunkY + tileY + 1),
static_cast<float>(chunkX + tileX), 0, static_cast<float>(chunkY + tileY),
static_cast<float>(chunkX + tileX + 1), 0, static_cast<float>(chunkY + tileY),
static_cast<float>(chunkX + tileX), 0, static_cast<float>(chunkY + tileY + 1),
static_cast<float>(chunkX + tileX + 1), 0, static_cast<float>(chunkY + tileY),
static_cast<float>(chunkX + tileX), 0, static_cast<float>(chunkY + tileY + 1),
static_cast<float>(chunkX + tileX), 0, static_cast<float>(chunkY + tileY + 1),
static_cast<float>(chunkX + tileX + 1), 0, static_cast<float>(chunkY + tileY),
static_cast<float>(chunkX + tileX + 1), 0, static_cast<float>(chunkY + tileY + 1)
});
@@ -103,8 +103,8 @@ GL::VertexArray LoadWorldModel(const td::game::World* world) {
float fromY = spawn.GetTopLeft().GetY(), toY = spawn.GetBottomRight().GetY();
positions.insert(positions.end(), {
fromX, 0, fromY,
fromX, 0, toY,
fromX, 0, fromY,
toX, 0, fromY,
toX, 0, toY,
@@ -131,8 +131,8 @@ GL::VertexArray LoadWorldModel(const td::game::World* world) {
float fromY = castle.GetTopLeft().GetY(), toY = castle.GetBottomRight().GetY();
positions.insert(positions.end(), {
fromX, 0, fromY,
fromX, 0, toY,
fromX, 0, fromY,
toX, 0, fromY,
toX, 0, toY,
@@ -168,13 +168,13 @@ GL::VertexArray LoadWorldModel(const td::game::World* world) {
GL::VertexArray LoadTileSelectModel() {
std::vector<float> positions = {
0, 0, 0,
1, 0, 0,
0, 0, 1,
0, .01, 0,
1, .01, 0,
0, .01, 1,
1, 0, 0,
0, 0, 1,
1, 0, 1
0, .01, 1,
1, .01, 0,
1, .01, 1
};
int color = 255 << 24 | 255 << 16 | 255 << 8 | 150;