argv[0] to resource manager, building with clang
This commit is contained in:
parent
82187b9005
commit
147bd4a206
|
@ -73,13 +73,13 @@
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
<PlatformToolset>ClangCL</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
<PlatformToolset>ClangCL</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "resource_manager.h"
|
#include "resource_manager.h"
|
||||||
|
|
||||||
struct game {
|
struct game {
|
||||||
game();
|
game(int argc, char* argv[]);
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
virtual void init(settings& settings);
|
virtual void init(settings& settings);
|
||||||
|
@ -22,6 +22,8 @@ private:
|
||||||
image const* _cursor;
|
image const* _cursor;
|
||||||
resource_manager _rm;
|
resource_manager _rm;
|
||||||
int _fps;
|
int _fps;
|
||||||
|
int _argc;
|
||||||
|
char** _argv;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct resource_manager {
|
struct resource_manager {
|
||||||
resource_manager();
|
resource_manager(int argc, char** argv);
|
||||||
|
|
||||||
void mount(std::string const& path, std::string const& mounting_point);
|
void mount(std::string const& path, std::string const& mounting_point);
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
@ -28,8 +28,8 @@ font::font(resource_manager& rm, ini_category const* ini, std::string const& pat
|
||||||
_glyphs.at(ch).draw(image, vec2i::zero, r);
|
_glyphs.at(ch).draw(image, vec2i::zero, r);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int width = ini->get<int>("width");
|
int width = ini->get<int>("tile_width");
|
||||||
int height = ini->get<int>("height");
|
int height = ini->get<int>("tile_height");
|
||||||
auto ts = rm.get<tileset>(path);
|
auto ts = rm.get<tileset>(path);
|
||||||
_lineheight = ts->_tile_size.y;
|
_lineheight = ts->_tile_size.y;
|
||||||
for(int i = 0; i < 256; ++i) {
|
for(int i = 0; i < 256; ++i) {
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <format>
|
#include <format>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <SDL3/SDL.h>
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
@ -18,12 +17,14 @@ LRESULT WINAPI wnd_proc(HWND window, UINT msg, WPARAM w, LPARAM l) {
|
||||||
return ::DefWindowProc(window, msg, w, l);
|
return ::DefWindowProc(window, msg, w, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
game::game() : _cursor(0) {
|
game::game(int argc, char** argv) : _cursor(0), _argc(argc), _argv(argv), _rm(argc, argv) {
|
||||||
|
std::cout << "a\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void play_logo(HWND window, image const* logo, image const* logo_slime);
|
void play_logo(HWND window, image const* logo, image const* logo_slime);
|
||||||
|
|
||||||
void game::run() {
|
void game::run() {
|
||||||
|
std::cout << "a\n";
|
||||||
settings settings;
|
settings settings;
|
||||||
init(settings);
|
init(settings);
|
||||||
auto title = std::wstring(settings.title.begin(), settings.title.end());
|
auto title = std::wstring(settings.title.begin(), settings.title.end());
|
||||||
|
|
|
@ -6,14 +6,17 @@
|
||||||
#define BP_INSER_RESOURCES
|
#define BP_INSER_RESOURCES
|
||||||
#include "system_assets.h"
|
#include "system_assets.h"
|
||||||
|
|
||||||
resource_manager::resource_manager() {
|
resource_manager::resource_manager(int argc, char** argv) {
|
||||||
PHYSFS_init(0);
|
if(!PHYSFS_init(argv[0]))
|
||||||
|
throw std::runtime_error(std::format("physfs error: {}", PHYSFS_getLastError()));
|
||||||
mount("assets", "/");
|
mount("assets", "/");
|
||||||
PHYSFS_mountMemory(BP_system_assets, sizeof(BP_system_assets), 0, "system-assets", "/", 0);
|
if(!PHYSFS_mountMemory(BP_system_assets, sizeof(BP_system_assets), 0, "system-assets", "/", 0))
|
||||||
|
throw std::runtime_error(std::format("physfs error: {}", PHYSFS_getLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void resource_manager::mount(std::string const& path, std::string const& mounting_point) {
|
void resource_manager::mount(std::string const& path, std::string const& mounting_point) {
|
||||||
PHYSFS_mount(path.c_str(), mounting_point.c_str(), 0);
|
if(!PHYSFS_mount(path.c_str(), mounting_point.c_str(), 0))
|
||||||
|
throw std::runtime_error(std::format("physfs error: {}", PHYSFS_getLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<uint8_t> resource_manager::read(std::filesystem::path const& path) {
|
std::vector<uint8_t> resource_manager::read(std::filesystem::path const& path) {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "bloob.h"
|
#include "bloob.h"
|
||||||
|
|
||||||
struct my_game : game {
|
struct my_game : game {
|
||||||
|
my_game(int argc, char** argv) : game(argc, argv) {}
|
||||||
void init(settings& settings);
|
void init(settings& settings);
|
||||||
void update();
|
void update();
|
||||||
void render(image& target);
|
void render(image& target);
|
||||||
|
@ -79,7 +80,7 @@ void my_game::render(image& target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
my_game game;
|
my_game game(argc, argv);
|
||||||
game.run();
|
game.run();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,13 +42,13 @@
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
<PlatformToolset>ClangCL</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
<PlatformToolset>ClangCL</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
Loading…
Reference in New Issue