le humble skybox
This commit is contained in:
parent
fed15e4ff8
commit
9162b9327e
Binary file not shown.
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 24 KiB |
Binary file not shown.
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 28 KiB |
|
@ -33,8 +33,8 @@ void renderInit(GLFWwindow* window) {
|
|||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
skyboxTexture = new Skybox({
|
||||
"assets/textures/skybox/null_plainsky512_rt.jpg",
|
||||
"assets/textures/skybox/null_plainsky512_lf.jpg",
|
||||
"assets/textures/skybox/null_plainsky512_rt.jpg",
|
||||
"assets/textures/skybox/null_plainsky512_up.jpg",
|
||||
"assets/textures/skybox/null_plainsky512_dn.jpg",
|
||||
"assets/textures/skybox/null_plainsky512_ft.jpg",
|
||||
|
@ -47,6 +47,7 @@ void renderInit(GLFWwindow* window) {
|
|||
}
|
||||
|
||||
void renderParts() {
|
||||
glDepthMask(GL_TRUE);
|
||||
|
||||
// Use shader
|
||||
shader->use();
|
||||
|
@ -101,6 +102,8 @@ void renderParts() {
|
|||
}
|
||||
|
||||
void renderSkyBox() {
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
skyboxShader->use();
|
||||
|
||||
glm::mat4 projection = glm::perspective(glm::radians(45.f), (float)1200 / (float)900, 0.1f, 100.0f);
|
||||
|
@ -121,5 +124,5 @@ void render(GLFWwindow* window) {
|
|||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
renderSkyBox();
|
||||
// renderParts();
|
||||
renderParts();
|
||||
}
|
|
@ -8,15 +8,6 @@ Skybox::Skybox(std::array<std::string, 6> faces, unsigned int format) {
|
|||
glGenTextures(1, &this->ID);
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, this->ID);
|
||||
|
||||
// Wrapping
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
||||
|
||||
// Interpolation
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
// stbi_set_flip_vertically_on_load(true);
|
||||
for (unsigned int i = 0; i< faces.size(); i++) {
|
||||
int width, height, nrChannels;
|
||||
|
@ -30,11 +21,17 @@ Skybox::Skybox(std::array<std::string, 6> faces, unsigned int format) {
|
|||
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, format, width, height, 0, format,
|
||||
GL_UNSIGNED_BYTE, data);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
|
||||
|
||||
stbi_image_free(data);
|
||||
}
|
||||
|
||||
// Wrapping
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
||||
|
||||
// Interpolation
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
}
|
||||
|
||||
Skybox::~Skybox() {
|
||||
|
|
Loading…
Reference in a new issue