Cleanup
This commit is contained in:
parent
29a383f47f
commit
ad9bcac7d2
@ -30,8 +30,8 @@ void Engine::Init() {
|
|||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR); // , GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR);
|
||||||
glBlendEquation(GL_FUNC_SUBTRACT);// , GL_FUNC_ADD);
|
glBlendEquation(GL_FUNC_SUBTRACT);
|
||||||
|
|
||||||
// Objet de skybox avec sa propre texture et son propre shader!
|
// Objet de skybox avec sa propre texture et son propre shader!
|
||||||
m_skybox.Init(0.2f);
|
m_skybox.Init(0.2f);
|
||||||
@ -89,6 +89,7 @@ void Engine::UnloadResource() {}
|
|||||||
|
|
||||||
void Engine::DrawHud(float elapsedTime) {
|
void Engine::DrawHud(float elapsedTime) {
|
||||||
// Setter le blend function , tout ce qui sera noir sera transparent
|
// Setter le blend function , tout ce qui sera noir sera transparent
|
||||||
|
glDisable(GL_STENCIL_TEST);
|
||||||
glColor4f(1.f, 1.f, 1.f, 1.f);
|
glColor4f(1.f, 1.f, 1.f, 1.f);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||||
glBlendEquation(GL_FUNC_ADD);
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
@ -138,9 +139,10 @@ void Engine::DrawHud(float elapsedTime) {
|
|||||||
glTexCoord2f(0, 1);
|
glTexCoord2f(0, 1);
|
||||||
glVertex2i(0, crossSize);
|
glVertex2i(0, crossSize);
|
||||||
glEnd();
|
glEnd();
|
||||||
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR); // , GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR);
|
||||||
glBlendEquation(GL_FUNC_SUBTRACT);// , GL_FUNC_ADD);
|
glBlendEquation(GL_FUNC_SUBTRACT);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glEnable(GL_STENCIL_TEST);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
@ -197,18 +199,13 @@ void Engine::Render(float elapsedTime) {
|
|||||||
else if (m_mouseR)
|
else if (m_mouseR)
|
||||||
m_world.ChangeBlockAtCursor(BTYPE_AIR, m_player, m_block);
|
m_world.ChangeBlockAtCursor(BTYPE_AIR, m_player, m_block);
|
||||||
|
|
||||||
glStencilFunc(GL_EQUAL, 1, 0x00);
|
|
||||||
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
|
||||||
m_world.Update(m_renderCount, m_badHitCount, m_player, all, m_shader01, m_textureAtlas, m_perlin, m_blockinfo);
|
m_world.Update(m_renderCount, m_badHitCount, m_player, all, m_shader01, m_textureAtlas, m_perlin, m_blockinfo);
|
||||||
|
|
||||||
glStencilFunc(GL_GREATER, 1, 0xFF);
|
|
||||||
if (m_isSkybox) m_skybox.Render(skybox);
|
if (m_isSkybox) m_skybox.Render(skybox);
|
||||||
|
|
||||||
if (m_wireframe)
|
if (m_wireframe)
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
glDisable(GL_STENCIL_TEST);
|
|
||||||
DrawHud(elapsedTime);
|
DrawHud(elapsedTime);
|
||||||
glEnable(GL_STENCIL_TEST);
|
|
||||||
if (m_wireframe)
|
if (m_wireframe)
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||||
|
|
||||||
|
@ -162,4 +162,3 @@ void Player::Teleport(int& x, int& z) {
|
|||||||
m_position.x -= x * CHUNK_SIZE_X;
|
m_position.x -= x * CHUNK_SIZE_X;
|
||||||
m_position.z -= z * CHUNK_SIZE_Z;
|
m_position.z -= z * CHUNK_SIZE_Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,11 +107,14 @@ void World::GetScope(int& x, int& y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void World::Update(int& rendercount, int& badhitcount, Player& player, Transformation& world, Shader& shader, TextureAtlas& atlas, Perlin& perlin, BlockInfo* blockinfo[BTYPE_LAST]) {
|
void World::Update(int& rendercount, int& badhitcount, Player& player, Transformation& world, Shader& shader, TextureAtlas& atlas, Perlin& perlin, BlockInfo* blockinfo[BTYPE_LAST]) {
|
||||||
|
glStencilFunc(GL_EQUAL, 1, 0x00);
|
||||||
|
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
||||||
atlas.Bind();
|
atlas.Bind();
|
||||||
RenderWorld(rendercount, badhitcount, player, world, shader);
|
RenderWorld(rendercount, badhitcount, player, world, shader);
|
||||||
TransposeWorld(player);
|
TransposeWorld(player);
|
||||||
UpdateWorld(player, perlin, blockinfo);
|
UpdateWorld(player, perlin, blockinfo);
|
||||||
shader.Disable();
|
shader.Disable();
|
||||||
|
glStencilFunc(GL_GREATER, 1, 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool World::GenerateChunk(int chx, int chy, Perlin& perlin) {
|
bool World::GenerateChunk(int chx, int chy, Perlin& perlin) {
|
||||||
|
@ -46,8 +46,6 @@ private:
|
|||||||
void RenderWorld(int& rendercount, int& badhitcount, Player& player, Transformation& world, Shader& shader);
|
void RenderWorld(int& rendercount, int& badhitcount, Player& player, Transformation& world, Shader& shader);
|
||||||
void UpdateWorld(Player& player, Perlin& perlin, BlockInfo* blockinfo[BTYPE_LAST]);
|
void UpdateWorld(Player& player, Perlin& perlin, BlockInfo* blockinfo[BTYPE_LAST]);
|
||||||
void TransposeWorld(Player& player);
|
void TransposeWorld(Player& player);
|
||||||
/*Chunk* RetrieveChunk(int x, int y);*/
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif // WORLD_H__
|
#endif // WORLD_H__
|
||||||
|
Loading…
x
Reference in New Issue
Block a user