diff --git a/BaseGLProject/Models/skybox/back.JPG b/BaseGLProject/Models/skybox/back.JPG new file mode 100644 index 0000000..9d7756d Binary files /dev/null and b/BaseGLProject/Models/skybox/back.JPG differ diff --git a/BaseGLProject/Models/skybox/down.JPG b/BaseGLProject/Models/skybox/down.JPG new file mode 100644 index 0000000..7fd0ef9 Binary files /dev/null and b/BaseGLProject/Models/skybox/down.JPG differ diff --git a/BaseGLProject/Models/skybox/front.JPG b/BaseGLProject/Models/skybox/front.JPG new file mode 100644 index 0000000..20e8fe3 Binary files /dev/null and b/BaseGLProject/Models/skybox/front.JPG differ diff --git a/BaseGLProject/Models/skybox/left.JPG b/BaseGLProject/Models/skybox/left.JPG new file mode 100644 index 0000000..b7bd478 Binary files /dev/null and b/BaseGLProject/Models/skybox/left.JPG differ diff --git a/BaseGLProject/Models/skybox/right.JPG b/BaseGLProject/Models/skybox/right.JPG new file mode 100644 index 0000000..e1dd2e2 Binary files /dev/null and b/BaseGLProject/Models/skybox/right.JPG differ diff --git a/BaseGLProject/Models/skybox/top.jpg b/BaseGLProject/Models/skybox/top.jpg new file mode 100644 index 0000000..cb59e8f Binary files /dev/null and b/BaseGLProject/Models/skybox/top.jpg differ diff --git a/BaseGLProject/MyGLWindow.cpp b/BaseGLProject/MyGLWindow.cpp index 0d51478..637717e 100644 --- a/BaseGLProject/MyGLWindow.cpp +++ b/BaseGLProject/MyGLWindow.cpp @@ -161,7 +161,7 @@ void MyGlWindow::setup() //meshes.emplace("Mountain", new Mesh("mountain/mount.blend1.obj", shaders["TexBaseLight"])); meshes.emplace("Sponza", new Mesh("sponza/sponza.obj", shaders["TexBaseLight"])); - meshes["Sponza"]->addTranslation(glm::vec4(0, -200, 0, 1)); + //meshes["Sponza"]->addTranslation(glm::vec4(0, -200, 0, 1)); diff --git a/BaseGLProject/Skybox.cpp b/BaseGLProject/Skybox.cpp new file mode 100644 index 0000000..c0f1a30 --- /dev/null +++ b/BaseGLProject/Skybox.cpp @@ -0,0 +1,96 @@ +#include "Skybox.h" + +Skybox::Skybox() +{ + float side = 50.0f; //size of cube + float side2 = side / 2.0f; + float v[24 * 3] = { + // Front + -side2, -side2, side2, + side2, -side2, side2, + side2, side2, side2, + -side2, side2, side2, + // Right + side2, -side2, side2, + side2, -side2, -side2, + side2, side2, -side2, + side2, side2, side2, + // Back + -side2, -side2, -side2, + -side2, side2, -side2, + side2, side2, -side2, + side2, -side2, -side2, + // Left + -side2, -side2, side2, //12 + -side2, side2, side2, //13 + -side2, side2, -side2, //14 + -side2, -side2, -side2, //15 + // Bottom + -side2, -side2, side2, + -side2, -side2, -side2, + side2, -side2, -side2, + side2, -side2, side2, + // Top + -side2, side2, side2, + side2, side2, side2, + side2, side2, -side2, + -side2, side2, -side2 + }; + + GLuint el[] = { + 0,2,1, 0,3,2, 4,6,5, 4,7,6, + 8,10,9, 8,11,10, 12,14,13, 12,15,14, + 16,18,17, 16,19,18, 20,22,21, 20,23,22 + }; + + glGenVertexArrays(1, &vao); + glBindVertexArray(vao); + + glGenBuffers(1, &vector_vbo); + glBindBuffer(GL_ARRAY_BUFFER, vector_vbo); + glBufferData(GL_ARRAY_BUFFER, 24 * 3 * sizeof(GLfloat), v, GL_STATIC_DRAW); + + glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 3, NULL); + glEnableVertexAttribArray(0); + + glGenBuffers(1, &ibo); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, 36 * sizeof(GLuint), el, GL_STATIC_DRAW); + + glVertexAttribPointer(4, 3, GL_FLOAT, GL_FALSE, 0, NULL); + glEnableVertexAttribArray(4); + + glActiveTexture(GL_TEXTURE0); + glGenTextures(1, &texID); //set the texID as a member variable + glBindTexture(GL_TEXTURE_CUBE_MAP, texID); + + const char * suffixes[] = { "left", "right", "top", "down", "back", "front" }; + + GLuint targets[] = { + GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, + GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, + GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z + }; + + for (int i = 0; i < 6; i++) { + int channel; + int width, height; + std::string filename; + filename = std::string("Models/skybox/" + suffixes[i]) + string(".jpg"); + unsigned char * image = SOIL_load_image(filename.c_str(), &width, &height, &channel, SOIL_LOAD_RGB); + glTexImage2D(targets[i], 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image); + glGenerateMipmap(GL_TEXTURE_2D); + SOIL_free_image_data(image); + } + + +} + + +Skybox::~Skybox() +{ +} + +void Skybox::draw() +{ +} diff --git a/BaseGLProject/Skybox.h b/BaseGLProject/Skybox.h new file mode 100644 index 0000000..a92f8fc --- /dev/null +++ b/BaseGLProject/Skybox.h @@ -0,0 +1,25 @@ +#pragma once +#include +#include +#include +#include +#include + +#include +#include +#include +#include "Loader.h" + +class Skybox +{ +private: + unsigned int vao; + unsigned int vector_vbo; + unsigned int ibo; + GLuint texID; +public: + Skybox(); + ~Skybox(); + void draw(); +}; +