remove the skybox, disable broken frustum
This commit is contained in:
parent
eb05ae1950
commit
840e2fb46b
|
@ -1,7 +0,0 @@
|
|||
#version 330
|
||||
|
||||
in vec3 cardial_color;
|
||||
|
||||
void main(void) {
|
||||
gl_FragColor = vec4(cardial_color.xyz, 1.0f);
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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.0f,-1.0f, 1.0f, 1.0f, 0.0f, // triangle 2 : end
|
||||
1.0f,-1.0f, 1.0f, 1.0f, 0.0f, 1.0f,
|
||||
-1.0f,-1.0f,-1.0f, 1.0f, 0.0f, 1.0f,
|
||||
1.0f,-1.0f,-1.0f, 1.0f, 0.0f, 1.0f,
|
||||
1.0f, 1.0f,-1.0f, 1.0f, 1.0f, 0.0f,
|
||||
1.0f,-1.0f,-1.0f, 1.0f, 1.0f, 0.0f,
|
||||
-1.0f,-1.0f,-1.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
||||
|
||||
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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue