mirror of
https://github.com/guezoloic/LearnOpenGL.git
synced 2026-01-25 01:34:15 +00:00
fix: use extern "C" and ensure shaders are built before main
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
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;
|
||||
Reference in New Issue
Block a user