From 840e2fb46b459fe7ff49a0beaef2e149950f6328 Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Thu, 7 Jun 2018 12:29:44 +0300 Subject: [PATCH] remove the skybox, disable broken frustum --- data/shaders/skybox.frag | 7 ---- data/shaders/skybox.vert | 15 -------- src/Application.cpp | 74 --------------------------------------- src/planet/PlanetFace.cpp | 12 +++---- 4 files changed, 6 insertions(+), 102 deletions(-) delete mode 100644 data/shaders/skybox.frag delete mode 100644 data/shaders/skybox.vert diff --git a/data/shaders/skybox.frag b/data/shaders/skybox.frag deleted file mode 100644 index 29d04bb..0000000 --- a/data/shaders/skybox.frag +++ /dev/null @@ -1,7 +0,0 @@ -#version 330 - -in vec3 cardial_color; - -void main(void) { - gl_FragColor = vec4(cardial_color.xyz, 1.0f); -} diff --git a/data/shaders/skybox.vert b/data/shaders/skybox.vert deleted file mode 100644 index 131e605..0000000 --- a/data/shaders/skybox.vert +++ /dev/null @@ -1,15 +0,0 @@ -#version 330 - -in vec3 position; -in vec3 color; -out vec3 cardial_color; - -uniform mat4 projectionMatrix; -uniform mat4 viewMatrix; -uniform mat4 modelMatrix; - -void main(void) { - gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.0); - - cardial_color = color; -} diff --git a/src/Application.cpp b/src/Application.cpp index 80561ae..34c5a16 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -158,70 +158,6 @@ void Application::run() // TEST CODE SDL_ShowCursor(SDL_DISABLE); Input::getInstance().setMouseCoords(m_width/2, m_height/2); - - static const GLfloat vertices[] = { - -1.0f,-1.0f,-1.0f, 0.0f, 1.0f, 1.0f, // triangle 1 : begin - -1.0f,-1.0f, 1.0f, 0.0f, 1.0f, 1.0f, - -1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, // triangle 1 : end - 1.0f, 1.0f,-1.0f, 1.0f, 1.0f, 0.0f, // triangle 2 : begin - -1.0f,-1.0f,-1.0f, 1.0f, 1.0f, 0.0f, - -1.0f, 1.0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.0f, 0.0f, - 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, - -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, - 1.0f,-1.0f, 1.0f, 0.0f, 0.0f, 1.0f - }; - - GLuint vertexArray, vertexBuffer; - - // Create VAO - glGenVertexArrays(1, &vertexArray); - glBindVertexArray(vertexArray); - - // Generate 1 buffer, put the resulting identifier in vertexBuffer - glGenBuffers(1, &vertexBuffer); - // The following commands will talk about our 'vertexBuffer' buffer - glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); - // Give our vertices to OpenGL. - glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); - - // Create the shader and link them together - Shader& skyboxShader = Shader::createShader("data/shaders/skybox.vert", "data/shaders/skybox.frag"); - skyboxShader.linkShaders(); - - // Give the buffers to the shader - skyboxShader.setBuffers(vertexArray, vertexBuffer, 0); - - // Set attribute arrays - skyboxShader.setAttribute("position", 3, GL_FALSE, 6, 0, GL_FLOAT); - skyboxShader.setAttribute("color", 3, GL_FALSE, 6, 3, GL_FLOAT); - glEnable(GL_DEPTH_TEST); Planet* pl = new Planet(glm::vec3(0.0f,0.0f,0.0f), 4); @@ -251,15 +187,6 @@ void Application::run() // TEST CODE - glm::vec3 cameraPos = m_camera->getPosition(); - - glm::mat4 model = glm::scale(glm::translate(glm::mat4(1.0f), cameraPos), glm::vec3(50.0f, 50.0f, 50.0f)); - skyboxShader.use(); - skyboxShader.setUniform("modelMatrix", model); - m_camera->shaderViewProjection(skyboxShader); // Load view and projection matrices - - glDrawArrays(GL_TRIANGLES, 0, 12*3); // 12*3 indices starting at 0 -> 12 triangles -> 6 squares - pl->tick(m_camera, deltaTime); //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); @@ -268,7 +195,6 @@ void Application::run() //glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); - // END TEST CODE update(deltaTime); diff --git a/src/planet/PlanetFace.cpp b/src/planet/PlanetFace.cpp index f7e70b7..720b44a 100644 --- a/src/planet/PlanetFace.cpp +++ b/src/planet/PlanetFace.cpp @@ -313,14 +313,14 @@ void ChunkManager::updateRender(Camera* camera) if(pChunk->shouldRender()) // Early flags check so we don't always have to do the frustum check... { // TODO: fix frustum culling - glm::vec3 pos = pChunk->getAbsolutePosition(); - glm::mat4 model = glm::translate(glm::mat4(1.0f), pos); + //glm::vec3 pos = pChunk->getAbsolutePosition(); + //glm::mat4 model = glm::translate(glm::mat4(1.0f), pos); - camera->updateFrustum(model); - if(camera->frustumContainsBox(glm::vec3(0.0f), glm::vec3((float)CHUNK_SIZE)) != 0) - { + //camera->updateFrustum(model); + //if(camera->frustumContainsBox(glm::vec3(0.0f), glm::vec3((float)CHUNK_SIZE / 2)) > 0) + //{ m_chunkRenderQueue.push_back(pChunk); - } + //} } } }