diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/glwidget.cpp | 52 | ||||
-rw-r--r-- | src/graphics/shape.cpp | 6 | ||||
-rw-r--r-- | src/ocean/ocean_alt.cpp | 11 |
3 files changed, 41 insertions, 28 deletions
diff --git a/src/glwidget.cpp b/src/glwidget.cpp index 4c8696d..bac695c 100755 --- a/src/glwidget.cpp +++ b/src/glwidget.cpp @@ -68,8 +68,8 @@ void GLWidget::initializeGL() // Enable depth-testing and backface culling glEnable(GL_DEPTH_TEST); - glEnable(GL_CULL_FACE); - glCullFace(GL_BACK); +// glEnable(GL_CULL_FACE); +// glCullFace(GL_BACK); // glShadeModel(GL_SMOOTH); @@ -169,30 +169,38 @@ void GLWidget::initializeGL() void GLWidget::paintCaustics() { glClearColor(0.68f, 0.58f, 0.38f, 1); +// glClearColor(0., 0., 0., 1); glBindFramebuffer(GL_FRAMEBUFFER, m_fbo); +// glBindFramebuffer(GL_FRAMEBUFFER, m_defaultFBO); - // Task 15: Clear the screen here - - // TA SOLUTION + // Clear Screen glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable( GL_BLEND ); - // Bind the shader - m_colorShader->bind(); +// // Bind the shader +// m_colorShader->bind(); - // Task 16: Bind your VAO here +//// m_colorShader->setUniform("asdf", m_arap.minCorner[0], m_arap.maxCorner[0]); +//// // Bind VAO +// glBindVertexArray(m_floor_vao); - // TA SOLUTION - glBindVertexArray(m_floor_vao); - - // Task 17: Draw your VAO here +//// // Draw the VAO +// glDrawArrays(GL_TRIANGLES, 0, 3); - // TA SOLUTION - glDrawArrays(GL_TRIANGLES, 0, 3); - - // Task 18: Unbind your VAO here + m_colorShader->bind(); + // + m_colorShader->setUniform("proj", m_camera.getProjection()); + m_colorShader->setUniform("view", m_camera.getView()); + Eigen::Matrix4f inverseView = m_camera.getView().inverse(); + m_colorShader->setUniform("inverseView", inverseView); + // + m_colorShader->setUniform("widthBounds", m_arap.minCorner[0], m_arap.maxCorner[0]); + m_colorShader->setUniform("lengthBounds", m_arap.minCorner[2], m_arap.maxCorner[2]); + m_arap.draw(m_colorShader, GL_TRIANGLES); - // TA SOLUTION + // Unbind the VAO glBindVertexArray(0); // Unbind the shader @@ -309,9 +317,9 @@ void GLWidget::paintGL() glBindFramebuffer(GL_FRAMEBUFFER, m_defaultFBO); // return; // paintTexture(m_ground_texture, false); -// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); -// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -// glEnable( GL_BLEND ); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable( GL_BLEND ); m_defaultShader->bind(); m_defaultShader->setUniform("proj", m_camera.getProjection()); @@ -345,6 +353,10 @@ void GLWidget::resizeGL(int w, int h) { glViewport(0, 0, w, h); m_camera.setAspect(static_cast<float>(w) / h); + glDeleteTextures(1, &m_fbo_texture); + glDeleteRenderbuffers(1, &m_fbo_renderbuffer); + glDeleteFramebuffers(1, &m_fbo); + makeFBO(); } // ================== Event Listeners diff --git a/src/graphics/shape.cpp b/src/graphics/shape.cpp index 7a33140..4b1d4d4 100644 --- a/src/graphics/shape.cpp +++ b/src/graphics/shape.cpp @@ -138,13 +138,13 @@ void Shape::draw(Shader *shader, GLenum mode) // Not that one texture is overwriting the other, because if we just load sky it doesn't work // Draws whatever is bound to texture0 no matter what. // Drawing the ground texture. - /* // When ground is being rendered dynamically, don't use static ground image. +/* // When ground is being rendered dynamically, don't use static ground image. glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, m_ground_texture); // glBindTexture(GL_TEXTURE_2D, 0); shader->setUniform("groundSampler", 0); - glUniform1i(glGetUniformLocation(shader->id(), "groundSampler"), 0); - */ + glUniform1i(glGetUniformLocation(shader->id(), "groundSampler"), 0);*/ + // https://stackoverflow.com/questions/67277087/opengl-glsl-multiple-texture-binding-not-working // FIGURED OUT THE PROBLEM. it was that SAMPLERS WERE DEFAULTING TO SLOT 0 AND SETUNIFORM WASN'T WORKING diff --git a/src/ocean/ocean_alt.cpp b/src/ocean/ocean_alt.cpp index 025e89b..ca080cd 100644 --- a/src/ocean/ocean_alt.cpp +++ b/src/ocean/ocean_alt.cpp @@ -43,7 +43,8 @@ void ocean_alt::init_wave_index_constants(){ m_waveIndexConstants[i] = wave_const; // initialize m_current_h to be h0 for now - m_current_h.push_back(h0_prime); +// m_current_h.push_back(h0_prime); + m_current_h.push_back(Eigen::Vector2d(0.0, 0.0)); m_displacements.push_back(Eigen::Vector2d(0.0, 0.0)); m_slopes.push_back(Eigen::Vector2d(0.0, 0.0)); m_normals.push_back(Eigen::Vector3f(0.0, 1.0, 0.0)); @@ -269,11 +270,11 @@ std::vector<Eigen::Vector3f> ocean_alt::get_vertices() float ys = 1.f + s[1]*s[1]; float zs = 1.f + s[2]*s[2]; -// Eigen::Vector3f diff = y - s; -// Eigen::Vector3f norm = Eigen::Vector3f(diff[0]/ sqrt(xs), diff[1]/ sqrt(ys), diff[2]/sqrt(zs)); + Eigen::Vector3f diff = y - s; + Eigen::Vector3f norm = Eigen::Vector3f(diff[0]/ sqrt(xs), diff[1]/ sqrt(ys), diff[2]/sqrt(zs)); // NEW - Eigen::Vector3f norm = Eigen::Vector3f(-slope[0], 1.0, -slope[1]); +// Eigen::Vector3f norm = Eigen::Vector3f(-slope[0], 1.0, -slope[1]); norm.normalize(); //NEW @@ -450,4 +451,4 @@ std::vector<Eigen::Vector2d> ocean_alt::fast_fft } return h; -}
\ No newline at end of file +} |