examples: Check for errors when loading textures

This commit is contained in:
Antonio Niño Díaz 2024-06-02 11:57:38 +01:00
parent 93483c4d90
commit 26d8512219
6 changed files with 48 additions and 18 deletions

View File

@ -1,6 +1,6 @@
// SPDX-License-Identifier: CC0-1.0
//
// SPDX-FileContributor: Antonio Niño Díaz, 2022
// SPDX-FileContributor: Antonio Niño Díaz, 2022-2024
#include <stdio.h>
@ -68,8 +68,13 @@ int main(void)
int textureID;
glGenTextures(1, &textureID);
glBindTexture(0, textureID);
glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128, TEXTURE_SIZE_128, 0,
TEXGEN_TEXCOORD, (u8*)texture128_bin);
if (glTexImage2D(0, 0, GL_RGBA, TEXTURE_SIZE_128, TEXTURE_SIZE_128, 0,
TEXGEN_TEXCOORD, (u8 *)texture128_bin) == 0)
{
printf("Failed to load texture");
while (1)
swiWaitForVBlank();
}
// Get pointers to the animated model files
const void *dsa_file = robot_walk_dsa_bin;

View File

@ -1,6 +1,6 @@
// SPDX-License-Identifier: CC0-1.0
//
// SPDX-FileContributor: Antonio Niño Díaz, 2022
// SPDX-FileContributor: Antonio Niño Díaz, 2022-2024
#include <stdio.h>
@ -70,8 +70,13 @@ int main(void)
int textureID;
glGenTextures(1, &textureID);
glBindTexture(0, textureID);
glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128, TEXTURE_SIZE_128, 0,
TEXGEN_TEXCOORD, (u8*)texture128_bin);
if (glTexImage2D(0, 0, GL_RGBA, TEXTURE_SIZE_128, TEXTURE_SIZE_128, 0,
TEXGEN_TEXCOORD, (u8 *)texture128_bin) == 0)
{
printf("Failed to load texture");
while (1)
swiWaitForVBlank();
}
const void *dsm_file = robot_dsm_bin;
const void *dsa_file_1 = robot_wave_dsa_bin;

View File

@ -1,6 +1,6 @@
// SPDX-License-Identifier: CC0-1.0
//
// SPDX-FileContributor: Antonio Niño Díaz, 2022
// SPDX-FileContributor: Antonio Niño Díaz, 2022-2024
#include <stdbool.h>
#include <stdio.h>
@ -147,8 +147,13 @@ int main(void)
int textureID;
glGenTextures(1, &textureID);
glBindTexture(0, textureID);
glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128, TEXTURE_SIZE_128, 0,
TEXGEN_TEXCOORD, texture128);
if (glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128, TEXTURE_SIZE_128, 0,
TEXGEN_TEXCOORD, texture128) == 0)
{
printf("Failed to load texture");
while (1)
swiWaitForVBlank();
}
// Obtain number of frames in the animation
const uint32_t num_frames = DSMA_GetNumFrames(dsa_file);

View File

@ -1,6 +1,6 @@
// SPDX-License-Identifier: CC0-1.0
//
// SPDX-FileContributor: Antonio Niño Díaz, 2022
// SPDX-FileContributor: Antonio Niño Díaz, 2022-2024
#include <stdio.h>
@ -72,8 +72,13 @@ int main(void)
int textureID;
glGenTextures(1, &textureID);
glBindTexture(0, textureID);
glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128, TEXTURE_SIZE_128, 0,
TEXGEN_TEXCOORD, (u8*)texture128_bin);
if (glTexImage2D(0, 0, GL_RGBA, TEXTURE_SIZE_128, TEXTURE_SIZE_128, 0,
TEXGEN_TEXCOORD, (u8 *)texture128_bin) == 0)
{
printf("Failed to load texture");
while (1)
swiWaitForVBlank();
}
const void *animations[] = {
robot_wave_dsa_bin,

View File

@ -1,6 +1,6 @@
// SPDX-License-Identifier: CC0-1.0
//
// SPDX-FileContributor: Antonio Niño Díaz, 2022
// SPDX-FileContributor: Antonio Niño Díaz, 2022-2024
#include <stdio.h>
@ -68,8 +68,13 @@ int main(void)
int textureID;
glGenTextures(1, &textureID);
glBindTexture(0, textureID);
glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128, TEXTURE_SIZE_128, 0,
TEXGEN_TEXCOORD, (u8*)texture128_bin);
if (glTexImage2D(0, 0, GL_RGBA, TEXTURE_SIZE_128, TEXTURE_SIZE_128, 0,
TEXGEN_TEXCOORD, (u8 *)texture128_bin) == 0)
{
printf("Failed to load texture");
while (1)
swiWaitForVBlank();
}
const void *robot_dsa_file = robot_walk_dsa_bin;
const void *robot_dsm_file = robot_dsm_bin;

View File

@ -1,6 +1,6 @@
// SPDX-License-Identifier: CC0-1.0
//
// SPDX-FileContributor: Antonio Niño Díaz, 2022
// SPDX-FileContributor: Antonio Niño Díaz, 2022-2024
#include <stdio.h>
@ -186,8 +186,13 @@ int main(void)
int textureID;
glGenTextures(1, &textureID);
glBindTexture(0, textureID);
glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128, TEXTURE_SIZE_128, 0,
TEXGEN_TEXCOORD, (u8*)texture128_bin);
if (glTexImage2D(0, 0, GL_RGBA, TEXTURE_SIZE_128, TEXTURE_SIZE_128, 0,
TEXGEN_TEXCOORD, (u8 *)texture128_bin) == 0)
{
printf("Failed to load texture");
while (1)
swiWaitForVBlank();
}
initialize_models();