mirror of
https://github.com/guezoloic/LearnOpenGL.git
synced 2026-01-25 10:34:16 +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}
|
${OUTPUT_C}
|
||||||
DEPENDS ${SHADER}
|
DEPENDS ${SHADER}
|
||||||
${CMAKE_SOURCE_DIR}/glsl2c.py
|
${CMAKE_SOURCE_DIR}/glsl2c.py
|
||||||
COMMENT "Converting shader ${SHADER} to CPP"
|
COMMENT "Converting shader ${NAME_WE}${EXT} to C file"
|
||||||
VERBATIM
|
VERBATIM
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND SHADER_C_FILES ${OUTPUT_C})
|
list(APPEND SHADER_C_FILES ${OUTPUT_C})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
add_custom_target(Shaders ALL DEPENDS ${SHADER_C_FILES})
|
||||||
|
|
||||||
add_executable(main ${CPP_SOURCES} ${SHADER_C_FILES})
|
add_executable(main ${CPP_SOURCES} ${SHADER_C_FILES})
|
||||||
add_definitions(-g)
|
add_definitions(-g)
|
||||||
|
|
||||||
|
add_dependencies(main Shaders)
|
||||||
|
|
||||||
target_include_directories(main PRIVATE
|
target_include_directories(main PRIVATE
|
||||||
inc # project
|
inc # project
|
||||||
res/render # ressources (primitive)
|
res/render # ressources (primitive)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "GLFW/glfw3.h"
|
#include "GLFW/glfw3.h"
|
||||||
|
|
||||||
constexpr GLfloat P_CUBE_VERTICE[] = {
|
constexpr GLfloat P_CUBE_VERTICE[] = {
|
||||||
// Positions // _LEN;ales // texture coordinate
|
// Positions // normales // texture coordinate
|
||||||
// front side
|
// 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, 0.0f, 0.0f,
|
||||||
0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 1.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
|
22, 23, 20 // 12
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const unsigned char P_CUBE_FRAG[];
|
extern "C" const unsigned char P_CUBE_FRAG[];
|
||||||
extern const unsigned int P_CUBE_FRAG_LEN;
|
extern "C" const unsigned int P_CUBE_FRAG_LEN;
|
||||||
|
extern "C" const unsigned char P_CUBE_VERT[];
|
||||||
extern const unsigned char P_CUBE_VERT[];
|
extern "C" const unsigned int P_CUBE_VERT_LEN;
|
||||||
extern const unsigned int P_CUBE_VERT_LEN;
|
|
||||||
Reference in New Issue
Block a user