summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastian Park <SebPark03@gmail.com>2024-04-23 12:03:06 -0400
committerSebastian Park <SebPark03@gmail.com>2024-04-23 12:03:06 -0400
commit6a5806b82c44a2cae481a6015d1a0f390e4b8445 (patch)
treec0774ed28ea29370e59b803f50d5ff35ab8998d7 /src
parent1a26bf6678822bc73d3eb0eb754fd4a01d25573f (diff)
Create init sky plane.
Diffstat (limited to 'src')
-rw-r--r--src/graphics/shape.cpp38
-rw-r--r--src/graphics/shape.h1
2 files changed, 39 insertions, 0 deletions
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();
+}
+
diff --git a/src/graphics/shape.h b/src/graphics/shape.h
index d8ea0c1..4a3632c 100644
--- a/src/graphics/shape.h
+++ b/src/graphics/shape.h
@@ -36,6 +36,7 @@ public:
void setColor(float r, float g, float b);
void initGroundPlane(std::string texturePath, float depth, Shader* shader);
+ void initSkyPlane(std::string texturePath, float depth, Shader* shader);
void draw(Shader *shader, GLenum mode);
SelectMode select(Shader *shader, int vertex);