[Chunk] Working on it.

This commit is contained in:
Quentin Bazin 2014-12-19 16:00:31 +01:00
parent 0b806a93c6
commit 56d3ddb14a
5 changed files with 7 additions and 11 deletions

View File

@ -37,7 +37,6 @@ void main() {
} }
vec4 surfaceColor = texture2D(u_tex, v_texCoord); vec4 surfaceColor = texture2D(u_tex, v_texCoord);
gl_FragColor = surfaceColor * (ambientColor + diffuseColor); gl_FragColor = surfaceColor * (ambientColor + diffuseColor);
} }

View File

@ -54,6 +54,8 @@ void Application::initGL() {
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST);
glClearColor(0.196078, 0.6, 0.8, 1.0); // Skyblue glClearColor(0.196078, 0.6, 0.8, 1.0); // Skyblue
} }

View File

@ -26,16 +26,8 @@ GameState::GameState() {
Shader::bind(&m_shader); Shader::bind(&m_shader);
m_projectionMatrix = glm::perspective(45.0f, 640.0f / 480.0f, 0.1f, 3000.0f); m_projectionMatrix = glm::perspective(45.0f, 640.0f / 480.0f, 0.1f, 3000.0f);
/*glm::mat4 modelviewMatrix = glm::lookAt(glm::vec3(-20.0f, 40.0f, -20.0f),
glm::vec3(16.0f, 16.0f, 16.0f),
glm::vec3(0.0f, 1.0f, 0.0f));
*/
m_viewMatrix = m_camera.update(); m_viewMatrix = m_camera.update();
//glActiveTexture(GL_TEXTURE0);
glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST);
m_shader.setUniform("u_tex", 0); m_shader.setUniform("u_tex", 0);
Shader::bind(nullptr); Shader::bind(nullptr);

View File

@ -174,6 +174,7 @@ void Chunk::update() {
|| (x == width - 1 && m_surroundingChunks[1] && m_surroundingChunks[1]->getBlock(0, y, z) && i == 1) || (x == width - 1 && m_surroundingChunks[1] && m_surroundingChunks[1]->getBlock(0, y, z) && i == 1)
|| (z == 0 && m_surroundingChunks[2] && m_surroundingChunks[2]->getBlock(x, y, depth - 1) && i == 5) || (z == 0 && m_surroundingChunks[2] && m_surroundingChunks[2]->getBlock(x, y, depth - 1) && i == 5)
|| (z == depth - 1 && m_surroundingChunks[3] && m_surroundingChunks[3]->getBlock(x, y, 0) && i == 4) || (z == depth - 1 && m_surroundingChunks[3] && m_surroundingChunks[3]->getBlock(x, y, 0) && i == 4)
|| y < 18
) { ) {
continue; continue;
} }
@ -183,6 +184,8 @@ void Chunk::update() {
glm::vec3 normal = glm::normalize(glm::cross(u, v)); glm::vec3 normal = glm::normalize(glm::cross(u, v));
for(u8 j = 0 ; j < 4 ; j++) { for(u8 j = 0 ; j < 4 ; j++) {
DEBUG("(", (int)x, (int)y, (int)z, "): [", (int)i, (int)j, "] >= (", x + cubeCoords[i * 12 + j * 3], y + cubeCoords[i * 12 + j * 3 + 1], z + cubeCoords[i * 12 + j * 3 + 2], ")");
m_vertices.push_back(x + cubeCoords[i * 12 + j * 3]); m_vertices.push_back(x + cubeCoords[i * 12 + j * 3]);
m_vertices.push_back(y + cubeCoords[i * 12 + j * 3 + 1]); m_vertices.push_back(y + cubeCoords[i * 12 + j * 3 + 1]);
m_vertices.push_back(z + cubeCoords[i * 12 + j * 3 + 2]); m_vertices.push_back(z + cubeCoords[i * 12 + j * 3 + 2]);

View File

@ -21,8 +21,8 @@
#include "World.hpp" #include "World.hpp"
World::World() { World::World() {
m_width = 4; m_width = 1;
m_depth = 4; m_depth = 1;
//for(s32 z = -m_depth / 2 ; z < m_depth / 2 ; z++) { //for(s32 z = -m_depth / 2 ; z < m_depth / 2 ; z++) {
// for(s32 x = -m_width / 2 ; x < m_width / 2 ; x++) { // for(s32 x = -m_width / 2 ; x < m_width / 2 ; x++) {