skybox bla
This commit is contained in:
parent
2ddca33da4
commit
3d230a1f29
26
src/main.c
26
src/main.c
|
@ -137,19 +137,28 @@ void loadTexture(char* textureFile, GLuint* texture) {
|
||||||
stbi_image_free(image);
|
stbi_image_free(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadCubemap(const char* faces[6], GLuint* textureID) {
|
void loadSkyboxTexture() {
|
||||||
glGenTextures(1, textureID);
|
glGenTextures(1, &skyboxTexture);
|
||||||
glBindTexture(GL_TEXTURE_CUBE_MAP, *textureID);
|
glBindTexture(GL_TEXTURE_CUBE_MAP, skyboxTexture);
|
||||||
|
|
||||||
int width, height, nrChannels;
|
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++) {
|
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) {
|
if (data) {
|
||||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
|
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
|
||||||
0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
|
0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
|
||||||
stbi_image_free(data);
|
stbi_image_free(data);
|
||||||
} else {
|
} 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);
|
stbi_image_free(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,10 +236,7 @@ void initSkybox() {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read Model Stuff einfügen
|
loadSkyboxTexture();
|
||||||
//TODO
|
|
||||||
|
|
||||||
//skyboxTexture = loadCubemap(faces); --> faces noch machen
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderSkybox(mat4* viewMatrix, mat4* projectionMatrix) {
|
void renderSkybox(mat4* viewMatrix, mat4* projectionMatrix) {
|
||||||
|
@ -578,6 +584,7 @@ int main(int argc, char **argv) {
|
||||||
} else {
|
} else {
|
||||||
model = defaultModel;
|
model = defaultModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialise window
|
// initialise window
|
||||||
glfwInit();
|
glfwInit();
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
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));
|
printf("OpenGL version supported by this platform (%s):\n", glGetString(GL_VERSION));
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
initSkybox();
|
||||||
|
|
||||||
// exit when window should close or exit is requested (ESC)
|
// exit when window should close or exit is requested (ESC)
|
||||||
while (!glfwWindowShouldClose(window) && !exitRequested) {
|
while (!glfwWindowShouldClose(window) && !exitRequested) {
|
||||||
|
|
Loading…
Reference in New Issue