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);
|
||||
}
|
||||
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue