summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2024-02-25 15:08:26 -0800
committer3gg <3gg@shellblade.net>2024-02-25 15:08:26 -0800
commit5e6328e83bcc2d26d61ca9c084450a0af2bda341 (patch)
tree7ab5556c07589873aeed96db66aed4bf69ea0fe1
parentfd3cbac7a9b47936d28cfcf11b7781c563779129 (diff)
Use new error function.
-rw-r--r--gfx/src/asset/texture.c14
-rw-r--r--gfx/src/render/framebuffer.c10
-rw-r--r--gfx/src/render/renderbuffer.c4
-rw-r--r--gfx/src/scene/light.c2
4 files changed, 15 insertions, 15 deletions
diff --git a/gfx/src/asset/texture.c b/gfx/src/asset/texture.c
index d15f09f..3a82788 100644
--- a/gfx/src/asset/texture.c
+++ b/gfx/src/asset/texture.c
@@ -61,7 +61,7 @@ Texture* gfx_texture_load(
61 stbi_set_flip_vertically_on_load(0); 61 stbi_set_flip_vertically_on_load(0);
62 pixels[0] = stbi_load(filepath, &width, &height, &components, 0); 62 pixels[0] = stbi_load(filepath, &width, &height, &components, 0);
63 if (!pixels[0]) { 63 if (!pixels[0]) {
64 set_error("Failed to load texture file: %s", filepath); 64 log_error("Failed to load texture file: %s", filepath);
65 } 65 }
66 break; 66 break;
67 } 67 }
@@ -74,11 +74,11 @@ Texture* gfx_texture_load(
74 stbi_uc* image_pixels = 74 stbi_uc* image_pixels =
75 stbi_load(filepath, &width, &height, &components, 0); 75 stbi_load(filepath, &width, &height, &components, 0);
76 if (!image_pixels) { 76 if (!image_pixels) {
77 set_error("Failed to load texture file: %s", filepath); 77 log_error("Failed to load texture file: %s", filepath);
78 break; 78 break;
79 } 79 }
80 if (i > 0 && components != old_components) { 80 if (i > 0 && components != old_components) {
81 set_error("All textures in a cubemap must have the same number of " 81 log_error("All textures in a cubemap must have the same number of "
82 "components"); 82 "components");
83 break; 83 break;
84 } 84 }
@@ -93,7 +93,7 @@ Texture* gfx_texture_load(
93 break; 93 break;
94 case AssetFromMemory: 94 case AssetFromMemory:
95 // TODO: Load textures from memory. 95 // TODO: Load textures from memory.
96 set_error("Loading textures from memory is not yet implemented"); 96 log_error("Loading textures from memory is not yet implemented");
97 return 0; 97 return 0;
98 } 98 }
99 99
@@ -132,7 +132,7 @@ Texture* gfx_texture_load(
132 desc.format = TextureSRGB8; 132 desc.format = TextureSRGB8;
133 break; 133 break;
134 default: 134 default:
135 set_error("Unsupported texture colour space: %d", cmd->colour_space); 135 log_error("Unsupported texture colour space: %d", cmd->colour_space);
136 return 0; 136 return 0;
137 } 137 }
138 break; 138 break;
@@ -145,12 +145,12 @@ Texture* gfx_texture_load(
145 desc.format = TextureSRGBA8; 145 desc.format = TextureSRGBA8;
146 break; 146 break;
147 default: 147 default:
148 set_error("Unsupported texture colour space: %d", cmd->colour_space); 148 log_error("Unsupported texture colour space: %d", cmd->colour_space);
149 return 0; 149 return 0;
150 } 150 }
151 break; 151 break;
152 default: 152 default:
153 set_error("Unsupported number of texture components: %d", components); 153 log_error("Unsupported number of texture components: %d", components);
154 return 0; 154 return 0;
155 } 155 }
156 156
diff --git a/gfx/src/render/framebuffer.c b/gfx/src/render/framebuffer.c
index 2ea2165..76d9002 100644
--- a/gfx/src/render/framebuffer.c
+++ b/gfx/src/render/framebuffer.c
@@ -52,7 +52,7 @@ static void framebuffer_attach_depth(
52 // TODO: Could distinguish between colour and depth attachment types to make 52 // TODO: Could distinguish between colour and depth attachment types to make
53 // this a compile-time error. 53 // this a compile-time error.
54 case FrameBufferCubemapTexture: 54 case FrameBufferCubemapTexture:
55 set_error("Cannot use a cubemap texture as a depth framebuffer attachment"); 55 log_error("Cannot use a cubemap texture as a depth framebuffer attachment");
56 break; 56 break;
57 case FrameBufferRenderBuffer: 57 case FrameBufferRenderBuffer:
58 glFramebufferRenderbuffer( 58 glFramebufferRenderbuffer(
@@ -71,7 +71,7 @@ bool gfx_init_framebuffer(
71 71
72 glGenFramebuffers(1, &framebuffer->id); 72 glGenFramebuffers(1, &framebuffer->id);
73 if (!framebuffer->id) { 73 if (!framebuffer->id) {
74 set_error("glGenFramebuffers() failed"); 74 log_error("glGenFramebuffers() failed");
75 return false; 75 return false;
76 } 76 }
77 77
@@ -85,7 +85,7 @@ bool gfx_init_framebuffer(
85 framebuffer_attach_colour(framebuffer, &desc->colour); 85 framebuffer_attach_colour(framebuffer, &desc->colour);
86 framebuffer_attach_depth(framebuffer, &desc->depth); 86 framebuffer_attach_depth(framebuffer, &desc->depth);
87 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { 87 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
88 set_error("glCheckFramebufferStatus() failed"); 88 log_error("glCheckFramebufferStatus() failed");
89 gfx_del_framebuffer(framebuffer); 89 gfx_del_framebuffer(framebuffer);
90 return false; 90 return false;
91 } 91 }
@@ -105,7 +105,7 @@ bool gfx_framebuffer_attach_colour(
105 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer->id); 105 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer->id);
106 framebuffer_attach_colour(framebuffer, attachment); 106 framebuffer_attach_colour(framebuffer, attachment);
107 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { 107 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
108 set_error("glCheckFramebufferStatus() failed"); 108 log_error("glCheckFramebufferStatus() failed");
109 return false; 109 return false;
110 } 110 }
111 return true; 111 return true;
@@ -120,7 +120,7 @@ bool gfx_framebuffer_attach_depth(
120 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer->id); 120 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer->id);
121 framebuffer_attach_depth(framebuffer, attachment); 121 framebuffer_attach_depth(framebuffer, attachment);
122 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { 122 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
123 set_error("glCheckFramebufferStatus() failed"); 123 log_error("glCheckFramebufferStatus() failed");
124 return false; 124 return false;
125 } 125 }
126 return true; 126 return true;
diff --git a/gfx/src/render/renderbuffer.c b/gfx/src/render/renderbuffer.c
index 23f9524..2753f3b 100644
--- a/gfx/src/render/renderbuffer.c
+++ b/gfx/src/render/renderbuffer.c
@@ -11,7 +11,7 @@ bool gfx_init_renderbuffer(
11 11
12 glGenRenderbuffers(1, &renderbuffer->id); 12 glGenRenderbuffers(1, &renderbuffer->id);
13 if (!renderbuffer->id) { 13 if (!renderbuffer->id) {
14 set_error("glGenRenderbuffers failed"); 14 log_error("glGenRenderbuffers failed");
15 return false; 15 return false;
16 } 16 }
17 17
@@ -27,7 +27,7 @@ bool gfx_init_renderbuffer(
27 27
28void gfx_del_renderbuffer(RenderBuffer* renderbuffer) { 28void gfx_del_renderbuffer(RenderBuffer* renderbuffer) {
29 assert(renderbuffer); 29 assert(renderbuffer);
30 30
31 if (renderbuffer->id) { 31 if (renderbuffer->id) {
32 glDeleteRenderbuffers(1, &renderbuffer->id); 32 glDeleteRenderbuffers(1, &renderbuffer->id);
33 renderbuffer->id = 0; 33 renderbuffer->id = 0;
diff --git a/gfx/src/scene/light.c b/gfx/src/scene/light.c
index 1046c82..adbec8d 100644
--- a/gfx/src/scene/light.c
+++ b/gfx/src/scene/light.c
@@ -23,7 +23,7 @@ Light* gfx_make_light(const LightDesc* desc) {
23 make_environment_light(light, &desc->light.environment); 23 make_environment_light(light, &desc->light.environment);
24 break; 24 break;
25 default: 25 default:
26 set_error("Unhandled light type"); 26 log_error("Unhandled light type");
27 gfx_destroy_light(&light); 27 gfx_destroy_light(&light);
28 return 0; 28 return 0;
29 } 29 }