Skip to content

Commit ac4ab74

Browse files
committed
Worked on asset shaders
1 parent f9694fe commit ac4ab74

File tree

11 files changed

+551
-357
lines changed

11 files changed

+551
-357
lines changed

CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ option(IGNEOUS_EDITOR "Build editor." ON)
2323
option(IGNEOUS_INSTALL "Install Igneous." OFF)
2424
option(IGNEOUS_SAMPLES "Build samples." ON)
2525
option(IGNEOUS_TESTS "Build tests." ON)
26-
option(IGNEOUS_TOOLS "Build tools." ON)
2726

2827
add_subdirectory(dependencies)
2928

@@ -33,9 +32,7 @@ if(IGNEOUS_DOCS)
3332
add_subdirectory(docs)
3433
endif()
3534

36-
if(IGNEOUS_TOOLS)
37-
add_subdirectory(tools)
38-
endif()
35+
add_subdirectory(tools)
3936

4037
if(IGNEOUS_EDITOR)
4138
add_subdirectory(editor)

igneous/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,15 @@ add_library(igneous STATIC
6565
)
6666

6767
add_asset_shaders(igneous
68-
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/shaders
69-
HEADER src/renderer/igneous_assets.h
68+
HEADER src/renderer/splash_assets.h
7069
SHADERS
7170
shaders/fs_splash.sc
7271
shaders/vs_splash.sc
72+
73+
HEADER src/gui/imgui_assets.h
74+
SHADERS
75+
shaders/fs_imgui.sc
76+
shaders/vs_imgui.sc
7377
)
7478

7579
configure_file (include/igneous/core/version.hpp.in include/igneous/core/version.hpp @ONLY)

igneous/include/igneous/core/igneous.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ class Application
5353

5454
void reset(uint32_t flags = 0);
5555
void setSize(int width, int height);
56-
const char* getTitle() const;
57-
void setTitle(const char* title);
5856

5957
virtual void initialize(int _argc, char** _argv) {};
6058
virtual void update(float dt) {};

igneous/include/igneous/core/input.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,25 @@
88
namespace igneous {
99
namespace input
1010
{
11-
/*! @private */
11+
/*! @cond */
1212
void init(GLFWwindow* window);
13+
/*! @endcond */
1314

1415
/*! Sets the mouse cursor visibility
1516
* \param visible `true` for visible. `false` for hidden.
1617
*/
1718
void setCursorVisible(bool visible);
1819

20+
const char* getTitle();
21+
void setTitle(const char* title);
22+
1923
extern bool keys[GLFW_KEY_LAST + 1];
2024
extern bool mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1];
2125
extern double scrollX, scrollY;
2226
extern double mouseX, mouseY;
2327
extern int width;
2428
extern int height;
29+
extern const char* title;
2530
extern GLFWwindow* window;
2631
}
2732

igneous/src/core/igneous.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@
2727
namespace igneous {
2828
// Application
2929
Application::Application(const char* title, uint32_t width, uint32_t height)
30-
: mTitle(title), mReset(BGFX_RESET_NONE), mWindow(nullptr)
30+
: mReset(BGFX_RESET_NONE), mWindow(nullptr)
3131
{
3232
input::width = width;
3333
input::height = height;
34+
input::title = title;
3435
}
3536

3637
// Input callbacks
@@ -162,7 +163,7 @@ int Application::run(int argc, char** argv, bgfx::RendererType::Enum type, uint1
162163

163164
// Create a window
164165
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
165-
mWindow = glfwCreateWindow(input::width, input::height, mTitle, NULL, NULL);
166+
mWindow = glfwCreateWindow(input::width, input::height, input::title, NULL, NULL);
166167
if (!mWindow)
167168
{
168169
glfwTerminate();
@@ -226,7 +227,7 @@ int Application::run(int argc, char** argv, bgfx::RendererType::Enum type, uint1
226227
RendererSystem::init();
227228
gui::init(mWindow);
228229
Console* console = &Console::getInstance();
229-
input::Init(mWindow);
230+
input::init(mWindow);
230231
console->runFile("startup.cmd");
231232
IG_CORE_INFO("Services Initialized");
232233

@@ -325,15 +326,4 @@ void Application::setSize(int width, int height)
325326
{
326327
glfwSetWindowSize(mWindow, width, height);
327328
}
328-
329-
const char* Application::getTitle() const
330-
{
331-
return mTitle;
332-
}
333-
334-
void Application::setTitle(const char* title)
335-
{
336-
mTitle = title;
337-
glfwSetWindowTitle(mWindow, title);
338-
}
339329
} // end namespace igneous

igneous/src/core/input.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace input
1717
glfwSetWindowShouldClose(window, true);
1818
}
1919

20-
void Init(GLFWwindow* win)
20+
void init(GLFWwindow* win)
2121
{
2222
IG_CORE_INFO("Initializing Input");
2323
window = win;
@@ -41,11 +41,23 @@ namespace input
4141
glfwSetInputMode(window, GLFW_CURSOR, visible ? GLFW_CURSOR_NORMAL : GLFW_CURSOR_DISABLED);
4242
}
4343

44+
const char* getTitle()
45+
{
46+
return title;
47+
}
48+
49+
void setTitle(const char* newTitle)
50+
{
51+
title = newTitle;
52+
glfwSetWindowTitle(window, title);
53+
}
54+
4455
bool keys[GLFW_KEY_LAST + 1] = { 0 };
4556
bool mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1] = { 0 };
4657
double scrollX, scrollY = 0;
4758
double mouseX, mouseY = 0;
4859
int width, height = 0;
60+
const char* title;
4961
GLFWwindow* window = nullptr;
5062
}
5163
} // end namespace igneous

igneous/src/gui/imgui_assets.h

Lines changed: 382 additions & 201 deletions
Large diffs are not rendered by default.

igneous/src/renderer/splash_assets.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// This file is autogenerated.
22

3+
#pragma once
4+
5+
#include <bgfx/bgfx.h>
6+
37
static const int fs_splash_glsl_len = 159;
48
static const unsigned char fs_splash_glsl[] = {
59
0x46,0x53,0x48,0x06,0x6F,0x1E,0x3E,0x3C,0x00,0x00,0x00,0x00,0x01,0x00,0x08,0x73,0x5F,0x73,0x70,0x6C,0x61,0x73,0x68,0x00,0x01,
@@ -185,6 +189,7 @@ static const unsigned char* name() \
185189
case bgfx::RendererType::OpenGLES: return name##_essl; \
186190
case bgfx::RendererType::Gnm: return NULL; \
187191
case bgfx::RendererType::Metal: return name##_metal; \
192+
case bgfx::RendererType::Nvn: return NULL; \
188193
case bgfx::RendererType::Vulkan: return NULL; \
189194
case bgfx::RendererType::Count: return NULL; \
190195
} \
@@ -202,10 +207,12 @@ static const int name##_len() \
202207
case bgfx::RendererType::OpenGLES: return name##_essl_len; \
203208
case bgfx::RendererType::Gnm: return 0; \
204209
case bgfx::RendererType::Metal: return name##_metal_len;\
210+
case bgfx::RendererType::Nvn: return 0; \
205211
case bgfx::RendererType::Vulkan: return 0; \
206212
case bgfx::RendererType::Count: return 0; \
207213
} \
208214
return 0; \
209215
}
210-
_getShader( fs_splash );
211-
_getShader( vs_splash );
216+
217+
_getShader(fs_splash)
218+
_getShader(vs_splash)

tools/asset_gen/CMakeLists.txt

Lines changed: 74 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,98 @@
1-
set(OUTDIR ${CMAKE_CURRENT_BINARY_DIR}/generated)
2-
file(MAKE_DIRECTORY ${OUTDIR})
3-
file(MAKE_DIRECTORY ${OUTDIR}/glsl)
4-
file(MAKE_DIRECTORY ${OUTDIR}/essl)
5-
file(MAKE_DIRECTORY ${OUTDIR}/dx9)
6-
file(MAKE_DIRECTORY ${OUTDIR}/dx11)
7-
file(MAKE_DIRECTORY ${OUTDIR}/metal)
1+
set(ASSET_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated CACHE INTERNAL "")
2+
file(MAKE_DIRECTORY ${ASSET_BINARY_DIR})
3+
file(MAKE_DIRECTORY ${ASSET_BINARY_DIR}/glsl)
4+
file(MAKE_DIRECTORY ${ASSET_BINARY_DIR}/essl)
5+
file(MAKE_DIRECTORY ${ASSET_BINARY_DIR}/dx9)
6+
file(MAKE_DIRECTORY ${ASSET_BINARY_DIR}/dx11)
7+
file(MAKE_DIRECTORY ${ASSET_BINARY_DIR}/metal)
88

9-
macro(asset_shader FILE VAR)
10-
set(ARGS ${ARGN})
11-
set(BASE_OPTIONS FILE ${FILE} INCLUDES ${BGFX_DIR}/src ${ARGS})
12-
list(FIND ARGS VERTEX IND)
13-
if(IND EQUAL -1)
14-
set(TYPE "ps")
15-
else()
16-
set(TYPE "vs")
17-
endif()
9+
macro(add_asset_shaders ARG_TARGET)
10+
if(IGNEOUS_ASSET_GEN)
11+
if(NOT TARGET ${ARG_TARGET})
12+
message(FATAL_ERROR "add_asset_shaders: You must provide a valid target.")
13+
endif()
1814

19-
# glsl
20-
set(OPTIONS ${BASE_OPTIONS} OUTPUT ${OUTDIR}/glsl/${VAR}.bin LINUX PROFILE 120)
21-
shaderc_parse(OUT ${OPTIONS})
22-
list(APPEND ASSET_COMMANDS COMMAND "$<TARGET_FILE:shaderc>" ${OUT})
23-
list(APPEND ASSET_FILES ${OUTDIR}/glsl/${VAR}.bin ${VAR}_glsl)
15+
unset(ASSET_COMMANDS)
2416

25-
# gles
26-
set(OPTIONS ${BASE_OPTIONS} OUTPUT ${OUTDIR}/essl/${VAR}.bin ANDROID PROFILE 120)
27-
shaderc_parse(OUT ${OPTIONS})
28-
list(APPEND ASSET_COMMANDS COMMAND "$<TARGET_FILE:shaderc>" ${OUT})
29-
list(APPEND ASSET_FILES ${OUTDIR}/essl/${VAR}.bin ${VAR}_essl)
17+
#while(condition)
18+
cmake_parse_arguments(ARG "" "HEADER" "SHADERS" ${ARGN})
3019

31-
# dx9
32-
set(OPTIONS ${BASE_OPTIONS} OUTPUT ${OUTDIR}/dx9/${VAR}.bin WINDOWS PROFILE ${TYPE}_3_0)
33-
shaderc_parse(OUT ${OPTIONS})
34-
list(APPEND ASSET_COMMANDS COMMAND "$<TARGET_FILE:shaderc>" ${OUT})
35-
list(APPEND ASSET_FILES ${OUTDIR}/dx9/${VAR}.bin ${VAR}_dx9)
20+
if(NOT ARG_HEADER)
21+
message(FATAL_ERROR "add_asset_shaders: You must provide a header path.")
22+
elseif(NOT ARG_SHADERS)
23+
message(FATAL_ERROR "add_asset_shaders: You must provide shaders.")
24+
endif()
3625

37-
# dx11
38-
set(OPTIONS ${BASE_OPTIONS} OUTPUT ${OUTDIR}/dx11/${VAR}.bin WINDOWS PROFILE ${TYPE}_4_0)
39-
shaderc_parse(OUT ${OPTIONS})
40-
list(APPEND ASSET_COMMANDS COMMAND "$<TARGET_FILE:shaderc>" ${OUT})
41-
list(APPEND ASSET_FILES ${OUTDIR}/dx11/${VAR}.bin ${VAR}_dx11)
26+
unset(ASSET_FILES)
4227

43-
# metal
44-
set(OPTIONS ${BASE_OPTIONS} OUTPUT ${OUTDIR}/metal/${VAR}.bin OSX PROFILE metal)
45-
shaderc_parse(OUT ${OPTIONS})
46-
list(APPEND ASSET_COMMANDS COMMAND "$<TARGET_FILE:shaderc>" ${OUT})
47-
list(APPEND ASSET_FILES ${OUTDIR}/metal/${VAR}.bin ${VAR}_metal)
48-
endmacro()
28+
foreach(SHADER ${ARG_SHADERS})
29+
get_filename_component(SHADER_NAME ${SHADER} NAME_WE)
30+
if(${SHADER_NAME} MATCHES "^vs_")
31+
set(DX_TYPE "vs")
32+
set(TYPE "VERTEX")
33+
elseif(${SHADER_NAME} MATCHES "^fs_")
34+
set(DX_TYPE "ps")
35+
set(TYPE "FRAGMENT")
36+
else()
37+
message(FATAL_ERROR "add_asset_shaders: Unknown shader type: ${SHADER_NAME}")
38+
endif()
39+
set(BASE_OPTIONS FILE ${SHADER} INCLUDES ${BGFX_DIR}/src ${TYPE})
4940

50-
macro(asset FILE VAR)
51-
list(APPEND ASSET_FILES ${FILE} ${VAR})
52-
endmacro()
41+
# glsl
42+
set(OPTIONS ${BASE_OPTIONS} OUTPUT ${ASSET_BINARY_DIR}/glsl/${SHADER_NAME}.bin LINUX PROFILE 120)
43+
shaderc_parse(OUT ${OPTIONS})
44+
list(APPEND ASSET_COMMANDS COMMAND "$<TARGET_FILE:shaderc>" ${OUT})
45+
list(APPEND ASSET_FILES ${ASSET_BINARY_DIR}/glsl/${SHADER_NAME}.bin ${SHADER_NAME}_glsl)
5346

54-
macro(add_asset_shaders ARG_TARGET)
55-
if(IGNEOUS_ASSET_GEN)
56-
cmake_parse_arguments(ARG "" "OUTPUT;HEADER" "SHADERS" ${ARGN})
47+
# gles
48+
set(OPTIONS ${BASE_OPTIONS} OUTPUT ${ASSET_BINARY_DIR}/essl/${SHADER_NAME}.bin ANDROID PROFILE 120)
49+
shaderc_parse(OUT ${OPTIONS})
50+
list(APPEND ASSET_COMMANDS COMMAND "$<TARGET_FILE:shaderc>" ${OUT})
51+
list(APPEND ASSET_FILES ${ASSET_BINARY_DIR}/essl/${SHADER_NAME}.bin ${SHADER_NAME}_essl)
5752

58-
if(NOT TARGET ${ARG_TARGET})
59-
message(FATAL_ERROR "add_shaders: You must provide a valid target.")
60-
elseif(NOT ARG_OUTPUT)
61-
message(FATAL_ERROR "add_shaders: You must provide an output directory.")
62-
elseif(NOT ARG_HEADER)
63-
message(FATAL_ERROR "add_shaders: You must provide a header path.")
64-
elseif(NOT ARG_SHADERS)
65-
message(FATAL_ERROR "add_shaders: You must provide shaders.")
66-
endif()
53+
# dx9
54+
set(OPTIONS ${BASE_OPTIONS} OUTPUT ${ASSET_BINARY_DIR}/dx9/${SHADER_NAME}.bin WINDOWS PROFILE ${DX_TYPE}_3_0)
55+
shaderc_parse(OUT ${OPTIONS})
56+
list(APPEND ASSET_COMMANDS COMMAND "$<TARGET_FILE:shaderc>" ${OUT})
57+
list(APPEND ASSET_FILES ${ASSET_BINARY_DIR}/dx9/${SHADER_NAME}.bin ${SHADER_NAME}_dx9)
6758

68-
foreach(SHADER ${ARG_SHADERS})
69-
get_filename_component(SHADER_NAME ${SHADER} NAME_WE)
70-
if(${SHADER_NAME} MATCHES "^vs_")
71-
asset_shader(${SHADER} ${SHADER_NAME} VERTEX)
72-
elseif(${SHADER_NAME} MATCHES "^fs_")
73-
asset_shader(${SHADER} ${SHADER_NAME} FRAGMENT)
74-
endif()
75-
endforeach()
59+
# dx11
60+
set(OPTIONS ${BASE_OPTIONS} OUTPUT ${ASSET_BINARY_DIR}/dx11/${SHADER_NAME}.bin WINDOWS PROFILE ${DX_TYPE}_4_0)
61+
shaderc_parse(OUT ${OPTIONS})
62+
list(APPEND ASSET_COMMANDS COMMAND "$<TARGET_FILE:shaderc>" ${OUT})
63+
list(APPEND ASSET_FILES ${ASSET_BINARY_DIR}/dx11/${SHADER_NAME}.bin ${SHADER_NAME}_dx11)
7664

77-
if(NOT EXISTS ${ARG_HEADER})
78-
file(WRITE ${ARG_HEADER})
79-
endif()
65+
# metal
66+
set(OPTIONS ${BASE_OPTIONS} OUTPUT ${ASSET_BINARY_DIR}/metal/${SHADER_NAME}.bin OSX PROFILE metal)
67+
shaderc_parse(OUT ${OPTIONS})
68+
list(APPEND ASSET_COMMANDS COMMAND "$<TARGET_FILE:shaderc>" ${OUT})
69+
list(APPEND ASSET_FILES ${ASSET_BINARY_DIR}/metal/${SHADER_NAME}.bin ${SHADER_NAME}_metal)
70+
endforeach()
71+
72+
if(NOT EXISTS ${ARG_HEADER})
73+
file(WRITE ${ARG_HEADER})
74+
endif()
8075

76+
list(APPEND ASSET_COMMANDS COMMAND "$<TARGET_FILE:bin2c>" ${ARG_HEADER} ${ASSET_FILES})
77+
#endwhile()
78+
8179
add_custom_target(
8280
${ARG_TARGET}_assets ALL
8381
${ASSET_COMMANDS}
84-
COMMAND "$<TARGET_FILE:bin2c>" ${ARG_HEADER} ${ASSET_FILES}
8582
DEPENDS shaderc
8683
DEPENDS bin2c
8784
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
8885
)
89-
90-
set_target_properties(${ARG_TARGET}_assets PROPERTIES FOLDER "assets")
86+
set_target_properties(${ARG_TARGET}_assets PROPERTIES FOLDER "assets" )
9187
add_dependencies(${ARG_TARGET} ${ARG_TARGET}_assets)
9288
endif()
9389
endmacro()
9490

95-
add_executable(bin2c
96-
bin2c.cpp
97-
)
91+
if(IGNEOUS_ASSET_GEN)
92+
add_executable(bin2c
93+
bin2c.cpp
94+
strings.h
95+
)
9896

99-
set_target_properties(bin2c PROPERTIES FOLDER "assets")
97+
set_target_properties(bin2c PROPERTIES FOLDER "assets")
98+
endif()

0 commit comments

Comments
 (0)