Rename File -> file and move under the prism namespace
This commit is contained in:
parent
ee2771f45f
commit
01966c1d81
33 changed files with 186 additions and 186 deletions
|
@ -11,28 +11,28 @@
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
template <>
|
template <>
|
||||||
struct hash<file::Path> {
|
struct hash<prism::Path> {
|
||||||
std::size_t operator()(const file::Path& k) const {
|
std::size_t operator()(const prism::Path& k) const {
|
||||||
return (std::hash<std::string>()(k.string()));
|
return (std::hash<std::string>()(k.string()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::unique_ptr<T> load_asset(const file::Path p);
|
std::unique_ptr<T> load_asset(const prism::Path p);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool can_load_asset(const file::Path p);
|
bool can_load_asset(const prism::Path p);
|
||||||
|
|
||||||
template<class AssetType>
|
template<class AssetType>
|
||||||
using AssetStore = std::unordered_map<file::Path, std::unique_ptr<AssetType>>;
|
using AssetStore = std::unordered_map<prism::Path, std::unique_ptr<AssetType>>;
|
||||||
|
|
||||||
template<class... Assets>
|
template<class... Assets>
|
||||||
class AssetPool : public AssetStore<Assets>... {
|
class AssetPool : public AssetStore<Assets>... {
|
||||||
public:
|
public:
|
||||||
template<typename T>
|
template<typename T>
|
||||||
AssetPtr<T> add() {
|
AssetPtr<T> add() {
|
||||||
const auto p = file::Path();
|
const auto p = prism::Path();
|
||||||
auto reference_block = get_reference_block(p);
|
auto reference_block = get_reference_block(p);
|
||||||
|
|
||||||
AssetStore<T>::try_emplace(p, std::make_unique<T>());
|
AssetStore<T>::try_emplace(p, std::make_unique<T>());
|
||||||
|
@ -41,7 +41,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
AssetPtr<T> get(const file::Path path) {
|
AssetPtr<T> get(const prism::Path path) {
|
||||||
return fetch<T>(path, get_reference_block(path));
|
return fetch<T>(path, get_reference_block(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,14 +58,14 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
AssetPtr<T> fetch(const file::Path path, ReferenceBlock* reference_block) {
|
AssetPtr<T> fetch(const prism::Path path, ReferenceBlock* reference_block) {
|
||||||
if(!AssetStore<T>::count(path))
|
if(!AssetStore<T>::count(path))
|
||||||
AssetStore<T>::try_emplace(path, load_asset<T>(path));
|
AssetStore<T>::try_emplace(path, load_asset<T>(path));
|
||||||
|
|
||||||
return AssetPtr<T>(AssetStore<T>::at(path).get(), reference_block);
|
return AssetPtr<T>(AssetStore<T>::at(path).get(), reference_block);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::tuple<Asset*, ReferenceBlock*> load_asset_generic(const file::Path path) {
|
std::tuple<Asset*, ReferenceBlock*> load_asset_generic(const prism::Path path) {
|
||||||
Asset* asset = nullptr;
|
Asset* asset = nullptr;
|
||||||
ReferenceBlock* block = nullptr;
|
ReferenceBlock* block = nullptr;
|
||||||
|
|
||||||
|
@ -88,10 +88,10 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_map<file::Path, std::unique_ptr<ReferenceBlock>> reference_blocks;
|
std::unordered_map<prism::Path, std::unique_ptr<ReferenceBlock>> reference_blocks;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ReferenceBlock* get_reference_block(const file::Path path) {
|
ReferenceBlock* get_reference_block(const prism::Path path) {
|
||||||
if(!reference_blocks.count(path))
|
if(!reference_blocks.count(path))
|
||||||
reference_blocks.try_emplace(path, std::make_unique<ReferenceBlock>());
|
reference_blocks.try_emplace(path, std::make_unique<ReferenceBlock>());
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void load_asset_generic(const file::Path path, Asset*& at, ReferenceBlock*& block) {
|
void load_asset_generic(const prism::Path path, Asset*& at, ReferenceBlock*& block) {
|
||||||
if(can_load_asset<T>(path)) {
|
if(can_load_asset<T>(path)) {
|
||||||
if(!AssetStore<T>::count(path))
|
if(!AssetStore<T>::count(path))
|
||||||
AssetStore<T>::try_emplace(path, load_asset<T>(path));
|
AssetStore<T>::try_emplace(path, load_asset<T>(path));
|
||||||
|
@ -110,7 +110,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void delete_asset(const file::Path path) {
|
void delete_asset(const prism::Path path) {
|
||||||
auto iter = AssetStore<T>::find(path);
|
auto iter = AssetStore<T>::find(path);
|
||||||
if(iter != AssetStore<T>::end()) {
|
if(iter != AssetStore<T>::end()) {
|
||||||
auto& [_, asset] = *iter;
|
auto& [_, asset] = *iter;
|
||||||
|
@ -126,14 +126,14 @@ using AssetManager = AssetPool<Mesh, Material, Texture>;
|
||||||
|
|
||||||
inline std::unique_ptr<AssetManager> assetm;
|
inline std::unique_ptr<AssetManager> assetm;
|
||||||
|
|
||||||
std::unique_ptr<Mesh> load_mesh(const file::Path path);
|
std::unique_ptr<Mesh> load_mesh(const prism::Path path);
|
||||||
std::unique_ptr<Material> load_material(const file::Path path);
|
std::unique_ptr<Material> load_material(const prism::Path path);
|
||||||
std::unique_ptr<Texture> load_texture(const file::Path path);
|
std::unique_ptr<Texture> load_texture(const prism::Path path);
|
||||||
|
|
||||||
void save_material(Material* material, const file::Path path);
|
void save_material(Material* material, const prism::Path path);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::unique_ptr<T> load_asset(const file::Path path) {
|
std::unique_ptr<T> load_asset(const prism::Path path) {
|
||||||
if constexpr (std::is_same_v<T, Mesh>) {
|
if constexpr (std::is_same_v<T, Mesh>) {
|
||||||
return load_mesh(path);
|
return load_mesh(path);
|
||||||
} else if constexpr(std::is_same_v<T, Material>) {
|
} else if constexpr(std::is_same_v<T, Material>) {
|
||||||
|
@ -144,7 +144,7 @@ std::unique_ptr<T> load_asset(const file::Path path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool can_load_asset(const file::Path path) {
|
bool can_load_asset(const prism::Path path) {
|
||||||
if constexpr(std::is_same_v<T, Mesh>) {
|
if constexpr(std::is_same_v<T, Mesh>) {
|
||||||
return path.extension() == ".model";
|
return path.extension() == ".model";
|
||||||
} else if constexpr(std::is_same_v<T, Material>) {
|
} else if constexpr(std::is_same_v<T, Material>) {
|
||||||
|
|
|
@ -15,10 +15,10 @@
|
||||||
#include "physics.hpp"
|
#include "physics.hpp"
|
||||||
#include "imgui_backend.hpp"
|
#include "imgui_backend.hpp"
|
||||||
|
|
||||||
std::unique_ptr<Mesh> load_mesh(const file::Path path) {
|
std::unique_ptr<Mesh> load_mesh(const prism::Path path) {
|
||||||
Expects(!path.empty());
|
Expects(!path.empty());
|
||||||
|
|
||||||
auto file = file::open(path, true);
|
auto file = prism::open_file(path, true);
|
||||||
if(!file.has_value()) {
|
if(!file.has_value()) {
|
||||||
prism::log::error(System::Renderer, "Failed to load mesh from {}!", path);
|
prism::log::error(System::Renderer, "Failed to load mesh from {}!", path);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -185,10 +185,10 @@ std::unique_ptr<Mesh> load_mesh(const file::Path path) {
|
||||||
return mesh;
|
return mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Texture> load_texture(const file::Path path) {
|
std::unique_ptr<Texture> load_texture(const prism::Path path) {
|
||||||
Expects(!path.empty());
|
Expects(!path.empty());
|
||||||
|
|
||||||
auto file = file::open(path, true);
|
auto file = prism::open_file(path, true);
|
||||||
if(!file.has_value()) {
|
if(!file.has_value()) {
|
||||||
prism::log::error(System::Renderer, "Failed to load texture from {}!", path);
|
prism::log::error(System::Renderer, "Failed to load texture from {}!", path);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -242,10 +242,10 @@ std::unique_ptr<Texture> load_texture(const file::Path path) {
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Material> load_material(const file::Path path) {
|
std::unique_ptr<Material> load_material(const prism::Path path) {
|
||||||
Expects(!path.empty());
|
Expects(!path.empty());
|
||||||
|
|
||||||
auto file = file::open(path);
|
auto file = prism::open_file(path);
|
||||||
if(!file.has_value()) {
|
if(!file.has_value()) {
|
||||||
prism::log::error(System::Core, "Failed to load material from {}!", path);
|
prism::log::error(System::Core, "Failed to load material from {}!", path);
|
||||||
return {};
|
return {};
|
||||||
|
@ -287,7 +287,7 @@ std::unique_ptr<Material> load_material(const file::Path path) {
|
||||||
p.float_value = property["float_value"];
|
p.float_value = property["float_value"];
|
||||||
|
|
||||||
if(!property["asset_value"].get<std::string>().empty()) {
|
if(!property["asset_value"].get<std::string>().empty()) {
|
||||||
p.value_tex = assetm->get<Texture>(file::app_domain / property["asset_value"].get<std::string>());
|
p.value_tex = assetm->get<Texture>(prism::app_domain / property["asset_value"].get<std::string>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -331,7 +331,7 @@ std::unique_ptr<Material> load_material(const file::Path path) {
|
||||||
return mat;
|
return mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
void save_material(Material* material, const file::Path path) {
|
void save_material(Material* material, const prism::Path path) {
|
||||||
Expects(material != nullptr);
|
Expects(material != nullptr);
|
||||||
Expects(!path.empty());
|
Expects(!path.empty());
|
||||||
|
|
||||||
|
|
|
@ -8,5 +8,5 @@
|
||||||
namespace audio {
|
namespace audio {
|
||||||
void initialize();
|
void initialize();
|
||||||
|
|
||||||
void play_file(const file::Path path, const float gain = 1.0f);
|
void play_file(const prism::Path path, const float gain = 1.0f);
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,8 +77,8 @@ void audio::initialize() {
|
||||||
Pa_StartStream(stream);
|
Pa_StartStream(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio::play_file(const file::Path path, const float gain) {
|
void audio::play_file(const prism::Path path, const float gain) {
|
||||||
auto audio_file = file::open(path);
|
auto audio_file = prism::open_file(path);
|
||||||
if(audio_file == std::nullopt)
|
if(audio_file == std::nullopt)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,7 @@ namespace prism {
|
||||||
@param path The scene file path.
|
@param path The scene file path.
|
||||||
@return Returns a instance of the scene is successful, and nullptr on failure.
|
@return Returns a instance of the scene is successful, and nullptr on failure.
|
||||||
*/
|
*/
|
||||||
Scene* load_scene(const file::Path& path);
|
Scene* load_scene(const prism::Path& path);
|
||||||
|
|
||||||
/** Save the current scene to disk.
|
/** Save the current scene to disk.
|
||||||
@param path The absolute file path.
|
@param path The absolute file path.
|
||||||
|
@ -145,7 +145,7 @@ namespace prism {
|
||||||
@param path The screen file path.
|
@param path The screen file path.
|
||||||
@return Returns a instance of the screen if successful, and nullptr on failure.
|
@return Returns a instance of the screen if successful, and nullptr on failure.
|
||||||
*/
|
*/
|
||||||
ui::Screen* load_screen(const file::Path& path);
|
ui::Screen* load_screen(const prism::Path& path);
|
||||||
|
|
||||||
/** Set the current screen.
|
/** Set the current screen.
|
||||||
@param screen The screen object to set as current. Can be null.
|
@param screen The screen object to set as current. Can be null.
|
||||||
|
@ -162,7 +162,7 @@ namespace prism {
|
||||||
@param path The prefab file path.
|
@param path The prefab file path.
|
||||||
@param override_name If not empty, the root object's new name. Defaulted to a empty string.
|
@param override_name If not empty, the root object's new name. Defaulted to a empty string.
|
||||||
*/
|
*/
|
||||||
Object add_prefab(Scene& scene, const file::Path& path, std::string_view override_name = "");
|
Object add_prefab(Scene& scene, const prism::Path& path, std::string_view override_name = "");
|
||||||
|
|
||||||
/** Save a tree of objects as a prefab to disk.
|
/** Save a tree of objects as a prefab to disk.
|
||||||
@param root The parent object to save as a prefab.
|
@param root The parent object to save as a prefab.
|
||||||
|
@ -180,12 +180,12 @@ namespace prism {
|
||||||
@param path The animation file path.
|
@param path The animation file path.
|
||||||
@return An animation.
|
@return An animation.
|
||||||
*/
|
*/
|
||||||
Animation load_animation(const file::Path& path);
|
Animation load_animation(const prism::Path& path);
|
||||||
|
|
||||||
/** Load a cutscene from disk. This changes the current cutscene.
|
/** Load a cutscene from disk. This changes the current cutscene.
|
||||||
@param path The cutscene file path.
|
@param path The cutscene file path.
|
||||||
*/
|
*/
|
||||||
void load_cutscene(const file::Path& path);
|
void load_cutscene(const prism::Path& path);
|
||||||
|
|
||||||
/** Saves the current cutscene to disk.
|
/** Saves the current cutscene to disk.
|
||||||
@param path The absolute file path.
|
@param path The absolute file path.
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace ui {
|
||||||
class Screen {
|
class Screen {
|
||||||
public:
|
public:
|
||||||
Screen() {}
|
Screen() {}
|
||||||
Screen(const file::Path path);
|
Screen(const prism::Path path);
|
||||||
|
|
||||||
void process_event(const std::string& type, std::string data = "");
|
void process_event(const std::string& type, std::string data = "");
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,7 @@ void draw_shader_editor() {
|
||||||
if(ImGui::Button("Select Path")) {
|
if(ImGui::Button("Select Path")) {
|
||||||
platform::open_dialog(false, [](std::string path) {
|
platform::open_dialog(false, [](std::string path) {
|
||||||
// open_dialog() can't select folders yet, so use this as a workaround
|
// open_dialog() can't select folders yet, so use this as a workaround
|
||||||
options.shader_source_path = file::Path(path).parent_path().string();
|
options.shader_source_path = prism::Path(path).parent_path().string();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -186,13 +186,13 @@ void draw_shader_editor() {
|
||||||
|
|
||||||
if(!selected_shader.empty()) {
|
if(!selected_shader.empty()) {
|
||||||
if(loaded_shader_string.empty()) {
|
if(loaded_shader_string.empty()) {
|
||||||
file::Path base_shader_path = options.shader_source_path;
|
prism::Path base_shader_path = options.shader_source_path;
|
||||||
|
|
||||||
shader_compiler.set_include_path(base_shader_path.string());
|
shader_compiler.set_include_path(base_shader_path.string());
|
||||||
|
|
||||||
file::Path shader_path = file::Path(selected_shader);
|
prism::Path shader_path = prism::Path(selected_shader);
|
||||||
|
|
||||||
auto file = file::open(base_shader_path / shader_path.replace_extension(shader_path.extension().string() + ".glsl"));
|
auto file = prism::open_file(base_shader_path / shader_path.replace_extension(shader_path.extension().string() + ".glsl"));
|
||||||
|
|
||||||
loaded_shader_string = file->read_as_string();
|
loaded_shader_string = file->read_as_string();
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ prism::app* engine::get_app() const {
|
||||||
void engine::load_localization(const std::string_view path) {
|
void engine::load_localization(const std::string_view path) {
|
||||||
Expects(!path.empty());
|
Expects(!path.empty());
|
||||||
|
|
||||||
auto file = file::open(file::app_domain / path);
|
auto file = prism::open_file(prism::app_domain / path);
|
||||||
if(file.has_value()) {
|
if(file.has_value()) {
|
||||||
nlohmann::json j;
|
nlohmann::json j;
|
||||||
file->read_as_stream() >> j;
|
file->read_as_stream() >> j;
|
||||||
|
@ -131,10 +131,10 @@ void engine::create_empty_scene() {
|
||||||
current_scene = scenes.back().get();
|
current_scene = scenes.back().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
Scene* engine::load_scene(const file::Path& path) {
|
Scene* engine::load_scene(const prism::Path& path) {
|
||||||
Expects(!path.empty());
|
Expects(!path.empty());
|
||||||
|
|
||||||
auto file = file::open(path);
|
auto file = prism::open_file(path);
|
||||||
if(!file.has_value()) {
|
if(!file.has_value()) {
|
||||||
prism::log::error(System::Core, "Failed to load scene from {}!", path);
|
prism::log::error(System::Core, "Failed to load scene from {}!", path);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -149,7 +149,7 @@ Scene* engine::load_scene(const file::Path& path) {
|
||||||
|
|
||||||
for(auto& obj : j["objects"]) {
|
for(auto& obj : j["objects"]) {
|
||||||
if(obj.contains("prefabPath")) {
|
if(obj.contains("prefabPath")) {
|
||||||
Object o = add_prefab(*scene, file::app_domain / obj["prefabPath"].get<std::string_view>());
|
Object o = add_prefab(*scene, prism::app_domain / obj["prefabPath"].get<std::string_view>());
|
||||||
|
|
||||||
scene->get(o).name = obj["name"];
|
scene->get(o).name = obj["name"];
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ void engine::save_scene(const std::string_view path) {
|
||||||
out << j;
|
out << j;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui::Screen* engine::load_screen(const file::Path& path) {
|
ui::Screen* engine::load_screen(const prism::Path& path) {
|
||||||
Expects(!path.empty());
|
Expects(!path.empty());
|
||||||
|
|
||||||
return new ui::Screen(path);
|
return new ui::Screen(path);
|
||||||
|
@ -224,10 +224,10 @@ AnimationChannel engine::load_animation(nlohmann::json a) {
|
||||||
return animation;
|
return animation;
|
||||||
}
|
}
|
||||||
|
|
||||||
Animation engine::load_animation(const file::Path& path) {
|
Animation engine::load_animation(const prism::Path& path) {
|
||||||
Expects(!path.empty());
|
Expects(!path.empty());
|
||||||
|
|
||||||
auto file = file::open(path, true);
|
auto file = prism::open_file(path, true);
|
||||||
if(!file.has_value()) {
|
if(!file.has_value()) {
|
||||||
prism::log::error(System::Core, "Failed to load animation from {}!", path);
|
prism::log::error(System::Core, "Failed to load animation from {}!", path);
|
||||||
return {};
|
return {};
|
||||||
|
@ -282,12 +282,12 @@ Animation engine::load_animation(const file::Path& path) {
|
||||||
return anim;
|
return anim;
|
||||||
}
|
}
|
||||||
|
|
||||||
void engine::load_cutscene(const file::Path& path) {
|
void engine::load_cutscene(const prism::Path& path) {
|
||||||
Expects(!path.empty());
|
Expects(!path.empty());
|
||||||
|
|
||||||
cutscene = std::make_unique<Cutscene>();
|
cutscene = std::make_unique<Cutscene>();
|
||||||
|
|
||||||
auto file = file::open(path);
|
auto file = prism::open_file(path);
|
||||||
if(!file.has_value()) {
|
if(!file.has_value()) {
|
||||||
prism::log::error(System::Core, "Failed to load cutscene from {}!", path);
|
prism::log::error(System::Core, "Failed to load cutscene from {}!", path);
|
||||||
return;
|
return;
|
||||||
|
@ -316,7 +316,7 @@ void engine::load_cutscene(const file::Path& path) {
|
||||||
anim.target = obj;
|
anim.target = obj;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
load_scene(file::root_path(path) / s["scene"].get<std::string_view>());
|
load_scene(prism::root_path(path) / s["scene"].get<std::string_view>());
|
||||||
|
|
||||||
if(get_scene() == nullptr)
|
if(get_scene() == nullptr)
|
||||||
create_empty_scene();
|
create_empty_scene();
|
||||||
|
@ -359,10 +359,10 @@ void engine::save_cutscene(const std::string_view path) {
|
||||||
out << j;
|
out << j;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object engine::add_prefab(Scene& scene, const file::Path& path, const std::string_view override_name) {
|
Object engine::add_prefab(Scene& scene, const prism::Path& path, const std::string_view override_name) {
|
||||||
Expects(!path.empty());
|
Expects(!path.empty());
|
||||||
|
|
||||||
auto file = file::open(path);
|
auto file = prism::open_file(path);
|
||||||
if(!file.has_value()) {
|
if(!file.has_value()) {
|
||||||
prism::log::error(System::Core, "Failed to load prefab from {}!", path);
|
prism::log::error(System::Core, "Failed to load prefab from {}!", path);
|
||||||
return NullObject;
|
return NullObject;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include "log.hpp"
|
#include "log.hpp"
|
||||||
#include "assertions.hpp"
|
#include "assertions.hpp"
|
||||||
|
|
||||||
file::Path file::root_path(const Path path) {
|
prism::Path prism::root_path(const Path path) {
|
||||||
auto p = path;
|
auto p = path;
|
||||||
while(p.parent_path() != p && p.parent_path() != "/") {
|
while(p.parent_path() != p && p.parent_path() != "/") {
|
||||||
p = p.parent_path();
|
p = p.parent_path();
|
||||||
|
@ -15,7 +15,7 @@ file::Path file::root_path(const Path path) {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<file::File> file::open(const file::Path path, const bool binary_mode) {
|
std::optional<prism::file> prism::open_file(const prism::Path path, const bool binary_mode) {
|
||||||
Expects(!path.empty());
|
Expects(!path.empty());
|
||||||
|
|
||||||
auto str = get_file_path(path).string();
|
auto str = get_file_path(path).string();
|
||||||
|
@ -25,30 +25,30 @@ std::optional<file::File> file::open(const file::Path path, const bool binary_mo
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return file::File(file);
|
return prism::file(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
file::Path file::get_file_path(const file::Path path) {
|
prism::Path prism::get_file_path(const prism::Path& path) {
|
||||||
auto fixed_path = path;
|
auto fixed_path = path;
|
||||||
auto root = root_path(path);
|
auto root = root_path(path);
|
||||||
if(root == app_domain) {
|
if(root == app_domain) {
|
||||||
fixed_path = domain_data[static_cast<int>(Domain::App)] / path.lexically_relative(root_path(path));
|
fixed_path = domain_data[static_cast<int>(domain::app)] / path.lexically_relative(root_path(path));
|
||||||
} else if(root == internal_domain) {
|
} else if(root == internal_domain) {
|
||||||
fixed_path = domain_data[static_cast<int>(Domain::Internal)] / path.lexically_relative(root_path(path));
|
fixed_path = domain_data[static_cast<int>(domain::internal)] / path.lexically_relative(root_path(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
return fixed_path;
|
return fixed_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
file::Path file::get_domain_path(const Domain domain) {
|
prism::Path prism::get_domain_path(const domain domain) {
|
||||||
return domain_data[static_cast<int>(domain)];
|
return domain_data[static_cast<int>(domain)];
|
||||||
}
|
}
|
||||||
|
|
||||||
file::Path parent_domain(const file::Path path) {
|
prism::Path parent_domain(const prism::Path& path) {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
file::Path file::get_relative_path(const Domain domain, const Path path) {
|
prism::Path prism::get_relative_path(const domain domain, const Path path) {
|
||||||
// unimplemented
|
// unimplemented
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,10 @@ void load_transform_component(nlohmann::json j, Transform& t) {
|
||||||
|
|
||||||
void load_renderable_component(nlohmann::json j, Renderable& t) {
|
void load_renderable_component(nlohmann::json j, Renderable& t) {
|
||||||
if(j.contains("path"))
|
if(j.contains("path"))
|
||||||
t.mesh = assetm->get<Mesh>(file::app_domain / j["path"].get<std::string_view>());
|
t.mesh = assetm->get<Mesh>(prism::app_domain / j["path"].get<std::string_view>());
|
||||||
|
|
||||||
for(auto& material : j["materials"])
|
for(auto& material : j["materials"])
|
||||||
t.materials.push_back(assetm->get<Material>(file::app_domain / material.get<std::string_view>()));
|
t.materials.push_back(assetm->get<Material>(prism::app_domain / material.get<std::string_view>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void load_camera_component(nlohmann::json j, Camera& camera) {
|
void load_camera_component(nlohmann::json j, Camera& camera) {
|
||||||
|
|
|
@ -94,8 +94,8 @@ UIElement* ui::Screen::find_element(const std::string& id) {
|
||||||
return foundElement;
|
return foundElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui::Screen::Screen(const file::Path path) {
|
ui::Screen::Screen(const prism::Path path) {
|
||||||
auto file = file::open(path);
|
auto file = prism::open_file(path);
|
||||||
if(!file.has_value()) {
|
if(!file.has_value()) {
|
||||||
prism::log::error(System::Core, "Failed to load UI from {}!", path);
|
prism::log::error(System::Core, "Failed to load UI from {}!", path);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -754,7 +754,7 @@ GFXPipeline* GFXVulkan::create_graphics_pipeline(const GFXGraphicsPipelineCreate
|
||||||
vertex_module = createShaderModule(vertex_shader_vector.data(), vertex_shader_vector.size() * sizeof(uint32_t));
|
vertex_module = createShaderModule(vertex_shader_vector.data(), vertex_shader_vector.size() * sizeof(uint32_t));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
auto vertex_shader = file::open(file::internal_domain / (info.shaders.vertex_src.as_path().string()), true);
|
auto vertex_shader = prism::open_file(prism::internal_domain / (info.shaders.vertex_src.as_path().string()), true);
|
||||||
vertex_shader->read_all();
|
vertex_shader->read_all();
|
||||||
|
|
||||||
vertex_module = createShaderModule(vertex_shader->cast_data<uint32_t>(), vertex_shader->size());
|
vertex_module = createShaderModule(vertex_shader->cast_data<uint32_t>(), vertex_shader->size());
|
||||||
|
@ -781,7 +781,7 @@ GFXPipeline* GFXVulkan::create_graphics_pipeline(const GFXGraphicsPipelineCreate
|
||||||
fragment_module = createShaderModule(fragment_shader_vector.data(), fragment_shader_vector.size() * sizeof(uint32_t));
|
fragment_module = createShaderModule(fragment_shader_vector.data(), fragment_shader_vector.size() * sizeof(uint32_t));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
auto fragment_shader = file::open(file::internal_domain / (info.shaders.fragment_src.as_path().string()), true);
|
auto fragment_shader = prism::open_file(prism::internal_domain / (info.shaders.fragment_src.as_path().string()), true);
|
||||||
fragment_shader->read_all();
|
fragment_shader->read_all();
|
||||||
|
|
||||||
fragment_module = createShaderModule(fragment_shader->cast_data<uint32_t>(), fragment_shader->size());
|
fragment_module = createShaderModule(fragment_shader->cast_data<uint32_t>(), fragment_shader->size());
|
||||||
|
@ -1035,7 +1035,7 @@ GFXPipeline* GFXVulkan::create_compute_pipeline(const GFXComputePipelineCreateIn
|
||||||
compute_module = createShaderModule(shader_vector.data(), shader_vector.size() * sizeof(uint32_t));
|
compute_module = createShaderModule(shader_vector.data(), shader_vector.size() * sizeof(uint32_t));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
auto shader = file::open(file::internal_domain / (info.compute_src.as_path().string()), true);
|
auto shader = prism::open_file(prism::internal_domain / (info.compute_src.as_path().string()), true);
|
||||||
shader->read_all();
|
shader->read_all();
|
||||||
|
|
||||||
compute_module = createShaderModule(shader->cast_data<uint32_t>(), shader->size());
|
compute_module = createShaderModule(shader->cast_data<uint32_t>(), shader->size());
|
||||||
|
|
|
@ -11,24 +11,24 @@
|
||||||
#include "file_utils.hpp"
|
#include "file_utils.hpp"
|
||||||
#include "path.hpp"
|
#include "path.hpp"
|
||||||
|
|
||||||
namespace file {
|
namespace prism {
|
||||||
enum class Domain {
|
enum class domain {
|
||||||
System,
|
system,
|
||||||
Internal,
|
internal,
|
||||||
App
|
app
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Represents a file handle. The file may or may not be fully loaded in memory.
|
/// Represents a file handle. The file may or may not be fully loaded in memory.
|
||||||
class File {
|
class file {
|
||||||
public:
|
public:
|
||||||
File(FILE* handle) : handle(handle) {}
|
explicit file(FILE* handle) : handle(handle) {}
|
||||||
|
|
||||||
File(File&& f) noexcept :
|
file(file&& f) noexcept :
|
||||||
mem(std::move(f.mem)),
|
mem(std::move(f.mem)),
|
||||||
handle(std::exchange(f.handle, nullptr)),
|
handle(std::exchange(f.handle, nullptr)),
|
||||||
data(std::move(f.data)) {}
|
data(std::move(f.data)) {}
|
||||||
|
|
||||||
~File() {
|
~file() {
|
||||||
if(handle != nullptr)
|
if(handle != nullptr)
|
||||||
fclose(handle);
|
fclose(handle);
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ namespace file {
|
||||||
/// Loads the entire file into memory, accessible via cast_data()
|
/// Loads the entire file into memory, accessible via cast_data()
|
||||||
void read_all() {
|
void read_all() {
|
||||||
fseek(handle, 0L, SEEK_END);
|
fseek(handle, 0L, SEEK_END);
|
||||||
const size_t _size = static_cast<size_t>(ftell(handle));
|
const auto _size = static_cast<size_t>(ftell(handle));
|
||||||
rewind(handle);
|
rewind(handle);
|
||||||
|
|
||||||
data.resize(_size);
|
data.resize(_size);
|
||||||
|
@ -71,7 +71,7 @@ namespace file {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the file is loaded in memory, return the size of the file.
|
/// If the file is loaded in memory, return the size of the file.
|
||||||
size_t size() const {
|
[[nodiscard]] size_t size() const {
|
||||||
return data.size();
|
return data.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,11 +110,11 @@ namespace file {
|
||||||
@param mode The access mode.
|
@param mode The access mode.
|
||||||
@param path The absolute file path.
|
@param path The absolute file path.
|
||||||
*/
|
*/
|
||||||
void set_domain_path(const Domain domain, const Path path);
|
void set_domain_path(domain domain, Path path);
|
||||||
Path get_domain_path(const Domain domain);
|
Path get_domain_path(domain domain);
|
||||||
|
|
||||||
/// Converts an absolute path to a domain relative path.
|
/// Converts an absolute path to a domain relative path.
|
||||||
Path get_relative_path(const Domain domain, const Path path);
|
Path get_relative_path(domain domain, Path path);
|
||||||
|
|
||||||
/// Returns the path to a writeable directory.
|
/// Returns the path to a writeable directory.
|
||||||
Path get_writeable_directory();
|
Path get_writeable_directory();
|
||||||
|
@ -126,10 +126,10 @@ namespace file {
|
||||||
@param binary_mode Whether or not to open the file as binary or ASCII. Defaults to false.
|
@param binary_mode Whether or not to open the file as binary or ASCII. Defaults to false.
|
||||||
@return An optional with a value if the file was loaded correctly, otherwise it's empty.
|
@return An optional with a value if the file was loaded correctly, otherwise it's empty.
|
||||||
*/
|
*/
|
||||||
std::optional<File> open(const Path path, const bool binary_mode = false);
|
std::optional<file> open_file(Path path, bool binary_mode = false);
|
||||||
|
|
||||||
Path root_path(const Path path);
|
Path root_path(Path path);
|
||||||
Path get_file_path(const Path path);
|
Path get_file_path(const Path& path);
|
||||||
|
|
||||||
inline Path internal_domain = "/internal", app_domain = "/app";
|
inline Path internal_domain = "/internal", app_domain = "/app";
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ private:
|
||||||
void create_font_texture();
|
void create_font_texture();
|
||||||
void update_buffers(RenderTarget& target, const ImDrawData& draw_data);
|
void update_buffers(RenderTarget& target, const ImDrawData& draw_data);
|
||||||
|
|
||||||
std::unique_ptr<file::File> font_file;
|
std::unique_ptr<prism::file> font_file;
|
||||||
|
|
||||||
GFXPipeline* pipeline = nullptr;
|
GFXPipeline* pipeline = nullptr;
|
||||||
GFXTexture* font_texture = nullptr;
|
GFXTexture* font_texture = nullptr;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
AssetPtr<Texture> aperture_texture;
|
AssetPtr<Texture> aperture_texture;
|
||||||
|
|
||||||
DoFPass::DoFPass(GFX* gfx, prism::renderer* renderer) : renderer(renderer) {
|
DoFPass::DoFPass(GFX* gfx, prism::renderer* renderer) : renderer(renderer) {
|
||||||
aperture_texture = assetm->get<Texture>(file::app_domain / "textures/aperture.png");
|
aperture_texture = assetm->get<Texture>(prism::app_domain / "textures/aperture.png");
|
||||||
|
|
||||||
GFXRenderPassCreateInfo renderPassInfo = {};
|
GFXRenderPassCreateInfo renderPassInfo = {};
|
||||||
renderPassInfo.label = "Depth of Field";
|
renderPassInfo.label = "Depth of Field";
|
||||||
|
@ -28,9 +28,9 @@ DoFPass::DoFPass(GFX* gfx, prism::renderer* renderer) : renderer(renderer) {
|
||||||
height_constant.value = extent.height;
|
height_constant.value = extent.height;
|
||||||
|
|
||||||
GFXGraphicsPipelineCreateInfo create_info = {};
|
GFXGraphicsPipelineCreateInfo create_info = {};
|
||||||
create_info.shaders.vertex_src = ShaderSource(file::Path("dof.vert"));
|
create_info.shaders.vertex_src = ShaderSource(prism::Path("dof.vert"));
|
||||||
create_info.shaders.vertex_constants = {width_constant, height_constant};
|
create_info.shaders.vertex_constants = {width_constant, height_constant};
|
||||||
create_info.shaders.fragment_src = ShaderSource(file::Path("dof.frag"));
|
create_info.shaders.fragment_src = ShaderSource(prism::Path("dof.frag"));
|
||||||
|
|
||||||
create_info.shader_input.bindings = {
|
create_info.shader_input.bindings = {
|
||||||
{0, GFXBindingType::StorageImage},
|
{0, GFXBindingType::StorageImage},
|
||||||
|
|
|
@ -23,8 +23,8 @@ void ImGuiPass::create_render_target_resources(RenderTarget& target) {
|
||||||
if(pipeline == nullptr) {
|
if(pipeline == nullptr) {
|
||||||
GFXGraphicsPipelineCreateInfo createInfo;
|
GFXGraphicsPipelineCreateInfo createInfo;
|
||||||
createInfo.label = "ImGui";
|
createInfo.label = "ImGui";
|
||||||
createInfo.shaders.vertex_src = ShaderSource(file::Path("imgui.vert"));
|
createInfo.shaders.vertex_src = ShaderSource(prism::Path("imgui.vert"));
|
||||||
createInfo.shaders.fragment_src = ShaderSource(file::Path("imgui.frag"));
|
createInfo.shaders.fragment_src = ShaderSource(prism::Path("imgui.frag"));
|
||||||
|
|
||||||
GFXVertexInput vertexInput = {};
|
GFXVertexInput vertexInput = {};
|
||||||
vertexInput.stride = sizeof(ImDrawVert);
|
vertexInput.stride = sizeof(ImDrawVert);
|
||||||
|
@ -153,9 +153,9 @@ void ImGuiPass::load_font(const std::string_view filename) {
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
if(io.Fonts->Fonts.empty()) {
|
if(io.Fonts->Fonts.empty()) {
|
||||||
auto file = file::open(file::app_domain / filename);
|
auto file = prism::open_file(prism::app_domain / filename);
|
||||||
if(file != std::nullopt) {
|
if(file != std::nullopt) {
|
||||||
font_file = std::make_unique<file::File>(std::move(file.value()));
|
font_file = std::make_unique<prism::file>(std::move(file.value()));
|
||||||
|
|
||||||
font_file->read_all();
|
font_file->read_all();
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include "renderer.hpp"
|
#include "renderer.hpp"
|
||||||
|
|
||||||
ShaderSource get_shader(std::string filename, bool skinned, bool cubemap) {
|
ShaderSource get_shader(std::string filename, bool skinned, bool cubemap) {
|
||||||
auto shader_file = file::open(file::internal_domain / filename);
|
auto shader_file = prism::open_file(prism::internal_domain / filename);
|
||||||
if(!shader_file.has_value()) {
|
if(!shader_file.has_value()) {
|
||||||
prism::log::error(System::Renderer, "Failed to open shader file {}!", filename);
|
prism::log::error(System::Renderer, "Failed to open shader file {}!", filename);
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -91,7 +91,7 @@ struct SkyPushConstant {
|
||||||
renderer::renderer(GFX* gfx, const bool enable_imgui) : gfx(gfx) {
|
renderer::renderer(GFX* gfx, const bool enable_imgui) : gfx(gfx) {
|
||||||
Expects(gfx != nullptr);
|
Expects(gfx != nullptr);
|
||||||
|
|
||||||
shader_compiler.set_include_path(file::get_domain_path(file::Domain::Internal).string());
|
shader_compiler.set_include_path(prism::get_domain_path(prism::domain::internal).string());
|
||||||
|
|
||||||
create_dummy_texture();
|
create_dummy_texture();
|
||||||
create_histogram_resources();
|
create_histogram_resources();
|
||||||
|
@ -144,8 +144,8 @@ void renderer::resize_render_target(RenderTarget& target, const prism::Extent ex
|
||||||
GFXGraphicsPipelineCreateInfo pipelineInfo = {};
|
GFXGraphicsPipelineCreateInfo pipelineInfo = {};
|
||||||
pipelineInfo.label = "Text";
|
pipelineInfo.label = "Text";
|
||||||
|
|
||||||
pipelineInfo.shaders.vertex_src = ShaderSource(file::Path("text.vert"));
|
pipelineInfo.shaders.vertex_src = ShaderSource(prism::Path("text.vert"));
|
||||||
pipelineInfo.shaders.fragment_src = ShaderSource(file::Path("text.frag"));
|
pipelineInfo.shaders.fragment_src = ShaderSource(prism::Path("text.frag"));
|
||||||
|
|
||||||
pipelineInfo.rasterization.primitive_type = GFXPrimitiveType::TriangleStrip;
|
pipelineInfo.rasterization.primitive_type = GFXPrimitiveType::TriangleStrip;
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ void renderer::update_screen() {
|
||||||
if(current_screen != nullptr) {
|
if(current_screen != nullptr) {
|
||||||
for(auto& element : current_screen->elements) {
|
for(auto& element : current_screen->elements) {
|
||||||
if(!element.background.image.empty())
|
if(!element.background.image.empty())
|
||||||
element.background.texture = assetm->get<Texture>(file::app_domain / element.background.image);
|
element.background.texture = assetm->get<Texture>(prism::app_domain / element.background.image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -718,8 +718,8 @@ void renderer::create_mesh_pipeline(Material& material) const {
|
||||||
|
|
||||||
GFXGraphicsPipelineCreateInfo pipelineInfo = {};
|
GFXGraphicsPipelineCreateInfo pipelineInfo = {};
|
||||||
pipelineInfo.label = "Mesh";
|
pipelineInfo.label = "Mesh";
|
||||||
pipelineInfo.shaders.vertex_src = ShaderSource(file::Path("mesh.vert"));
|
pipelineInfo.shaders.vertex_src = ShaderSource(prism::Path("mesh.vert"));
|
||||||
pipelineInfo.shaders.fragment_src = ShaderSource(file::Path("mesh.frag"));
|
pipelineInfo.shaders.fragment_src = ShaderSource(prism::Path("mesh.frag"));
|
||||||
|
|
||||||
pipelineInfo.shaders.vertex_constants = {materials_constant, lights_constant, spot_lights_constant, probes_constant};
|
pipelineInfo.shaders.vertex_constants = {materials_constant, lights_constant, spot_lights_constant, probes_constant};
|
||||||
pipelineInfo.shaders.fragment_constants = {materials_constant, lights_constant, spot_lights_constant, probes_constant};
|
pipelineInfo.shaders.fragment_constants = {materials_constant, lights_constant, spot_lights_constant, probes_constant};
|
||||||
|
@ -814,8 +814,8 @@ void renderer::create_render_target_resources(RenderTarget& target) {
|
||||||
GFXGraphicsPipelineCreateInfo pipelineInfo = {};
|
GFXGraphicsPipelineCreateInfo pipelineInfo = {};
|
||||||
pipelineInfo.label = "Post";
|
pipelineInfo.label = "Post";
|
||||||
|
|
||||||
pipelineInfo.shaders.vertex_src = ShaderSource(file::Path("post.vert"));
|
pipelineInfo.shaders.vertex_src = ShaderSource(prism::Path("post.vert"));
|
||||||
pipelineInfo.shaders.fragment_src = ShaderSource(file::Path("post.frag"));
|
pipelineInfo.shaders.fragment_src = ShaderSource(prism::Path("post.frag"));
|
||||||
|
|
||||||
pipelineInfo.shader_input.bindings = {
|
pipelineInfo.shader_input.bindings = {
|
||||||
{4, GFXBindingType::PushConstant},
|
{4, GFXBindingType::PushConstant},
|
||||||
|
@ -841,8 +841,8 @@ void renderer::create_post_pipelines() {
|
||||||
GFXGraphicsPipelineCreateInfo pipelineInfo = {};
|
GFXGraphicsPipelineCreateInfo pipelineInfo = {};
|
||||||
pipelineInfo.label = "Post";
|
pipelineInfo.label = "Post";
|
||||||
|
|
||||||
pipelineInfo.shaders.vertex_src = ShaderSource(file::Path("post.vert"));
|
pipelineInfo.shaders.vertex_src = ShaderSource(prism::Path("post.vert"));
|
||||||
pipelineInfo.shaders.fragment_src = ShaderSource(file::Path("post.frag"));
|
pipelineInfo.shaders.fragment_src = ShaderSource(prism::Path("post.frag"));
|
||||||
|
|
||||||
pipelineInfo.shader_input.bindings = {
|
pipelineInfo.shader_input.bindings = {
|
||||||
{4, GFXBindingType::PushConstant},
|
{4, GFXBindingType::PushConstant},
|
||||||
|
@ -862,7 +862,7 @@ void renderer::create_post_pipelines() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderer::create_font_texture() {
|
void renderer::create_font_texture() {
|
||||||
auto file = file::open(file::app_domain / "font.fp", true);
|
auto file = prism::open_file(prism::app_domain / "font.fp", true);
|
||||||
if(file == std::nullopt) {
|
if(file == std::nullopt) {
|
||||||
prism::log::error(System::Renderer, "Failed to load font file!");
|
prism::log::error(System::Renderer, "Failed to load font file!");
|
||||||
return;
|
return;
|
||||||
|
@ -920,8 +920,8 @@ void renderer::create_ui_pipelines() {
|
||||||
GFXGraphicsPipelineCreateInfo pipelineInfo = {};
|
GFXGraphicsPipelineCreateInfo pipelineInfo = {};
|
||||||
pipelineInfo.label = "UI";
|
pipelineInfo.label = "UI";
|
||||||
|
|
||||||
pipelineInfo.shaders.vertex_src = ShaderSource(file::Path("ui.vert"));
|
pipelineInfo.shaders.vertex_src = ShaderSource(prism::Path("ui.vert"));
|
||||||
pipelineInfo.shaders.fragment_src = ShaderSource(file::Path("ui.frag"));
|
pipelineInfo.shaders.fragment_src = ShaderSource(prism::Path("ui.frag"));
|
||||||
|
|
||||||
pipelineInfo.rasterization.primitive_type = GFXPrimitiveType::TriangleStrip;
|
pipelineInfo.rasterization.primitive_type = GFXPrimitiveType::TriangleStrip;
|
||||||
|
|
||||||
|
@ -959,8 +959,8 @@ void renderer::generate_brdf() {
|
||||||
GFXGraphicsPipelineCreateInfo pipelineInfo = {};
|
GFXGraphicsPipelineCreateInfo pipelineInfo = {};
|
||||||
pipelineInfo.label = "BRDF";
|
pipelineInfo.label = "BRDF";
|
||||||
|
|
||||||
pipelineInfo.shaders.vertex_src = ShaderSource(file::Path("brdf.vert"));
|
pipelineInfo.shaders.vertex_src = ShaderSource(prism::Path("brdf.vert"));
|
||||||
pipelineInfo.shaders.fragment_src = ShaderSource(file::Path("brdf.frag"));
|
pipelineInfo.shaders.fragment_src = ShaderSource(prism::Path("brdf.frag"));
|
||||||
|
|
||||||
pipelineInfo.render_pass = brdf_render_pass;
|
pipelineInfo.render_pass = brdf_render_pass;
|
||||||
|
|
||||||
|
@ -1006,7 +1006,7 @@ void renderer::generate_brdf() {
|
||||||
|
|
||||||
void renderer::create_histogram_resources() {
|
void renderer::create_histogram_resources() {
|
||||||
GFXComputePipelineCreateInfo create_info = {};
|
GFXComputePipelineCreateInfo create_info = {};
|
||||||
create_info.compute_src = ShaderSource(file::Path("histogram.comp"));
|
create_info.compute_src = ShaderSource(prism::Path("histogram.comp"));
|
||||||
create_info.workgroup_size_x = 16;
|
create_info.workgroup_size_x = 16;
|
||||||
create_info.workgroup_size_y = 16;
|
create_info.workgroup_size_y = 16;
|
||||||
|
|
||||||
|
@ -1022,7 +1022,7 @@ void renderer::create_histogram_resources() {
|
||||||
|
|
||||||
histogram_pipeline = gfx->create_compute_pipeline(create_info);
|
histogram_pipeline = gfx->create_compute_pipeline(create_info);
|
||||||
|
|
||||||
create_info.compute_src = ShaderSource(file::Path("histogram-average.comp"));
|
create_info.compute_src = ShaderSource(prism::Path("histogram-average.comp"));
|
||||||
create_info.workgroup_size_x = 256;
|
create_info.workgroup_size_x = 256;
|
||||||
create_info.workgroup_size_y = 1;
|
create_info.workgroup_size_y = 1;
|
||||||
|
|
||||||
|
@ -1055,15 +1055,15 @@ ShaderSource renderer::register_shader(const std::string_view shader_file) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
file::Path base_shader_path = get_shader_source_directory();
|
prism::Path base_shader_path = get_shader_source_directory();
|
||||||
|
|
||||||
// if shader editor system is not initialized, use prebuilt shaders
|
// if shader editor system is not initialized, use prebuilt shaders
|
||||||
if(base_shader_path.empty())
|
if(base_shader_path.empty())
|
||||||
return ShaderSource(file::Path(shader_file));
|
return ShaderSource(prism::Path(shader_file));
|
||||||
|
|
||||||
shader_compiler.set_include_path(base_shader_path.string());
|
shader_compiler.set_include_path(base_shader_path.string());
|
||||||
|
|
||||||
file::Path shader_path = file::Path(shader_file);
|
prism::Path shader_path = prism::Path(shader_file);
|
||||||
|
|
||||||
ShaderStage stage = ShaderStage::Vertex;
|
ShaderStage stage = ShaderStage::Vertex;
|
||||||
if(shader_path.extension() == ".vert")
|
if(shader_path.extension() == ".vert")
|
||||||
|
@ -1072,7 +1072,7 @@ ShaderSource renderer::register_shader(const std::string_view shader_file) {
|
||||||
stage = ShaderStage::Fragment;
|
stage = ShaderStage::Fragment;
|
||||||
|
|
||||||
if(found_shader_source.empty()) {
|
if(found_shader_source.empty()) {
|
||||||
auto file = file::open(base_shader_path / shader_path.replace_extension(shader_path.extension().string() + ".glsl"));
|
auto file = prism::open_file(base_shader_path / shader_path.replace_extension(shader_path.extension().string() + ".glsl"));
|
||||||
|
|
||||||
return shader_compiler.compile(ShaderLanguage::GLSL, stage, ShaderSource(file->read_as_string()), gfx->accepted_shader_language()).value();
|
return shader_compiler.compile(ShaderLanguage::GLSL, stage, ShaderSource(file->read_as_string()), gfx->accepted_shader_language()).value();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -68,7 +68,7 @@ const std::array<Matrix4x4, 6> sceneTransforms = {
|
||||||
inline AssetPtr<Mesh> cubeMesh;
|
inline AssetPtr<Mesh> cubeMesh;
|
||||||
|
|
||||||
SceneCapture::SceneCapture(GFX* gfx) {
|
SceneCapture::SceneCapture(GFX* gfx) {
|
||||||
cubeMesh = assetm->get<Mesh>(file::app_domain / "models/cube.model");
|
cubeMesh = assetm->get<Mesh>(prism::app_domain / "models/cube.model");
|
||||||
|
|
||||||
// render pass
|
// render pass
|
||||||
GFXRenderPassCreateInfo renderPassInfo = {};
|
GFXRenderPassCreateInfo renderPassInfo = {};
|
||||||
|
@ -407,8 +407,8 @@ void SceneCapture::createSkyResources() {
|
||||||
pipelineInfo.label = "Sky Scene Capture";
|
pipelineInfo.label = "Sky Scene Capture";
|
||||||
pipelineInfo.render_pass = renderPass;
|
pipelineInfo.render_pass = renderPass;
|
||||||
|
|
||||||
pipelineInfo.shaders.vertex_src = ShaderSource(file::Path("sky.vert"));
|
pipelineInfo.shaders.vertex_src = ShaderSource(prism::Path("sky.vert"));
|
||||||
pipelineInfo.shaders.fragment_src = ShaderSource(file::Path("sky.frag"));
|
pipelineInfo.shaders.fragment_src = ShaderSource(prism::Path("sky.frag"));
|
||||||
|
|
||||||
pipelineInfo.shader_input.bindings = {
|
pipelineInfo.shader_input.bindings = {
|
||||||
{1, GFXBindingType::PushConstant}
|
{1, GFXBindingType::PushConstant}
|
||||||
|
@ -451,8 +451,8 @@ void SceneCapture::createIrradianceResources() {
|
||||||
|
|
||||||
GFXGraphicsPipelineCreateInfo pipelineInfo = {};
|
GFXGraphicsPipelineCreateInfo pipelineInfo = {};
|
||||||
pipelineInfo.label = "Irradiance Convolution";
|
pipelineInfo.label = "Irradiance Convolution";
|
||||||
pipelineInfo.shaders.vertex_src = ShaderSource(file::Path("irradiance.vert"));
|
pipelineInfo.shaders.vertex_src = ShaderSource(prism::Path("irradiance.vert"));
|
||||||
pipelineInfo.shaders.fragment_src = ShaderSource(file::Path("irradiance.frag"));
|
pipelineInfo.shaders.fragment_src = ShaderSource(prism::Path("irradiance.frag"));
|
||||||
|
|
||||||
GFXVertexInput input;
|
GFXVertexInput input;
|
||||||
input.stride = sizeof(Vector3);
|
input.stride = sizeof(Vector3);
|
||||||
|
@ -503,8 +503,8 @@ void SceneCapture::createPrefilterResources() {
|
||||||
|
|
||||||
GFXGraphicsPipelineCreateInfo pipelineInfo = {};
|
GFXGraphicsPipelineCreateInfo pipelineInfo = {};
|
||||||
pipelineInfo.label = "Prefilter";
|
pipelineInfo.label = "Prefilter";
|
||||||
pipelineInfo.shaders.vertex_src = ShaderSource(file::Path("filter.vert"));
|
pipelineInfo.shaders.vertex_src = ShaderSource(prism::Path("filter.vert"));
|
||||||
pipelineInfo.shaders.fragment_src = ShaderSource(file::Path("filter.frag"));
|
pipelineInfo.shaders.fragment_src = ShaderSource(prism::Path("filter.frag"));
|
||||||
|
|
||||||
pipelineInfo.shaders.fragment_constants = {size_constant};
|
pipelineInfo.shaders.fragment_constants = {size_constant};
|
||||||
|
|
||||||
|
|
|
@ -320,7 +320,7 @@ void ShadowPass::create_pipelines() {
|
||||||
|
|
||||||
GFXGraphicsPipelineCreateInfo pipelineInfo = {};
|
GFXGraphicsPipelineCreateInfo pipelineInfo = {};
|
||||||
pipelineInfo.shaders.vertex_constants = {point_light_max_constant};
|
pipelineInfo.shaders.vertex_constants = {point_light_max_constant};
|
||||||
pipelineInfo.shaders.vertex_src = ShaderSource(file::Path("shadow.vert"));
|
pipelineInfo.shaders.vertex_src = ShaderSource(prism::Path("shadow.vert"));
|
||||||
|
|
||||||
pipelineInfo.shaders.fragment_constants = { point_light_max_constant };
|
pipelineInfo.shaders.fragment_constants = { point_light_max_constant };
|
||||||
|
|
||||||
|
@ -364,7 +364,7 @@ void ShadowPass::create_pipelines() {
|
||||||
{
|
{
|
||||||
pipelineInfo.label = "Point Shadow";
|
pipelineInfo.label = "Point Shadow";
|
||||||
|
|
||||||
pipelineInfo.shaders.fragment_src = ShaderSource(file::Path("omnishadow.frag"));
|
pipelineInfo.shaders.fragment_src = ShaderSource(prism::Path("omnishadow.frag"));
|
||||||
|
|
||||||
auto [static_pipeline, skinned_pipeline] = material_compiler.create_pipeline_permutations(pipelineInfo, true);
|
auto [static_pipeline, skinned_pipeline] = material_compiler.create_pipeline_permutations(pipelineInfo, true);
|
||||||
|
|
||||||
|
|
|
@ -137,8 +137,8 @@ void SMAAPass::create_pipelines() {
|
||||||
|
|
||||||
GFXGraphicsPipelineCreateInfo createInfo = {};
|
GFXGraphicsPipelineCreateInfo createInfo = {};
|
||||||
createInfo.label = "SMAA Edge";
|
createInfo.label = "SMAA Edge";
|
||||||
createInfo.shaders.vertex_src = ShaderSource(file::Path("edge.vert"));
|
createInfo.shaders.vertex_src = ShaderSource(prism::Path("edge.vert"));
|
||||||
createInfo.shaders.fragment_src = ShaderSource(file::Path("edge.frag"));
|
createInfo.shaders.fragment_src = ShaderSource(prism::Path("edge.frag"));
|
||||||
|
|
||||||
createInfo.render_pass = render_pass;
|
createInfo.render_pass = render_pass;
|
||||||
|
|
||||||
|
@ -155,8 +155,8 @@ void SMAAPass::create_pipelines() {
|
||||||
edge_pipeline = gfx->create_graphics_pipeline(createInfo);
|
edge_pipeline = gfx->create_graphics_pipeline(createInfo);
|
||||||
|
|
||||||
createInfo.label = "SMAA Blend";
|
createInfo.label = "SMAA Blend";
|
||||||
createInfo.shaders.vertex_src = ShaderSource(file::Path("blend.vert"));
|
createInfo.shaders.vertex_src = ShaderSource(prism::Path("blend.vert"));
|
||||||
createInfo.shaders.fragment_src = ShaderSource(file::Path("blend.frag"));
|
createInfo.shaders.fragment_src = ShaderSource(prism::Path("blend.frag"));
|
||||||
createInfo.shader_input.bindings.push_back({3, GFXBindingType::Texture});
|
createInfo.shader_input.bindings.push_back({3, GFXBindingType::Texture});
|
||||||
|
|
||||||
blend_pipeline = gfx->create_graphics_pipeline(createInfo);
|
blend_pipeline = gfx->create_graphics_pipeline(createInfo);
|
||||||
|
|
|
@ -43,13 +43,13 @@ public:
|
||||||
ShaderSource(const ShaderSource& rhs) : source (rhs.source) {}
|
ShaderSource(const ShaderSource& rhs) : source (rhs.source) {}
|
||||||
explicit ShaderSource(const std::string& source_string) : source(source_string) {}
|
explicit ShaderSource(const std::string& source_string) : source(source_string) {}
|
||||||
explicit ShaderSource(const std::vector<uint32_t>& source_bytecode) : source(source_bytecode) {}
|
explicit ShaderSource(const std::vector<uint32_t>& source_bytecode) : source(source_bytecode) {}
|
||||||
explicit ShaderSource(const file::Path& shader_path) : source(shader_path) {}
|
explicit ShaderSource(const prism::Path& shader_path) : source(shader_path) {}
|
||||||
|
|
||||||
std::variant<std::monostate, file::Path, std::string, std::vector<uint32_t>> source;
|
std::variant<std::monostate, prism::Path, std::string, std::vector<uint32_t>> source;
|
||||||
|
|
||||||
/// Returns a view of the shader source as a path.
|
/// Returns a view of the shader source as a path.
|
||||||
[[nodiscard]] file::Path as_path() const {
|
[[nodiscard]] prism::Path as_path() const {
|
||||||
return std::get<file::Path>(source);
|
return std::get<prism::Path>(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a view of the shader source as plaintext.
|
/// Returns a view of the shader source as plaintext.
|
||||||
|
@ -67,7 +67,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] bool is_path() const {
|
[[nodiscard]] bool is_path() const {
|
||||||
return std::holds_alternative<file::Path>(source);
|
return std::holds_alternative<prism::Path>(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] bool is_string() const {
|
[[nodiscard]] bool is_string() const {
|
||||||
|
|
|
@ -134,7 +134,7 @@ protected:
|
||||||
// If no path markers, return current working directory.
|
// If no path markers, return current working directory.
|
||||||
// Otherwise, strip file name and return path leading up to it.
|
// Otherwise, strip file name and return path leading up to it.
|
||||||
virtual std::string getDirectory(const std::string) const {
|
virtual std::string getDirectory(const std::string) const {
|
||||||
//return file::get_domain_path(file::Domain::Internal).string();
|
//return file::get_domain_path(file::domain::Internal).string();
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
namespace file {
|
namespace prism {
|
||||||
using Path = std::filesystem::path;
|
using Path = std::filesystem::path;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace prism::log {
|
namespace prism::log {
|
||||||
inline void internal_format(std::string& msg, const file::Path& arg) {
|
inline void internal_format(std::string& msg, const prism::Path& arg) {
|
||||||
auto pos = msg.find_first_of("{}");
|
auto pos = msg.find_first_of("{}");
|
||||||
msg.replace(pos, 2, arg.string());
|
msg.replace(pos, 2, arg.string());
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
namespace file {
|
namespace prism {
|
||||||
using Path = std::filesystem::path;
|
using Path = std::filesystem::path;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
#include "scene.hpp"
|
#include "scene.hpp"
|
||||||
|
|
||||||
void app_main(prism::engine* engine) {
|
void app_main(prism::engine* engine) {
|
||||||
file::set_domain_path(file::Domain::App, "data");
|
prism::set_domain_path(prism::domain::app, "data");
|
||||||
file::set_domain_path(file::Domain::Internal, "{resource_dir}/shaders");
|
prism::set_domain_path(prism::domain::internal, "{resource_dir}/shaders");
|
||||||
|
|
||||||
platform::open_window("Example", {-1, -1, 1280, 720}, WindowFlags::Resizable);
|
platform::open_window("Example", {-1, -1, 1280, 720}, WindowFlags::Resizable);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
#include "string_utils.hpp"
|
#include "string_utils.hpp"
|
||||||
|
|
||||||
void file::set_domain_path(const file::Domain domain, const file::Path path) {
|
void prism::set_domain_path(const prism::domain domain, const prism::Path path) {
|
||||||
domain_data[(int)domain] = replace_substring(path.string(), "{resource_dir}/", "");
|
domain_data[(int)domain] = replace_substring(path.string(), "{resource_dir}/", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
file::Path file::get_writeable_directory() {
|
prism::Path prism::get_writeable_directory() {
|
||||||
return "~";
|
return "~";
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,7 +188,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GFXTexture* get_asset_thumbnail(const file::Path path) {
|
GFXTexture* get_asset_thumbnail(const prism::Path path) {
|
||||||
if(asset_thumbnails.count(path.string())) {
|
if(asset_thumbnails.count(path.string())) {
|
||||||
return asset_thumbnails[path.string()];
|
return asset_thumbnails[path.string()];
|
||||||
} else {
|
} else {
|
||||||
|
@ -272,7 +272,7 @@ public:
|
||||||
current_asset_type = get_asset_type<T>();
|
current_asset_type = get_asset_type<T>();
|
||||||
open_asset_popup = true;
|
open_asset_popup = true;
|
||||||
on_asset_select = [&asset, this](auto p) {
|
on_asset_select = [&asset, this](auto p) {
|
||||||
asset = assetm->get<T>(file::app_domain / p);
|
asset = assetm->get<T>(prism::app_domain / p);
|
||||||
has_asset_edit_changed = true;
|
has_asset_edit_changed = true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -360,7 +360,7 @@ inline void editPath(const char* label, std::string& path, bool editable = true,
|
||||||
|
|
||||||
if(ImGui::Button("...")) {
|
if(ImGui::Button("...")) {
|
||||||
platform::open_dialog(false, [&path, &on_selected](std::string p) {
|
platform::open_dialog(false, [&path, &on_selected](std::string p) {
|
||||||
path = file::get_relative_path(file::Domain::App, p).string();
|
path = prism::get_relative_path(prism::domain::app, p).string();
|
||||||
|
|
||||||
if(on_selected != nullptr)
|
if(on_selected != nullptr)
|
||||||
on_selected();
|
on_selected();
|
||||||
|
|
|
@ -49,15 +49,15 @@ const std::map<ImGuiKey, InputButton> imToPl = {
|
||||||
|
|
||||||
CommonEditor::CommonEditor(std::string id) : id(id) {
|
CommonEditor::CommonEditor(std::string id) : id(id) {
|
||||||
#ifdef PLATFORM_MACOS
|
#ifdef PLATFORM_MACOS
|
||||||
file::set_domain_path(file::Domain::App, "../../../data");
|
file::set_domain_path(file::domain::App, "../../../data");
|
||||||
#else
|
#else
|
||||||
file::set_domain_path(file::Domain::App, "data");
|
prism::set_domain_path(prism::domain::app, "data");
|
||||||
#endif
|
#endif
|
||||||
file::set_domain_path(file::Domain::Internal, "{resource_dir}/shaders");
|
prism::set_domain_path(prism::domain::internal, "{resource_dir}/shaders");
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
iniFileName = (file::get_writeable_directory() / "imgui.ini").string();
|
iniFileName = (prism::get_writeable_directory() / "imgui.ini").string();
|
||||||
|
|
||||||
io.IniFilename = iniFileName.c_str();
|
io.IniFilename = iniFileName.c_str();
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ void CommonEditor::begin_frame() {
|
||||||
int column = 0;
|
int column = 0;
|
||||||
for(auto& [p, a_type] : asset_files) {
|
for(auto& [p, a_type] : asset_files) {
|
||||||
if(current_asset_type == a_type) {
|
if(current_asset_type == a_type) {
|
||||||
if(ImGui::ImageButton(get_asset_thumbnail(file::app_domain / p), ImVec2(64, 64))) {
|
if(ImGui::ImageButton(get_asset_thumbnail(prism::app_domain / p), ImVec2(64, 64))) {
|
||||||
on_asset_select(p);
|
on_asset_select(p);
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
|
@ -465,7 +465,7 @@ void editUI(UI& ui) {
|
||||||
ImGui::InputText("Path", &ui.ui_path);
|
ImGui::InputText("Path", &ui.ui_path);
|
||||||
|
|
||||||
if(ImGui::Button("Reload")) {
|
if(ImGui::Button("Reload")) {
|
||||||
ui.screen = engine->load_screen(file::app_domain / ui.ui_path);
|
ui.screen = engine->load_screen(prism::app_domain / ui.ui_path);
|
||||||
engine->get_renderer()->init_screen(ui.screen);
|
engine->get_renderer()->init_screen(ui.screen);
|
||||||
ui.screen->extent.width = ui.width;
|
ui.screen->extent.width = ui.width;
|
||||||
ui.screen->extent.height = ui.height;
|
ui.screen->extent.height = ui.height;
|
||||||
|
@ -723,8 +723,8 @@ void CommonEditor::set_undo_stack(UndoStack *stack) {
|
||||||
current_stack = stack;
|
current_stack = stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mesh_readable(const file::Path path) {
|
bool mesh_readable(const prism::Path path) {
|
||||||
auto file = file::open(path);
|
auto file = prism::open_file(path);
|
||||||
if(!file.has_value()) {
|
if(!file.has_value()) {
|
||||||
prism::log::error(System::Renderer, "Failed to load mesh from {}!", path);
|
prism::log::error(System::Renderer, "Failed to load mesh from {}!", path);
|
||||||
return false;
|
return false;
|
||||||
|
@ -736,8 +736,8 @@ bool mesh_readable(const file::Path path) {
|
||||||
return version == 5 || version == 6;
|
return version == 5 || version == 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool material_readable(const file::Path path) {
|
bool material_readable(const prism::Path path) {
|
||||||
auto file = file::open(path);
|
auto file = prism::open_file(path);
|
||||||
if(!file.has_value()) {
|
if(!file.has_value()) {
|
||||||
prism::log::error(System::Core, "Failed to load material from {}!", path);
|
prism::log::error(System::Core, "Failed to load material from {}!", path);
|
||||||
return false;
|
return false;
|
||||||
|
@ -783,8 +783,8 @@ void CommonEditor::drawAssets() {
|
||||||
for(auto& [p, type] : asset_files) {
|
for(auto& [p, type] : asset_files) {
|
||||||
ImGui::PushID(&p);
|
ImGui::PushID(&p);
|
||||||
|
|
||||||
if(ImGui::ImageButton(get_asset_thumbnail(file::app_domain / p), ImVec2(64, 64)))
|
if(ImGui::ImageButton(get_asset_thumbnail(prism::app_domain / p), ImVec2(64, 64)))
|
||||||
asset_selected(file::app_domain / p, type);
|
asset_selected(prism::app_domain / p, type);
|
||||||
|
|
||||||
if(ImGui::BeginPopupContextItem()) {
|
if(ImGui::BeginPopupContextItem()) {
|
||||||
ImGui::TextDisabled("%s", p.string().c_str());
|
ImGui::TextDisabled("%s", p.string().c_str());
|
||||||
|
@ -792,7 +792,7 @@ void CommonEditor::drawAssets() {
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
if(ImGui::Button("Regenerate thumbnail")) {
|
if(ImGui::Button("Regenerate thumbnail")) {
|
||||||
asset_thumbnails.erase(asset_thumbnails.find((file::app_domain / p).string()));
|
asset_thumbnails.erase(asset_thumbnails.find((prism::app_domain / p).string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
|
@ -814,8 +814,8 @@ GFXTexture* CommonEditor::get_material_preview(Material& material) {
|
||||||
Scene scene;
|
Scene scene;
|
||||||
|
|
||||||
auto sphere = scene.add_object();
|
auto sphere = scene.add_object();
|
||||||
scene.add<Renderable>(sphere).mesh = assetm->get<Mesh>(file::app_domain / "models" / "sphere.model");
|
scene.add<Renderable>(sphere).mesh = assetm->get<Mesh>(prism::app_domain / "models" / "sphere.model");
|
||||||
scene.get<Renderable>(sphere).materials.push_back(assetm->get<Material>(file::app_domain / material.path)); // we throw away our material handle here :-(
|
scene.get<Renderable>(sphere).materials.push_back(assetm->get<Material>(prism::app_domain / material.path)); // we throw away our material handle here :-(
|
||||||
|
|
||||||
scene.get<Transform>(sphere).rotation = euler_to_quat(Vector3(radians(90.0f), 0, 0));
|
scene.get<Transform>(sphere).rotation = euler_to_quat(Vector3(radians(90.0f), 0, 0));
|
||||||
|
|
||||||
|
@ -826,7 +826,7 @@ GFXTexture* CommonEditor::get_mesh_preview(Mesh& mesh) {
|
||||||
Scene scene;
|
Scene scene;
|
||||||
|
|
||||||
auto mesh_obj = scene.add_object();
|
auto mesh_obj = scene.add_object();
|
||||||
scene.add<Renderable>(mesh_obj).mesh = assetm->get<Mesh>(file::app_domain / mesh.path);
|
scene.add<Renderable>(mesh_obj).mesh = assetm->get<Mesh>(prism::app_domain / mesh.path);
|
||||||
|
|
||||||
float biggest_component = 0.0f;
|
float biggest_component = 0.0f;
|
||||||
for(const auto& part : scene.get<Renderable>(mesh_obj).mesh->parts) {
|
for(const auto& part : scene.get<Renderable>(mesh_obj).mesh->parts) {
|
||||||
|
@ -840,7 +840,7 @@ GFXTexture* CommonEditor::get_mesh_preview(Mesh& mesh) {
|
||||||
find_biggest_component(part.aabb.min);
|
find_biggest_component(part.aabb.min);
|
||||||
find_biggest_component(part.aabb.max);
|
find_biggest_component(part.aabb.max);
|
||||||
|
|
||||||
scene.get<Renderable>(mesh_obj).materials.push_back(assetm->get<Material>(file::app_domain / "materials" / "Material.material"));
|
scene.get<Renderable>(mesh_obj).materials.push_back(assetm->get<Material>(prism::app_domain / "materials" / "Material.material"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return generate_common_preview(scene, Vector3(biggest_component * 2.0f));
|
return generate_common_preview(scene, Vector3(biggest_component * 2.0f));
|
||||||
|
@ -1045,7 +1045,7 @@ void CommonEditor::drawConsole() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonEditor::load_options() {
|
void CommonEditor::load_options() {
|
||||||
std::ifstream i(file::get_writeable_directory() / (id + "options.json"));
|
std::ifstream i(prism::get_writeable_directory() / (id + "options.json"));
|
||||||
if (i.is_open()) {
|
if (i.is_open()) {
|
||||||
nlohmann::json j;
|
nlohmann::json j;
|
||||||
i >> j;
|
i >> j;
|
||||||
|
@ -1077,12 +1077,12 @@ void CommonEditor::save_options() {
|
||||||
j["height"] = height;
|
j["height"] = height;
|
||||||
j["files"] = lastOpenedFiles;
|
j["files"] = lastOpenedFiles;
|
||||||
|
|
||||||
std::ofstream out(file::get_writeable_directory() / (id + "options.json"));
|
std::ofstream out(prism::get_writeable_directory() / (id + "options.json"));
|
||||||
out << j;
|
out << j;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonEditor::load_thumbnail_cache() {
|
void CommonEditor::load_thumbnail_cache() {
|
||||||
auto thumbnail_cache = file::open("./thumbnail-cache");
|
auto thumbnail_cache = prism::open_file("./thumbnail-cache");
|
||||||
if(thumbnail_cache != std::nullopt) {
|
if(thumbnail_cache != std::nullopt) {
|
||||||
int size;
|
int size;
|
||||||
thumbnail_cache->read(&size);
|
thumbnail_cache->read(&size);
|
||||||
|
|
|
@ -21,8 +21,8 @@ void DebugPass::initialize() {
|
||||||
|
|
||||||
{
|
{
|
||||||
GFXGraphicsPipelineCreateInfo createInfo;
|
GFXGraphicsPipelineCreateInfo createInfo;
|
||||||
createInfo.shaders.vertex_src = ShaderSource(file::Path("debug.vert"));
|
createInfo.shaders.vertex_src = ShaderSource(prism::Path("debug.vert"));
|
||||||
createInfo.shaders.fragment_src = ShaderSource(file::Path("debug.frag"));
|
createInfo.shaders.fragment_src = ShaderSource(prism::Path("debug.frag"));
|
||||||
|
|
||||||
GFXVertexInput vertexInput = {};
|
GFXVertexInput vertexInput = {};
|
||||||
vertexInput.stride = sizeof(Vector3);
|
vertexInput.stride = sizeof(Vector3);
|
||||||
|
@ -47,14 +47,14 @@ void DebugPass::initialize() {
|
||||||
|
|
||||||
primitive_pipeline = engine->get_gfx()->create_graphics_pipeline(createInfo);
|
primitive_pipeline = engine->get_gfx()->create_graphics_pipeline(createInfo);
|
||||||
|
|
||||||
cubeMesh = assetm->get<Mesh>(file::app_domain / "models/cube.model");
|
cubeMesh = assetm->get<Mesh>(prism::app_domain / "models/cube.model");
|
||||||
sphereMesh = assetm->get<Mesh>(file::app_domain / "models/sphere.model");
|
sphereMesh = assetm->get<Mesh>(prism::app_domain / "models/sphere.model");
|
||||||
|
|
||||||
createInfo.rasterization.polygon_type = GFXPolygonType::Fill;
|
createInfo.rasterization.polygon_type = GFXPolygonType::Fill;
|
||||||
|
|
||||||
arrow_pipeline = engine->get_gfx()->create_graphics_pipeline(createInfo);
|
arrow_pipeline = engine->get_gfx()->create_graphics_pipeline(createInfo);
|
||||||
|
|
||||||
arrowMesh = assetm->get<Mesh>(file::app_domain / "models/arrow.model");
|
arrowMesh = assetm->get<Mesh>(prism::app_domain / "models/arrow.model");
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -69,8 +69,8 @@ void DebugPass::initialize() {
|
||||||
// pipeline
|
// pipeline
|
||||||
GFXGraphicsPipelineCreateInfo pipelineInfo = {};
|
GFXGraphicsPipelineCreateInfo pipelineInfo = {};
|
||||||
|
|
||||||
pipelineInfo.shaders.vertex_src = ShaderSource(file::Path("color.vert"));
|
pipelineInfo.shaders.vertex_src = ShaderSource(prism::Path("color.vert"));
|
||||||
pipelineInfo.shaders.fragment_src = ShaderSource(file::Path("color.frag"));
|
pipelineInfo.shaders.fragment_src = ShaderSource(prism::Path("color.frag"));
|
||||||
|
|
||||||
GFXVertexInput input;
|
GFXVertexInput input;
|
||||||
input.stride = sizeof(Vector3);
|
input.stride = sizeof(Vector3);
|
||||||
|
@ -110,8 +110,8 @@ void DebugPass::initialize() {
|
||||||
GFXGraphicsPipelineCreateInfo pipelineInfo = {};
|
GFXGraphicsPipelineCreateInfo pipelineInfo = {};
|
||||||
pipelineInfo.label = "Sobel";
|
pipelineInfo.label = "Sobel";
|
||||||
|
|
||||||
pipelineInfo.shaders.vertex_src = ShaderSource(file::Path("color.vert"));
|
pipelineInfo.shaders.vertex_src = ShaderSource(prism::Path("color.vert"));
|
||||||
pipelineInfo.shaders.fragment_src = ShaderSource(file::Path("color.frag"));
|
pipelineInfo.shaders.fragment_src = ShaderSource(prism::Path("color.frag"));
|
||||||
|
|
||||||
GFXVertexInput input;
|
GFXVertexInput input;
|
||||||
input.stride = sizeof(Vector3);
|
input.stride = sizeof(Vector3);
|
||||||
|
@ -142,8 +142,8 @@ void DebugPass::initialize() {
|
||||||
GFXGraphicsPipelineCreateInfo pipelineInfo = {};
|
GFXGraphicsPipelineCreateInfo pipelineInfo = {};
|
||||||
pipelineInfo.label = "Billboard";
|
pipelineInfo.label = "Billboard";
|
||||||
|
|
||||||
pipelineInfo.shaders.vertex_src = ShaderSource(file::Path("billboard.vert"));
|
pipelineInfo.shaders.vertex_src = ShaderSource(prism::Path("billboard.vert"));
|
||||||
pipelineInfo.shaders.fragment_src = ShaderSource(file::Path("billboard.frag"));
|
pipelineInfo.shaders.fragment_src = ShaderSource(prism::Path("billboard.frag"));
|
||||||
|
|
||||||
pipelineInfo.shader_input.bindings = {
|
pipelineInfo.shader_input.bindings = {
|
||||||
{1, GFXBindingType::PushConstant},
|
{1, GFXBindingType::PushConstant},
|
||||||
|
@ -163,10 +163,10 @@ void DebugPass::initialize() {
|
||||||
|
|
||||||
billboard_pipeline = engine->get_gfx()->create_graphics_pipeline(pipelineInfo);
|
billboard_pipeline = engine->get_gfx()->create_graphics_pipeline(pipelineInfo);
|
||||||
|
|
||||||
pointTexture = assetm->get<Texture>(file::app_domain / "textures/point.png");
|
pointTexture = assetm->get<Texture>(prism::app_domain / "textures/point.png");
|
||||||
spotTexture = assetm->get<Texture>(file::app_domain / "textures/spot.png");
|
spotTexture = assetm->get<Texture>(prism::app_domain / "textures/spot.png");
|
||||||
sunTexture = assetm->get<Texture>(file::app_domain / "textures/sun.png");
|
sunTexture = assetm->get<Texture>(prism::app_domain / "textures/sun.png");
|
||||||
probeTexture = assetm->get<Texture>(file::app_domain / "textures/probe.png");
|
probeTexture = assetm->get<Texture>(prism::app_domain / "textures/probe.png");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ public:
|
||||||
void asset_selected(std::filesystem::path path, AssetType type) override;
|
void asset_selected(std::filesystem::path path, AssetType type) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void open_asset(const file::Path path);
|
void open_asset(const prism::Path path);
|
||||||
void setup_editor(Editor* editor);
|
void setup_editor(Editor* editor);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,7 @@ void MaterialEditor::draw(CommonEditor* editor) {
|
||||||
save_material(*material, path);
|
save_material(*material, path);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
save_material(*material, file::get_file_path(path));
|
save_material(*material, prism::get_file_path(path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ void prepPrefabScene() {
|
||||||
scene->get<Transform>(plane).position = Vector3(0, -1, 0);
|
scene->get<Transform>(plane).position = Vector3(0, -1, 0);
|
||||||
scene->get<Transform>(plane).scale = Vector3(50);
|
scene->get<Transform>(plane).scale = Vector3(50);
|
||||||
|
|
||||||
scene->add<Renderable>(plane).mesh = assetm->get<Mesh>(file::app_domain / "models/plane.model");
|
scene->add<Renderable>(plane).mesh = assetm->get<Mesh>(prism::app_domain / "models/plane.model");
|
||||||
|
|
||||||
prepThreePointLighting();
|
prepThreePointLighting();
|
||||||
}
|
}
|
||||||
|
@ -96,8 +96,8 @@ Renderable* prepMaterialScene() {
|
||||||
scene->get<Transform>(plane).position = Vector3(0, -1, 0);
|
scene->get<Transform>(plane).position = Vector3(0, -1, 0);
|
||||||
scene->get<Transform>(plane).scale = Vector3(50);
|
scene->get<Transform>(plane).scale = Vector3(50);
|
||||||
|
|
||||||
scene->add<Renderable>(plane).mesh = assetm->get<Mesh>(file::app_domain / "models/plane.model");
|
scene->add<Renderable>(plane).mesh = assetm->get<Mesh>(prism::app_domain / "models/plane.model");
|
||||||
scene->get<Renderable>(plane).materials.push_back(assetm->get<Material>(file::app_domain / "materials/Material.material"));
|
scene->get<Renderable>(plane).materials.push_back(assetm->get<Material>(prism::app_domain / "materials/Material.material"));
|
||||||
|
|
||||||
auto sphere = scene->add_object();
|
auto sphere = scene->add_object();
|
||||||
scene->get(sphere).name = "sphere";
|
scene->get(sphere).name = "sphere";
|
||||||
|
@ -105,7 +105,7 @@ Renderable* prepMaterialScene() {
|
||||||
|
|
||||||
scene->get<Transform>(sphere).rotation = euler_to_quat(Vector3(radians(90.0f), 0, 0));
|
scene->get<Transform>(sphere).rotation = euler_to_quat(Vector3(radians(90.0f), 0, 0));
|
||||||
|
|
||||||
scene->add<Renderable>(sphere).mesh = assetm->get<Mesh>(file::app_domain / "models/sphere.model");
|
scene->add<Renderable>(sphere).mesh = assetm->get<Mesh>(prism::app_domain / "models/sphere.model");
|
||||||
|
|
||||||
prepThreePointLighting();
|
prepThreePointLighting();
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ void PrismEditor::setup_editor(Editor* editor) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrismEditor::open_asset(const file::Path path) {
|
void PrismEditor::open_asset(const prism::Path path) {
|
||||||
if(path.extension() == ".prefab") {
|
if(path.extension() == ".prefab") {
|
||||||
PrefabEditor* editor = new PrefabEditor();
|
PrefabEditor* editor = new PrefabEditor();
|
||||||
editor->path = path.string();
|
editor->path = path.string();
|
||||||
|
|
Reference in a new issue