From 3d230a1f29bb143086b4ad9d7b3e878dc8679894 Mon Sep 17 00:00:00 2001 From: JonasD1337 Date: Sun, 23 Jun 2024 14:41:24 +0200 Subject: [PATCH] skybox bla --- src/main.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/main.c b/src/main.c index c7030a9..d816fff 100644 --- a/src/main.c +++ b/src/main.c @@ -137,19 +137,28 @@ void loadTexture(char* textureFile, GLuint* texture) { stbi_image_free(image); } -void loadCubemap(const char* faces[6], GLuint* textureID) { - glGenTextures(1, textureID); - glBindTexture(GL_TEXTURE_CUBE_MAP, *textureID); +void loadSkyboxTexture() { + glGenTextures(1, &skyboxTexture); + glBindTexture(GL_TEXTURE_CUBE_MAP, skyboxTexture); int width, height, nrChannels; + unsigned char *data; + const char* faces[6] = { + "../texture/Cubemaps/Test_map.png", + "../texture/Cubemaps/Test_map.png", + "../texture/Cubemaps/Test_map.png", + "../texture/Cubemaps/Test_map.png", + "../texture/Cubemaps/Test_map.png", + "../texture/Cubemaps/Test_map.png" + }; for (unsigned int i = 0; i < 6; i++) { - unsigned char* data = stbi_load(faces[i], &width, &height, &nrChannels, 0); + data = stbi_load(faces[i], &width, &height, &nrChannels, 0); if (data) { glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data); stbi_image_free(data); } else { - printf("Cubemap texture failed to load at path: %s\n", faces[i]); + printf("Failed to load texture %s\n", faces[i]); stbi_image_free(data); } } @@ -227,10 +236,7 @@ void initSkybox() { exit(1); } - // Read Model Stuff einfügen - //TODO - - //skyboxTexture = loadCubemap(faces); --> faces noch machen + loadSkyboxTexture(); } void renderSkybox(mat4* viewMatrix, mat4* projectionMatrix) { @@ -578,6 +584,7 @@ int main(int argc, char **argv) { } else { model = defaultModel; } + // initialise window glfwInit(); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); @@ -608,6 +615,7 @@ int main(int argc, char **argv) { printf("OpenGL version supported by this platform (%s):\n", glGetString(GL_VERSION)); init(); + initSkybox(); // exit when window should close or exit is requested (ESC) while (!glfwWindowShouldClose(window) && !exitRequested) {