Skip to content

Commit 00ab6d9

Browse files
committed
engine: embed media files
1 parent e71268a commit 00ab6d9

File tree

7 files changed

+19
-0
lines changed

7 files changed

+19
-0
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,9 @@ if (BUILD_CLIENT)
10391039

10401040
# Generate GLSL include files.
10411041
daemon_embed_files("EngineShaders" "GLSL")
1042+
1043+
# Generate media include files.
1044+
daemon_embed_files("EngineMedia" "MEDIA")
10421045
endif()
10431046

10441047
if (BUILD_SERVER)

src.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ else()
8686
include (${ENGINE_DIR}/renderer/src.cmake)
8787
endif()
8888

89+
set(MEDIA_EMBED_DIR ${ENGINE_DIR}/media)
90+
set(MEDIA_EMBED_LIST
91+
gfx/2d/bigchars.png
92+
scripts/engine.shader
93+
sound/null.wav
94+
)
95+
8996
set(GLSL_EMBED_DIR "${ENGINE_DIR}/renderer/glsl_source")
9097
set(GLSL_EMBED_LIST
9198
# Common shader libraries

src/common/FileSystem.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3636
#include "shared/VMMain.h"
3737
#else
3838
#include "engine/qcommon/qcommon.h"
39+
#include "DaemonEmbedded/EngineMedia.h"
3940
#endif
4041

4142
#include "IPC/CommonSyscalls.h"
@@ -1542,6 +1543,12 @@ std::string ReadFile(Str::StringRef path, std::error_code& err) {
15421543
#ifdef BUILD_ENGINE
15431544
std::string ReadFile(Str::StringRef path, std::error_code& err)
15441545
{
1546+
if (EngineMedia::HasFile(path))
1547+
{
1548+
Log::Warn("Loading internal file: %s", path);
1549+
return EngineMedia::ReadFile(path);
1550+
}
1551+
15451552
auto it = fileMap.find(path);
15461553
if (it == fileMap.end()) {
15471554
SetErrorCodeFilesystem(err, filesystem_error::no_such_file, path);
File renamed without changes.
File renamed without changes.

src/engine/renderer/src.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

22
set(RENDERERLIST
3+
${DAEMON_EMBEDDED_DIR}/EngineMedia.cpp
4+
${DAEMON_EMBEDDED_DIR}/EngineMedia.h
35
${DAEMON_EMBEDDED_DIR}/EngineShaders.cpp
46
${DAEMON_EMBEDDED_DIR}/EngineShaders.h
57
${ENGINE_DIR}/renderer/BufferBind.h

0 commit comments

Comments
 (0)