From 6a5806b82c44a2cae481a6015d1a0f390e4b8445 Mon Sep 17 00:00:00 2001 From: Sebastian Park Date: Tue, 23 Apr 2024 12:03:06 -0400 Subject: Create init sky plane. --- src/graphics/shape.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/graphics/shape.cpp') diff --git a/src/graphics/shape.cpp b/src/graphics/shape.cpp index 0cdfe75..6c7ea00 100644 --- a/src/graphics/shape.cpp +++ b/src/graphics/shape.cpp @@ -323,3 +323,41 @@ void Shape::initGroundPlane(std::string texturePath, float depth, Shader* shader shader->unbind(); } +void Shape::initSkyPlane(std::string texturePath, float depth, Shader* shader) { + //TODO: Complete + + QString ground_texture_filepath = QString(texturePath.c_str()); + + // TASK 1: Obtain image from filepath + m_ground_image = QImage(ground_texture_filepath); + + // TASK 2: Format image to fit OpenGL + m_ground_image = m_ground_image.convertToFormat(QImage::Format_RGBA8888).mirrored(); + + auto bits = m_ground_image.bits(); + + // TASK 3: Generate kitten texture + glGenTextures(1, &m_ground_texture); + + // TASK 9: Set the active texture slot to texture slot 0 + glActiveTexture(GL_TEXTURE1); + + // TASK 4: Bind kitten texture + glBindTexture(GL_TEXTURE_2D, m_ground_texture); + + // TASK 5: Load image into kitten texture + glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, m_ground_image.width(), m_ground_image.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, m_ground_image.bits()); + + // TASK 6: Set min and mag filters' interpolation mode to linear + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + // TASK 7: Unbind kitten texture + glBindTexture(GL_TEXTURE_2D, 0); + +// // TASK 10: set the texture.frag uniform for our texture + shader->bind(); + shader->setUniform("sampler", 1); + shader->unbind(); +} + -- cgit v1.2.3-70-g09d2