mirror of
https://gitea.windcorp.ru/Wind-Corporation/Progressia.git
synced 2025-04-21 16:10:47 +03:00
TMP / assets will be embedded for now
This commit is contained in:
parent
15d41b60bd
commit
9d5ce3dca2
@ -60,6 +60,11 @@ target_sources(progressia PRIVATE
|
|||||||
target_glsl_shaders(progressia
|
target_glsl_shaders(progressia
|
||||||
desktop/graphics/shaders/shader.frag
|
desktop/graphics/shaders/shader.frag
|
||||||
desktop/graphics/shaders/shader.vert)
|
desktop/graphics/shaders/shader.vert)
|
||||||
|
|
||||||
|
target_embeds(progressia
|
||||||
|
assets/texture.png
|
||||||
|
assets/texture2.png)
|
||||||
|
|
||||||
compile_glsl(progressia)
|
compile_glsl(progressia)
|
||||||
compile_embeds(progressia)
|
compile_embeds(progressia)
|
||||||
target_include_directories(progressia PRIVATE ${generated}/embedded_resources)
|
target_include_directories(progressia PRIVATE ${generated}/embedded_resources)
|
||||||
|
@ -63,10 +63,10 @@ void initialize(GraphicsInterface &gintp) {
|
|||||||
debug("game init begin");
|
debug("game init begin");
|
||||||
gint = &gintp;
|
gint = &gintp;
|
||||||
|
|
||||||
texture1.reset(gint->newTexture(
|
texture1.reset(
|
||||||
progressia::main::loadImage(u"../assets/texture.png")));
|
gint->newTexture(progressia::main::loadImage("assets/texture.png")));
|
||||||
texture2.reset(gint->newTexture(
|
texture2.reset(
|
||||||
progressia::main::loadImage(u"../assets/texture2.png")));
|
gint->newTexture(progressia::main::loadImage("assets/texture2.png")));
|
||||||
|
|
||||||
// Cube 1
|
// Cube 1
|
||||||
{
|
{
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#include "stb/stb_image.h"
|
#include "stb/stb_image.h"
|
||||||
|
|
||||||
|
#include <embedded_resources.h>
|
||||||
|
|
||||||
#include "../logging.h"
|
#include "../logging.h"
|
||||||
using namespace progressia::main::logging;
|
using namespace progressia::main::logging;
|
||||||
|
|
||||||
@ -20,23 +22,19 @@ const Image::Byte *Image::getData() const { return data.data(); }
|
|||||||
|
|
||||||
Image::Byte *Image::getData() { return data.data(); }
|
Image::Byte *Image::getData() { return data.data(); }
|
||||||
|
|
||||||
Image loadImage(const std::filesystem::path &path) {
|
Image loadImage(const std::string &path) {
|
||||||
|
|
||||||
std::ifstream file(path, std::ios::ate | std::ios::binary);
|
auto resource = __embedded_resources::getEmbeddedResource(path.c_str());
|
||||||
|
|
||||||
if (!file.is_open()) {
|
if (resource.data == nullptr) {
|
||||||
fatal() << "Could not access a PNG image in file " << path;
|
|
||||||
// REPORT_ERROR
|
// REPORT_ERROR
|
||||||
|
progressia::main::logging::fatal()
|
||||||
|
<< "Could not find resource \"" << path << "\"";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t fileSize = static_cast<std::size_t>(file.tellg());
|
std::vector<Image::Byte> png(resource.data,
|
||||||
std::vector<Image::Byte> png(fileSize);
|
resource.data + resource.length);
|
||||||
|
|
||||||
file.seekg(0);
|
|
||||||
file.read(reinterpret_cast<char *>(png.data()), fileSize);
|
|
||||||
|
|
||||||
file.close();
|
|
||||||
|
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
@ -19,7 +19,7 @@ class Image {
|
|||||||
Byte *getData();
|
Byte *getData();
|
||||||
};
|
};
|
||||||
|
|
||||||
Image loadImage(const std::filesystem::path &);
|
Image loadImage(const std::string &);
|
||||||
|
|
||||||
} // namespace main
|
} // namespace main
|
||||||
} // namespace progressia
|
} // namespace progressia
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
# embed.cmake
|
# embed.cmake
|
||||||
# Generates embedded_resources.h and embedded_resources.cpp
|
# Generates embedded_resources.h and embedded_resources.cpp
|
||||||
|
|
||||||
find_package(Vulkan COMPONENTS glslc REQUIRED)
|
|
||||||
find_program(glslc_EXECUTABLE NAMES glslc HINTS Vulkan::glslc)
|
|
||||||
|
|
||||||
find_package(Python3 COMPONENTS Interpreter REQUIRED)
|
find_package(Python3 COMPONENTS Interpreter REQUIRED)
|
||||||
|
|
||||||
macro (get_target_property_or var target prop default)
|
macro (get_target_property_or var target prop default)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user