From 3698f3b2e548af6e65b19594ef0d8b3ef95fa12f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20GUEZO?= Date: Sat, 3 Jan 2026 18:41:41 +0100 Subject: [PATCH] fix: use `extern "C"` and ensure shaders are built before main --- CMakeLists.txt | 6 +++++- res/render/primitives/p_cube.hpp | 11 +++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 30e583f..e3838aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,16 +36,20 @@ foreach(SHADER ${SHADERS}) ${OUTPUT_C} DEPENDS ${SHADER} ${CMAKE_SOURCE_DIR}/glsl2c.py - COMMENT "Converting shader ${SHADER} to CPP" + COMMENT "Converting shader ${NAME_WE}${EXT} to C file" VERBATIM ) list(APPEND SHADER_C_FILES ${OUTPUT_C}) endforeach() +add_custom_target(Shaders ALL DEPENDS ${SHADER_C_FILES}) + add_executable(main ${CPP_SOURCES} ${SHADER_C_FILES}) add_definitions(-g) +add_dependencies(main Shaders) + target_include_directories(main PRIVATE inc # project res/render # ressources (primitive) diff --git a/res/render/primitives/p_cube.hpp b/res/render/primitives/p_cube.hpp index d57c564..643ac4d 100644 --- a/res/render/primitives/p_cube.hpp +++ b/res/render/primitives/p_cube.hpp @@ -1,7 +1,7 @@ #include "GLFW/glfw3.h" constexpr GLfloat P_CUBE_VERTICE[] = { - // Positions // _LEN;ales // texture coordinate + // Positions // normales // texture coordinate // front side -0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, @@ -59,8 +59,7 @@ constexpr unsigned int P_CUBE_INDICE[] = { 22, 23, 20 // 12 }; -extern const unsigned char P_CUBE_FRAG[]; -extern const unsigned int P_CUBE_FRAG_LEN; - -extern const unsigned char P_CUBE_VERT[]; -extern const unsigned int P_CUBE_VERT_LEN; \ No newline at end of file +extern "C" const unsigned char P_CUBE_FRAG[]; +extern "C" const unsigned int P_CUBE_FRAG_LEN; +extern "C" const unsigned char P_CUBE_VERT[]; +extern "C" const unsigned int P_CUBE_VERT_LEN; \ No newline at end of file