Better handle errors
This commit is contained in:
parent
2480fa80ef
commit
e4b01079f0
2 changed files with 12 additions and 6 deletions
16
main.c
16
main.c
|
@ -3,8 +3,8 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "shaders.h"
|
||||
#include "renderer.h"
|
||||
#include "shaders.h"
|
||||
|
||||
#define WINDOW_WIDTH 800
|
||||
#define WINDOW_HEIGHT 600
|
||||
|
@ -13,15 +13,21 @@
|
|||
|
||||
int main() {
|
||||
GLFWwindow *window = initialize_window(WINDOW_WIDTH, WINDOW_HEIGHT);
|
||||
if (window == NULL) {
|
||||
glfwTerminate();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
unsigned int VAO = initialize_vertices();
|
||||
|
||||
unsigned int shader_program = glCreateProgram();
|
||||
int result = compile_shaders(&shader_program, FRAGMENT_SHADER_FILE);
|
||||
if (!shader_program || result) {
|
||||
log_error("Could not compile shaders");
|
||||
if (!shader_program) {
|
||||
log_error("Could not create shader program");
|
||||
glfwDestroyWindow(window);
|
||||
glfwTerminate();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
compile_shaders(&shader_program, FRAGMENT_SHADER_FILE);
|
||||
|
||||
/* Drawing loop */
|
||||
size_t frame = 0;
|
||||
|
@ -65,7 +71,7 @@ int main() {
|
|||
frame++;
|
||||
}
|
||||
|
||||
glfwDestroyWindow(window);
|
||||
glfwTerminate();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
*
|
||||
* @param width The width of the window to create.
|
||||
* @param height The height of the window to create.
|
||||
* @return A pointer to the newly created GLFW window.
|
||||
* @return A pointer to the newly created GLFW window, or `NULL` on error.
|
||||
*/
|
||||
GLFWwindow *initialize_window(int width, int height) {
|
||||
/* Initialize GLFW */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue