Begin work on converting to the new class naming scheme and the new prism namespace
This commit is contained in:
parent
2552398aff
commit
744123763f
15 changed files with 429 additions and 421 deletions
|
@ -1,34 +1,37 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class Engine;
|
|
||||||
class GFXCommandBuffer;
|
class GFXCommandBuffer;
|
||||||
|
|
||||||
/// The base class for any Prism application.
|
namespace prism {
|
||||||
class App {
|
class Engine;
|
||||||
public:
|
|
||||||
/// Called when a render context is available.
|
|
||||||
virtual void initialize_render() {}
|
|
||||||
|
|
||||||
/// Called when the engine is about to quit. Should be overriden if an app needs to save data before qutting.
|
/// The base class for any Prism application.
|
||||||
virtual void prepare_quit() {}
|
class app {
|
||||||
|
public:
|
||||||
/// Called to check whether or not an app should intervene quitting.
|
/// Called when a render context is available.
|
||||||
virtual bool should_quit() {
|
virtual void initialize_render() {}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Called when a engine starts a new frame. Typically used for inserting new imgui windows.
|
/// Called when the engine is about to quit. Should be overriden if an app needs to save data before qutting.
|
||||||
virtual void begin_frame() {}
|
virtual void prepare_quit() {}
|
||||||
|
|
||||||
/** Called during the engine's update cycle.
|
|
||||||
@param delta_time Delta time in milliseconds.
|
|
||||||
*/
|
|
||||||
virtual void update([[maybe_unused]] const float delta_time) {}
|
|
||||||
|
|
||||||
virtual void render([[maybe_unused]] GFXCommandBuffer* command_buffer) {}
|
/// Called to check whether or not an app should intervene quitting.
|
||||||
|
virtual bool should_quit() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool wants_no_scene_rendering() { return false; }
|
/// Called when a engine starts a new frame. Typically used for inserting new imgui windows.
|
||||||
};
|
virtual void begin_frame() {}
|
||||||
|
|
||||||
/// This is an app's equivalent main(). You can check command line arguments through Engine::comand_line_arguments.
|
/** Called during the engine's update cycle.
|
||||||
void app_main(Engine* engine);
|
@param delta_time Delta time in milliseconds.
|
||||||
|
*/
|
||||||
|
virtual void update([[maybe_unused]] const float delta_time) {}
|
||||||
|
|
||||||
|
virtual void render([[maybe_unused]] GFXCommandBuffer* command_buffer) {}
|
||||||
|
|
||||||
|
virtual bool wants_no_scene_rendering() { return false; }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// This is an app's equivalent of main(). You can check command line arguments through Engine::command_line_arguments.
|
||||||
|
void app_main(prism::Engine* engine);
|
||||||
|
|
|
@ -15,7 +15,6 @@ namespace ui {
|
||||||
class Screen;
|
class Screen;
|
||||||
}
|
}
|
||||||
|
|
||||||
class App;
|
|
||||||
class Scene;
|
class Scene;
|
||||||
class Input;
|
class Input;
|
||||||
class Renderer;
|
class Renderer;
|
||||||
|
@ -24,368 +23,372 @@ class Physics;
|
||||||
class ImGuiLayer;
|
class ImGuiLayer;
|
||||||
struct Timer;
|
struct Timer;
|
||||||
|
|
||||||
struct AnimationTarget {
|
namespace prism {
|
||||||
float current_time = 0.0f;
|
class app;
|
||||||
float animation_speed_modifier = 1.0f;
|
|
||||||
bool looping = false;
|
|
||||||
|
|
||||||
Object target;
|
struct AnimationTarget {
|
||||||
Animation animation;
|
float current_time = 0.0f;
|
||||||
};
|
float animation_speed_modifier = 1.0f;
|
||||||
|
bool looping = false;
|
||||||
|
|
||||||
/// An object that contains glue between App and systems such as the Renderer.
|
Object target = NullObject;
|
||||||
class Engine {
|
Animation animation;
|
||||||
public:
|
|
||||||
/**
|
|
||||||
Constructs an Engine with command line arguments. Can be accessed later from command_line_arguments.
|
|
||||||
|
|
||||||
@param argc Numer of arguments. Can be null.
|
|
||||||
@param argv Array of strings containing arguments. Can be null.
|
|
||||||
*/
|
|
||||||
Engine(const int argc, char* argv[]);
|
|
||||||
|
|
||||||
Engine(const Engine& other) = delete;
|
|
||||||
Engine(Engine&& other) = delete;
|
|
||||||
|
|
||||||
~Engine();
|
|
||||||
|
|
||||||
/// Command line arguments, can be empty.
|
|
||||||
std::vector<std::string_view> command_line_arguments;
|
|
||||||
|
|
||||||
/** Sets the app object.
|
|
||||||
@param app The app object to set. Must not be null.
|
|
||||||
*/
|
|
||||||
void set_app(App* app);
|
|
||||||
|
|
||||||
/** Gets the current app object
|
|
||||||
@return The current app object. Can be null.
|
|
||||||
*/
|
|
||||||
App* get_app() const;
|
|
||||||
|
|
||||||
/** Call to begin the next frame.
|
|
||||||
@param delta_time Delta time in seconds.
|
|
||||||
*/
|
|
||||||
void begin_frame(const float delta_time);
|
|
||||||
|
|
||||||
/** Call to start updating the current frame.
|
|
||||||
@param delta_time Delta time in seconds.
|
|
||||||
*/
|
|
||||||
void update(const float delta_time);
|
|
||||||
|
|
||||||
/** Call to begin rendering for a window.
|
|
||||||
@param index The index of the window to begin rendering for.
|
|
||||||
*/
|
|
||||||
void render(const int index);
|
|
||||||
|
|
||||||
void end_frame();
|
|
||||||
|
|
||||||
/// Pause updating.
|
|
||||||
void pause();
|
|
||||||
|
|
||||||
/// Resume updating.
|
|
||||||
void unpause();
|
|
||||||
|
|
||||||
/** Query the current pause state.
|
|
||||||
@return Whether or not the engine is currently paused.
|
|
||||||
*/
|
|
||||||
bool is_paused() const;
|
|
||||||
|
|
||||||
/// Request to begin quitting immediately. This is not forced, and can be canceled by the user, platform, or app.
|
|
||||||
void quit();
|
|
||||||
|
|
||||||
/// Call right before the platform is about to quit the application, and requests the app or other systems to save work.
|
|
||||||
void prepare_quit();
|
|
||||||
|
|
||||||
/// Query whether or not the engine is in the process of quitting.
|
|
||||||
bool is_quitting() const;
|
|
||||||
|
|
||||||
/** Set the GFX api to use.
|
|
||||||
@param gfx The GFX object to use. Must not be null.
|
|
||||||
*/
|
|
||||||
void set_gfx(GFX* gfx);
|
|
||||||
|
|
||||||
/** Get the current GFX api.
|
|
||||||
@return The current GFX api. Can be null.
|
|
||||||
*/
|
|
||||||
GFX* get_gfx();
|
|
||||||
|
|
||||||
/** Get the input system.
|
|
||||||
@return Instance of the input system. Will not be null.
|
|
||||||
*/
|
|
||||||
Input* get_input();
|
|
||||||
|
|
||||||
/** Get the renderer for a window.
|
|
||||||
@param index Index of the window. Default is 0.
|
|
||||||
@return Instance of the renderer. Will not be null.
|
|
||||||
*/
|
|
||||||
Renderer* get_renderer();
|
|
||||||
|
|
||||||
/** Get the physics system.
|
|
||||||
@return Instance of the physics system. Will not be null.
|
|
||||||
*/
|
|
||||||
Physics* get_physics();
|
|
||||||
|
|
||||||
/// Creates an empty scene with no path. This will change the current scene.
|
|
||||||
void create_empty_scene();
|
|
||||||
|
|
||||||
/** Load a scene from disk. This will change the current scene if successful.
|
|
||||||
@param path The scene file path.
|
|
||||||
@return Returns a instance of the scene is successful, and nullptr on failure.
|
|
||||||
*/
|
|
||||||
Scene* load_scene(const file::Path path);
|
|
||||||
|
|
||||||
/** Save the current scene to disk.
|
|
||||||
@param path The absolute file path.
|
|
||||||
*/
|
|
||||||
void save_scene(const std::string_view path);
|
|
||||||
|
|
||||||
/** Load a UI screen from disk. This will not change the current screen.
|
|
||||||
@param path The screen file path.
|
|
||||||
@return Returns a instance of the screen if successful, and nullptr on failure.
|
|
||||||
*/
|
|
||||||
ui::Screen* load_screen(const file::Path path);
|
|
||||||
|
|
||||||
/** Set the current screen.
|
|
||||||
@param screen The screen object to set as current. Can be null.
|
|
||||||
*/
|
|
||||||
void set_screen(ui::Screen* screen);
|
|
||||||
|
|
||||||
/** Gets the current screen.
|
|
||||||
@return The current screen. Can be null.
|
|
||||||
*/
|
|
||||||
ui::Screen* get_screen() const;
|
|
||||||
|
|
||||||
/** Load a prefab from disk.
|
|
||||||
@param scene The scene to add the prefab to.
|
|
||||||
@param path The prefab file path.
|
|
||||||
@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, const std::string_view override_name = "");
|
|
||||||
|
|
||||||
/** Save a tree of objects as a prefab to disk.
|
|
||||||
@param root The parent object to save as a prefab.
|
|
||||||
@param path The absolue file path.
|
|
||||||
*/
|
|
||||||
void save_prefab(const Object root, const std::string_view path);
|
|
||||||
|
|
||||||
/** Deserializes a animation channel from JSON.
|
|
||||||
@param j The animation channel json to deserialize.
|
|
||||||
@return An animation channel.
|
|
||||||
*/
|
|
||||||
AnimationChannel load_animation(nlohmann::json j);
|
|
||||||
|
|
||||||
/** Load an animation from disk.
|
|
||||||
@param path The animation file path.
|
|
||||||
@return An animation.
|
|
||||||
*/
|
|
||||||
Animation load_animation(const file::Path path);
|
|
||||||
|
|
||||||
/** Load a cutscene from disk. This changes the current cutscene.
|
|
||||||
@param path The cutscene file path.
|
|
||||||
*/
|
|
||||||
void load_cutscene(const file::Path path);
|
|
||||||
|
|
||||||
/** Saves the current cutscene to disk.
|
|
||||||
@param path The absolute file path.
|
|
||||||
*/
|
|
||||||
void save_cutscene(const std::string_view path);
|
|
||||||
|
|
||||||
/** Adds the window for engine management.
|
|
||||||
@param native_handle The platform's native handle to it's window equivalent.
|
|
||||||
@param identifier The identifier of the new window.
|
|
||||||
@param extent The extent of the window.
|
|
||||||
*/
|
|
||||||
void add_window(void* native_handle, const int identifier, const prism::Extent extent);
|
|
||||||
|
|
||||||
/** Removes the window from engine management. Should be called before the window is actually closed.
|
|
||||||
@param identifier The identifier of the window to remove.
|
|
||||||
*/
|
|
||||||
void remove_window(const int identifier);
|
|
||||||
|
|
||||||
/** Called when the window has changed size.
|
|
||||||
@param identifier The window that has been resized.
|
|
||||||
@param extent The new extent of the window.
|
|
||||||
*/
|
|
||||||
void resize(const int identifier, const prism::Extent extent);
|
|
||||||
|
|
||||||
/** Called when a key has been pressed.
|
|
||||||
@param keyCode A platform-specific key code.
|
|
||||||
@note Use platform::get_keycode to get a InputButton equivalent if needed.
|
|
||||||
@note This function is only intended for debug purposes and all production code should be using the Input system instead.
|
|
||||||
*/
|
|
||||||
void process_key_down(const unsigned int keyCode);
|
|
||||||
|
|
||||||
/** Called when a key has been released.
|
|
||||||
@param keyCode A platform-specific key code.
|
|
||||||
@note Use platform::get_keycode to get a InputButton equivalent if needed.
|
|
||||||
@note This function is only intended for debug purposes and all production code should be using the Input system instead.
|
|
||||||
*/
|
|
||||||
void process_key_up(const unsigned int keyCode);
|
|
||||||
|
|
||||||
/** Called when a mouse button has been clicked..
|
|
||||||
@param button The mouse button.
|
|
||||||
@param offset The mouse position relative to the window where the click occured.
|
|
||||||
@note This function is only intended for debug purposes and all production code should be using the Input system instead.
|
|
||||||
*/
|
|
||||||
void process_mouse_down(const int button, const prism::Offset offset);
|
|
||||||
|
|
||||||
/** Pushes a UI event for the current screen. Does nothing if there is no screen set.
|
|
||||||
@param name The name of the event.
|
|
||||||
@param data Data for the event. Defaulted to an empty string.
|
|
||||||
*/
|
|
||||||
void push_event(const std::string_view name, const std::string_view data = "");
|
|
||||||
|
|
||||||
/** Load a localization file from disk. This will change the current localization.
|
|
||||||
@param path The localization file path.
|
|
||||||
*/
|
|
||||||
void load_localization(const std::string_view path);
|
|
||||||
|
|
||||||
/** Queries whether or not the current localization loaded has a key.
|
|
||||||
@param id The key to query.
|
|
||||||
@return Whether or not the locale has the key specified.
|
|
||||||
@note Having no localization loaded will always return false.
|
|
||||||
*/
|
|
||||||
bool has_localization(const std::string_view id) const;
|
|
||||||
|
|
||||||
/** Localizes a string.
|
|
||||||
@param id The locale key to use.
|
|
||||||
@return A localized string if the key is found, or an empty string if not found.
|
|
||||||
@note Having no localization loaded will always return a empty string.
|
|
||||||
*/
|
|
||||||
std::string localize(const std::string id);
|
|
||||||
|
|
||||||
/** Adds a timer to the list of timers.
|
|
||||||
@param timer The timer to add.
|
|
||||||
@note The timer instance is passed by reference. Use this to keep track of your timers without having to query it's state back.
|
|
||||||
*/
|
|
||||||
void add_timer(Timer& timer);
|
|
||||||
|
|
||||||
/** Gets the current scene.
|
|
||||||
@return The current scene if set, or nullptr if there isn't one.
|
|
||||||
*/
|
|
||||||
Scene* get_scene();
|
|
||||||
|
|
||||||
/** Get a scene by path. This does not change the current scene.
|
|
||||||
@param name The path to the scene file.
|
|
||||||
@return Returns a scene if it was previously loaded and found, or nullptr on failure.
|
|
||||||
*/
|
|
||||||
Scene* get_scene(const std::string_view name);
|
|
||||||
|
|
||||||
/** Set the current scene.
|
|
||||||
@param scene The scene to set. Can be null.
|
|
||||||
*/
|
|
||||||
void set_current_scene(Scene* scene);
|
|
||||||
|
|
||||||
/** Get the current scene's path.
|
|
||||||
@return If a scene is loaded, the path to the scene. Can be an empty string if there is no scene loaded, or if it's an empty scene.
|
|
||||||
*/
|
|
||||||
std::string_view get_scene_path() const;
|
|
||||||
|
|
||||||
/** Updates the Transform hierarchy for a scene.
|
|
||||||
@param scene The scene to update.
|
|
||||||
*/
|
|
||||||
void update_scene(Scene& scene);
|
|
||||||
|
|
||||||
/// The current cutscene.
|
|
||||||
std::unique_ptr<Cutscene> cutscene;
|
|
||||||
|
|
||||||
/// The current time in seconds for cutscene playback.
|
|
||||||
float current_cutscene_time = 0.0f;
|
|
||||||
|
|
||||||
/// The cutscene playback state.
|
|
||||||
bool play_cutscene = false;
|
|
||||||
|
|
||||||
/** Start playback of an animation.
|
|
||||||
@param animation The animation to play.
|
|
||||||
@param object The animation's target.
|
|
||||||
@param looping Whether or not the animation should loop or be discarded when finished. Default is false.
|
|
||||||
*/
|
|
||||||
void play_animation(const Animation animation, const Object target, const bool looping = false);
|
|
||||||
|
|
||||||
/** Sets the animation speed of an object.
|
|
||||||
@param target The object you want to change the animation speed of.
|
|
||||||
@param modifier The speed to play the object's animations at. A modifier of 2.0 would be 2x the speed, and 0.5 would be 1/2x the speed.
|
|
||||||
*/
|
|
||||||
void set_animation_speed_modifier(const Object target, const float modifier);
|
|
||||||
|
|
||||||
/** Stops all animation for an object.
|
|
||||||
@param target The object you want the animations to stop for.
|
|
||||||
*/
|
|
||||||
void stop_animation(const Object target);
|
|
||||||
|
|
||||||
/// If there is a render context available. If this is false, avoid doing any GFX or Renderer work as it could crash or cause undefined behavior.
|
|
||||||
bool render_ready = false;
|
|
||||||
|
|
||||||
/// If physics should upate. This is a control indepentent of the pause state.
|
|
||||||
bool update_physics = true;
|
|
||||||
|
|
||||||
#if defined(PLATFORM_TVOS) || defined(PLATFORM_IOS) || defined(PLATFORM_WINDOWS) || defined(PLATFORM_LINUX)
|
|
||||||
bool debug_enabled = true;
|
|
||||||
#else
|
|
||||||
bool debug_enabled = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
|
||||||
void setup_scene(Scene& scene);
|
|
||||||
|
|
||||||
void on_remove(Object object);
|
|
||||||
|
|
||||||
bool _paused = false;
|
|
||||||
|
|
||||||
ui::Screen* _current_screen = nullptr;
|
|
||||||
|
|
||||||
Scene* _current_scene = nullptr;
|
|
||||||
std::vector<std::unique_ptr<Scene>> _scenes;
|
|
||||||
std::map<std::string, Scene*> _path_to_scene;
|
|
||||||
|
|
||||||
struct Window {
|
|
||||||
int identifier = -1;
|
|
||||||
prism::Extent extent;
|
|
||||||
bool quitRequested = false;
|
|
||||||
|
|
||||||
RenderTarget* render_target = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<Window*> _windows;
|
/// The glue between app and systems such as the Renderer.
|
||||||
|
class Engine {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
Constructs an Engine with command line arguments. Can be accessed later from command_line_arguments.
|
||||||
|
|
||||||
Window* get_window(const int identifier) {
|
@param argc Numer of arguments. Can be null.
|
||||||
for(auto& window : _windows) {
|
@param argv Array of strings containing arguments. Can be null.
|
||||||
if(window->identifier == identifier)
|
*/
|
||||||
return window;
|
Engine(int argc, char* argv[]);
|
||||||
|
|
||||||
|
Engine(const Engine& other) = delete;
|
||||||
|
Engine(Engine&& other) = delete;
|
||||||
|
|
||||||
|
~Engine();
|
||||||
|
|
||||||
|
/// Command line arguments, can be empty.
|
||||||
|
std::vector<std::string_view> command_line_arguments;
|
||||||
|
|
||||||
|
/** Sets the app object.
|
||||||
|
@param app The app object to set. Must not be null.
|
||||||
|
*/
|
||||||
|
void set_app(app* app);
|
||||||
|
|
||||||
|
/** Gets the current app object
|
||||||
|
@return The current app object. Can be null.
|
||||||
|
*/
|
||||||
|
[[nodiscard]] app* get_app() const;
|
||||||
|
|
||||||
|
/** Call to begin the next frame.
|
||||||
|
@param delta_time Delta time in seconds.
|
||||||
|
*/
|
||||||
|
void begin_frame(float delta_time);
|
||||||
|
|
||||||
|
/** Call to start updating the current frame.
|
||||||
|
@param delta_time Delta time in seconds.
|
||||||
|
*/
|
||||||
|
void update(float delta_time);
|
||||||
|
|
||||||
|
/** Call to begin rendering for a window.
|
||||||
|
@param index The index of the window to begin rendering for.
|
||||||
|
*/
|
||||||
|
void render(int index);
|
||||||
|
|
||||||
|
void end_frame();
|
||||||
|
|
||||||
|
/// Pause updating.
|
||||||
|
void pause();
|
||||||
|
|
||||||
|
/// Resume updating.
|
||||||
|
void unpause();
|
||||||
|
|
||||||
|
/** Query the current pause state.
|
||||||
|
@return Whether or not the engine is currently paused.
|
||||||
|
*/
|
||||||
|
[[nodiscard]] bool is_paused() const;
|
||||||
|
|
||||||
|
/// Request to begin quitting immediately. This is not forced, and can be canceled by the user, platform, or app.
|
||||||
|
void quit();
|
||||||
|
|
||||||
|
/// Call right before the platform is about to quit the application, and requests the app or other systems to save work.
|
||||||
|
void prepare_quit();
|
||||||
|
|
||||||
|
/// Query whether or not the engine is in the process of quitting.
|
||||||
|
[[nodiscard]] bool is_quitting() const;
|
||||||
|
|
||||||
|
/** Set the GFX api to use.
|
||||||
|
@param gfx The GFX object to use. Must not be null.
|
||||||
|
*/
|
||||||
|
void set_gfx(GFX* gfx);
|
||||||
|
|
||||||
|
/** Get the current GFX api.
|
||||||
|
@return The current GFX api. Can be null.
|
||||||
|
*/
|
||||||
|
GFX* get_gfx();
|
||||||
|
|
||||||
|
/** Get the input system.
|
||||||
|
@return Instance of the input system. Will not be null.
|
||||||
|
*/
|
||||||
|
Input* get_input();
|
||||||
|
|
||||||
|
/** Get the renderer for a window.
|
||||||
|
@param index Index of the window. Default is 0.
|
||||||
|
@return Instance of the renderer. Will not be null.
|
||||||
|
*/
|
||||||
|
Renderer* get_renderer();
|
||||||
|
|
||||||
|
/** Get the physics system.
|
||||||
|
@return Instance of the physics system. Will not be null.
|
||||||
|
*/
|
||||||
|
Physics* get_physics();
|
||||||
|
|
||||||
|
/// Creates an empty scene with no path. This will change the current scene.
|
||||||
|
void create_empty_scene();
|
||||||
|
|
||||||
|
/** Load a scene from disk. This will change the current scene if successful.
|
||||||
|
@param path The scene file path.
|
||||||
|
@return Returns a instance of the scene is successful, and nullptr on failure.
|
||||||
|
*/
|
||||||
|
Scene* load_scene(file::Path path);
|
||||||
|
|
||||||
|
/** Save the current scene to disk.
|
||||||
|
@param path The absolute file path.
|
||||||
|
*/
|
||||||
|
void save_scene(std::string_view path);
|
||||||
|
|
||||||
|
/** Load a UI screen from disk. This will not change the current screen.
|
||||||
|
@param path The screen file path.
|
||||||
|
@return Returns a instance of the screen if successful, and nullptr on failure.
|
||||||
|
*/
|
||||||
|
ui::Screen* load_screen(file::Path path);
|
||||||
|
|
||||||
|
/** Set the current screen.
|
||||||
|
@param screen The screen object to set as current. Can be null.
|
||||||
|
*/
|
||||||
|
void set_screen(ui::Screen* screen);
|
||||||
|
|
||||||
|
/** Gets the current screen.
|
||||||
|
@return The current screen. Can be null.
|
||||||
|
*/
|
||||||
|
[[nodiscard]] ui::Screen* get_screen() const;
|
||||||
|
|
||||||
|
/** Load a prefab from disk.
|
||||||
|
@param scene The scene to add the prefab to.
|
||||||
|
@param path The prefab file path.
|
||||||
|
@param override_name If not empty, the root object's new name. Defaulted to a empty string.
|
||||||
|
*/
|
||||||
|
Object add_prefab(Scene& scene, file::Path path, std::string_view override_name = "");
|
||||||
|
|
||||||
|
/** Save a tree of objects as a prefab to disk.
|
||||||
|
@param root The parent object to save as a prefab.
|
||||||
|
@param path The absolue file path.
|
||||||
|
*/
|
||||||
|
void save_prefab(Object root, std::string_view path);
|
||||||
|
|
||||||
|
/** Deserializes a animation channel from JSON.
|
||||||
|
@param j The animation channel json to deserialize.
|
||||||
|
@return An animation channel.
|
||||||
|
*/
|
||||||
|
AnimationChannel load_animation(nlohmann::json j);
|
||||||
|
|
||||||
|
/** Load an animation from disk.
|
||||||
|
@param path The animation file path.
|
||||||
|
@return An animation.
|
||||||
|
*/
|
||||||
|
Animation load_animation(file::Path path);
|
||||||
|
|
||||||
|
/** Load a cutscene from disk. This changes the current cutscene.
|
||||||
|
@param path The cutscene file path.
|
||||||
|
*/
|
||||||
|
void load_cutscene(file::Path path);
|
||||||
|
|
||||||
|
/** Saves the current cutscene to disk.
|
||||||
|
@param path The absolute file path.
|
||||||
|
*/
|
||||||
|
void save_cutscene(std::string_view path);
|
||||||
|
|
||||||
|
/** Adds the window for engine management.
|
||||||
|
@param native_handle The platform's native handle to it's window equivalent.
|
||||||
|
@param identifier The identifier of the new window.
|
||||||
|
@param extent The extent of the window.
|
||||||
|
*/
|
||||||
|
void add_window(void* native_handle, int identifier, prism::Extent extent);
|
||||||
|
|
||||||
|
/** Removes the window from engine management. Should be called before the window is actually closed.
|
||||||
|
@param identifier The identifier of the window to remove.
|
||||||
|
*/
|
||||||
|
void remove_window(int identifier);
|
||||||
|
|
||||||
|
/** Called when the window has changed size.
|
||||||
|
@param identifier The window that has been resized.
|
||||||
|
@param extent The new extent of the window.
|
||||||
|
*/
|
||||||
|
void resize(int identifier, prism::Extent extent);
|
||||||
|
|
||||||
|
/** Called when a key has been pressed.
|
||||||
|
@param keyCode A platform-specific key code.
|
||||||
|
@note Use platform::get_keycode to get a InputButton equivalent if needed.
|
||||||
|
@note This function is only intended for debug purposes and all production code should be using the Input system instead.
|
||||||
|
*/
|
||||||
|
void process_key_down(unsigned int keyCode);
|
||||||
|
|
||||||
|
/** Called when a key has been released.
|
||||||
|
@param keyCode A platform-specific key code.
|
||||||
|
@note Use platform::get_keycode to get a InputButton equivalent if needed.
|
||||||
|
@note This function is only intended for debug purposes and all production code should be using the Input system instead.
|
||||||
|
*/
|
||||||
|
void process_key_up(unsigned int keyCode);
|
||||||
|
|
||||||
|
/** Called when a mouse button has been clicked..
|
||||||
|
@param button The mouse button.
|
||||||
|
@param offset The mouse position relative to the window where the click occured.
|
||||||
|
@note This function is only intended for debug purposes and all production code should be using the Input system instead.
|
||||||
|
*/
|
||||||
|
void process_mouse_down(int button, prism::Offset offset);
|
||||||
|
|
||||||
|
/** Pushes a UI event for the current screen. Does nothing if there is no screen set.
|
||||||
|
@param name The name of the event.
|
||||||
|
@param data Data for the event. Defaulted to an empty string.
|
||||||
|
*/
|
||||||
|
void push_event(std::string_view name, std::string_view data = "");
|
||||||
|
|
||||||
|
/** Load a localization file from disk. This will change the current localization.
|
||||||
|
@param path The localization file path.
|
||||||
|
*/
|
||||||
|
void load_localization(std::string_view path);
|
||||||
|
|
||||||
|
/** Queries whether or not the current localization loaded has a key.
|
||||||
|
@param id The key to query.
|
||||||
|
@return Whether or not the locale has the key specified.
|
||||||
|
@note Having no localization loaded will always return false.
|
||||||
|
*/
|
||||||
|
[[nodiscard]] bool has_localization(std::string_view id) const;
|
||||||
|
|
||||||
|
/** Localizes a string.
|
||||||
|
@param id The locale key to use.
|
||||||
|
@return A localized string if the key is found, or an empty string if not found.
|
||||||
|
@note Having no localization loaded will always return a empty string.
|
||||||
|
*/
|
||||||
|
std::string localize(std::string id);
|
||||||
|
|
||||||
|
/** Adds a timer to the list of timers.
|
||||||
|
@param timer The timer to add.
|
||||||
|
@note The timer instance is passed by reference. Use this to keep track of your timers without having to query it's state back.
|
||||||
|
*/
|
||||||
|
void add_timer(Timer& timer);
|
||||||
|
|
||||||
|
/** Gets the current scene.
|
||||||
|
@return The current scene if set, or nullptr if there isn't one.
|
||||||
|
*/
|
||||||
|
Scene* get_scene();
|
||||||
|
|
||||||
|
/** Get a scene by path. This does not change the current scene.
|
||||||
|
@param name The path to the scene file.
|
||||||
|
@return Returns a scene if it was previously loaded and found, or nullptr on failure.
|
||||||
|
*/
|
||||||
|
Scene* get_scene(std::string_view name);
|
||||||
|
|
||||||
|
/** Set the current scene.
|
||||||
|
@param scene The scene to set. Can be null.
|
||||||
|
*/
|
||||||
|
void set_current_scene(Scene* scene);
|
||||||
|
|
||||||
|
/** Get the current scene's path.
|
||||||
|
@return If a scene is loaded, the path to the scene. Can be an empty string if there is no scene loaded, or if it's an empty scene.
|
||||||
|
*/
|
||||||
|
[[nodiscard]] std::string_view get_scene_path() const;
|
||||||
|
|
||||||
|
/** Updates the Transform hierarchy for a scene.
|
||||||
|
@param scene The scene to update.
|
||||||
|
*/
|
||||||
|
void update_scene(Scene& scene);
|
||||||
|
|
||||||
|
/// The current cutscene.
|
||||||
|
std::unique_ptr<Cutscene> cutscene;
|
||||||
|
|
||||||
|
/// The current time in seconds for cutscene playback.
|
||||||
|
float current_cutscene_time = 0.0f;
|
||||||
|
|
||||||
|
/// The cutscene playback state.
|
||||||
|
bool play_cutscene = false;
|
||||||
|
|
||||||
|
/** Start playback of an animation.
|
||||||
|
@param animation The animation to play.
|
||||||
|
@param object The animation's target.
|
||||||
|
@param looping Whether or not the animation should loop or be discarded when finished. Default is false.
|
||||||
|
*/
|
||||||
|
void play_animation(Animation animation, Object target, bool looping = false);
|
||||||
|
|
||||||
|
/** Sets the animation speed of an object.
|
||||||
|
@param target The object you want to change the animation speed of.
|
||||||
|
@param modifier The speed to play the object's animations at. A modifier of 2.0 would be 2x the speed, and 0.5 would be 1/2x the speed.
|
||||||
|
*/
|
||||||
|
void set_animation_speed_modifier(Object target, float modifier);
|
||||||
|
|
||||||
|
/** Stops all animation for an object.
|
||||||
|
@param target The object you want the animations to stop for.
|
||||||
|
*/
|
||||||
|
void stop_animation(Object target);
|
||||||
|
|
||||||
|
/// If there is a render context available. If this is false, avoid doing any GFX or Renderer work as it could crash or cause undefined behavior.
|
||||||
|
bool render_ready = false;
|
||||||
|
|
||||||
|
/// If physics should upate. This is a control indepentent of the pause state.
|
||||||
|
bool update_physics = true;
|
||||||
|
|
||||||
|
#if defined(PLATFORM_TVOS) || defined(PLATFORM_IOS) || defined(PLATFORM_WINDOWS) || defined(PLATFORM_LINUX)
|
||||||
|
bool debug_enabled = true;
|
||||||
|
#else
|
||||||
|
bool debug_enabled = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setup_scene(Scene& scene);
|
||||||
|
|
||||||
|
void on_remove(Object object);
|
||||||
|
|
||||||
|
bool _paused = false;
|
||||||
|
|
||||||
|
ui::Screen* _current_screen = nullptr;
|
||||||
|
|
||||||
|
Scene* _current_scene = nullptr;
|
||||||
|
std::vector<std::unique_ptr<Scene>> _scenes;
|
||||||
|
std::map<std::string, Scene*> _path_to_scene;
|
||||||
|
|
||||||
|
struct Window {
|
||||||
|
int identifier = -1;
|
||||||
|
prism::Extent extent;
|
||||||
|
bool quitRequested = false;
|
||||||
|
|
||||||
|
RenderTarget* render_target = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<Window*> _windows;
|
||||||
|
|
||||||
|
Window* get_window(const int identifier) {
|
||||||
|
for(auto& window : _windows) {
|
||||||
|
if(window->identifier == identifier)
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
void calculate_bone(Mesh& mesh, const Mesh::Part& part, Bone& bone, const Bone* parent_bone = nullptr);
|
||||||
|
void calculate_object(Scene& scene, Object object, Object parent_object = NullObject);
|
||||||
|
|
||||||
|
Shot* get_shot(float time);
|
||||||
|
void update_animation(const Animation& anim, float time);
|
||||||
|
void update_cutscene(float time);
|
||||||
|
|
||||||
|
void update_animation_channel(Scene& scene, const AnimationChannel& channel, float time);
|
||||||
|
|
||||||
|
app* _app = nullptr;
|
||||||
|
GFX* _gfx = nullptr;
|
||||||
|
|
||||||
|
std::unique_ptr<Input> _input;
|
||||||
|
std::unique_ptr<Physics> _physics;
|
||||||
|
std::unique_ptr<Renderer> _renderer;
|
||||||
|
|
||||||
|
std::vector<Timer*> _timers, _timersToRemove;
|
||||||
|
|
||||||
|
std::map<std::string, std::string> _strings;
|
||||||
|
|
||||||
|
std::vector<AnimationTarget> _animation_targets;
|
||||||
|
|
||||||
|
std::unique_ptr<ImGuiLayer> _imgui;
|
||||||
|
|
||||||
|
const InputButton debug_button = InputButton::Q;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline bool operator==(const AnimationTarget& a1, const AnimationTarget& a2) {
|
||||||
|
return a1.current_time == a2.current_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
void calculate_bone(Mesh& mesh, const Mesh::Part& part, Bone& bone, const Bone* parent_bone = nullptr);
|
|
||||||
void calculate_object(Scene& scene, Object object, const Object parent_object = NullObject);
|
|
||||||
|
|
||||||
Shot* get_shot(const float time);
|
|
||||||
void update_animation(const Animation& anim, const float time);
|
|
||||||
void update_cutscene(const float time);
|
|
||||||
|
|
||||||
void update_animation_channel(Scene& scene, const AnimationChannel& channel, const float time);
|
|
||||||
|
|
||||||
App* _app = nullptr;
|
|
||||||
GFX* _gfx = nullptr;
|
|
||||||
|
|
||||||
std::unique_ptr<Input> _input;
|
|
||||||
std::unique_ptr<Physics> _physics;
|
|
||||||
std::unique_ptr<Renderer> _renderer;
|
|
||||||
|
|
||||||
std::vector<Timer*> _timers, _timersToRemove;
|
|
||||||
|
|
||||||
std::map<std::string, std::string> _strings;
|
|
||||||
|
|
||||||
std::vector<AnimationTarget> _animation_targets;
|
|
||||||
|
|
||||||
std::unique_ptr<ImGuiLayer> _imgui;
|
|
||||||
|
|
||||||
const InputButton debug_button = InputButton::Q;
|
|
||||||
};
|
|
||||||
|
|
||||||
inline bool operator==(const AnimationTarget& a1, const AnimationTarget& a2) {
|
|
||||||
return a1.current_time == a2.current_time;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Engine* engine = nullptr;
|
inline prism::Engine* engine = nullptr;
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
#include "shadowpass.hpp"
|
#include "shadowpass.hpp"
|
||||||
#include "scenecapture.hpp"
|
#include "scenecapture.hpp"
|
||||||
|
|
||||||
|
using prism::Engine;
|
||||||
|
|
||||||
Engine::Engine(const int argc, char* argv[]) {
|
Engine::Engine(const int argc, char* argv[]) {
|
||||||
console::info(System::Core, "Prism Engine loading...");
|
console::info(System::Core, "Prism Engine loading...");
|
||||||
|
|
||||||
|
@ -47,13 +49,13 @@ Engine::Engine(const int argc, char* argv[]) {
|
||||||
|
|
||||||
Engine::~Engine() {}
|
Engine::~Engine() {}
|
||||||
|
|
||||||
void Engine::set_app(App* app) {
|
void Engine::set_app(app* app) {
|
||||||
Expects(app != nullptr);
|
Expects(app != nullptr);
|
||||||
|
|
||||||
_app = app;
|
_app = app;
|
||||||
}
|
}
|
||||||
|
|
||||||
App* Engine::get_app() const {
|
prism::app* Engine::get_app() const {
|
||||||
return _app;
|
return _app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1354,7 +1354,7 @@ void GFXVulkan::createInstance(std::vector<const char*> layers, std::vector<cons
|
||||||
|
|
||||||
VkApplicationInfo appInfo = {};
|
VkApplicationInfo appInfo = {};
|
||||||
appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
|
appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
|
||||||
appInfo.pApplicationName = "Prism Engine App";
|
appInfo.pApplicationName = "Prism Engine app";
|
||||||
appInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
|
appInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
|
||||||
appInfo.pEngineName = "Prism Engine";
|
appInfo.pEngineName = "Prism Engine";
|
||||||
appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0);
|
appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "app.hpp"
|
#include "app.hpp"
|
||||||
|
|
||||||
class ExampleApp : public App {
|
class ExampleApp : public app {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
};
|
};
|
52
extern/imgui/src/imgui_demo.cpp
vendored
52
extern/imgui/src/imgui_demo.cpp
vendored
|
@ -55,19 +55,19 @@ Index of this file:
|
||||||
// - sub section: ShowDemoWindowMisc()
|
// - sub section: ShowDemoWindowMisc()
|
||||||
// [SECTION] About Window / ShowAboutWindow()
|
// [SECTION] About Window / ShowAboutWindow()
|
||||||
// [SECTION] Style Editor / ShowStyleEditor()
|
// [SECTION] Style Editor / ShowStyleEditor()
|
||||||
// [SECTION] Example App: Main Menu Bar / ShowExampleAppMainMenuBar()
|
// [SECTION] Example app: Main Menu Bar / ShowExampleAppMainMenuBar()
|
||||||
// [SECTION] Example App: Debug Console / ShowExampleAppConsole()
|
// [SECTION] Example app: Debug Console / ShowExampleAppConsole()
|
||||||
// [SECTION] Example App: Debug Log / ShowExampleAppLog()
|
// [SECTION] Example app: Debug Log / ShowExampleAppLog()
|
||||||
// [SECTION] Example App: Simple Layout / ShowExampleAppLayout()
|
// [SECTION] Example app: Simple Layout / ShowExampleAppLayout()
|
||||||
// [SECTION] Example App: Property Editor / ShowExampleAppPropertyEditor()
|
// [SECTION] Example app: Property Editor / ShowExampleAppPropertyEditor()
|
||||||
// [SECTION] Example App: Long Text / ShowExampleAppLongText()
|
// [SECTION] Example app: Long Text / ShowExampleAppLongText()
|
||||||
// [SECTION] Example App: Auto Resize / ShowExampleAppAutoResize()
|
// [SECTION] Example app: Auto Resize / ShowExampleAppAutoResize()
|
||||||
// [SECTION] Example App: Constrained Resize / ShowExampleAppConstrainedResize()
|
// [SECTION] Example app: Constrained Resize / ShowExampleAppConstrainedResize()
|
||||||
// [SECTION] Example App: Simple Overlay / ShowExampleAppSimpleOverlay()
|
// [SECTION] Example app: Simple Overlay / ShowExampleAppSimpleOverlay()
|
||||||
// [SECTION] Example App: Manipulating Window Titles / ShowExampleAppWindowTitles()
|
// [SECTION] Example app: Manipulating Window Titles / ShowExampleAppWindowTitles()
|
||||||
// [SECTION] Example App: Custom Rendering using ImDrawList API / ShowExampleAppCustomRendering()
|
// [SECTION] Example app: Custom Rendering using ImDrawList API / ShowExampleAppCustomRendering()
|
||||||
// [SECTION] Example App: Docking, DockSpace / ShowExampleAppDockSpace()
|
// [SECTION] Example app: Docking, DockSpace / ShowExampleAppDockSpace()
|
||||||
// [SECTION] Example App: Documents Handling / ShowExampleAppDocuments()
|
// [SECTION] Example app: Documents Handling / ShowExampleAppDocuments()
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -6100,7 +6100,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Example App: Main Menu Bar / ShowExampleAppMainMenuBar()
|
// [SECTION] Example app: Main Menu Bar / ShowExampleAppMainMenuBar()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// - ShowExampleAppMainMenuBar()
|
// - ShowExampleAppMainMenuBar()
|
||||||
// - ShowExampleMenuFile()
|
// - ShowExampleMenuFile()
|
||||||
|
@ -6212,7 +6212,7 @@ static void ShowExampleMenuFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Example App: Debug Console / ShowExampleAppConsole()
|
// [SECTION] Example app: Debug Console / ShowExampleAppConsole()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Demonstrate creating a simple console window, with scrolling, filtering, completion and history.
|
// Demonstrate creating a simple console window, with scrolling, filtering, completion and history.
|
||||||
|
@ -6570,7 +6570,7 @@ static void ShowExampleAppConsole(bool* p_open)
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Example App: Debug Log / ShowExampleAppLog()
|
// [SECTION] Example app: Debug Log / ShowExampleAppLog()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Usage:
|
// Usage:
|
||||||
|
@ -6728,7 +6728,7 @@ static void ShowExampleAppLog(bool* p_open)
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Example App: Simple Layout / ShowExampleAppLayout()
|
// [SECTION] Example app: Simple Layout / ShowExampleAppLayout()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Demonstrate create a window with multiple child windows.
|
// Demonstrate create a window with multiple child windows.
|
||||||
|
@ -6793,7 +6793,7 @@ static void ShowExampleAppLayout(bool* p_open)
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Example App: Property Editor / ShowExampleAppPropertyEditor()
|
// [SECTION] Example app: Property Editor / ShowExampleAppPropertyEditor()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
static void ShowPlaceholderObject(const char* prefix, int uid)
|
static void ShowPlaceholderObject(const char* prefix, int uid)
|
||||||
|
@ -6875,7 +6875,7 @@ static void ShowExampleAppPropertyEditor(bool* p_open)
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Example App: Long Text / ShowExampleAppLongText()
|
// [SECTION] Example app: Long Text / ShowExampleAppLongText()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Demonstrate/test rendering huge amount of text, and the incidence of clipping.
|
// Demonstrate/test rendering huge amount of text, and the incidence of clipping.
|
||||||
|
@ -6937,7 +6937,7 @@ static void ShowExampleAppLongText(bool* p_open)
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Example App: Auto Resize / ShowExampleAppAutoResize()
|
// [SECTION] Example app: Auto Resize / ShowExampleAppAutoResize()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Demonstrate creating a window which gets auto-resized according to its content.
|
// Demonstrate creating a window which gets auto-resized according to its content.
|
||||||
|
@ -6961,7 +6961,7 @@ static void ShowExampleAppAutoResize(bool* p_open)
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Example App: Constrained Resize / ShowExampleAppConstrainedResize()
|
// [SECTION] Example app: Constrained Resize / ShowExampleAppConstrainedResize()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Demonstrate creating a window with custom resize constraints.
|
// Demonstrate creating a window with custom resize constraints.
|
||||||
|
@ -7016,7 +7016,7 @@ static void ShowExampleAppConstrainedResize(bool* p_open)
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Example App: Simple Overlay / ShowExampleAppSimpleOverlay()
|
// [SECTION] Example app: Simple Overlay / ShowExampleAppSimpleOverlay()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Demonstrate creating a simple static window with no decoration
|
// Demonstrate creating a simple static window with no decoration
|
||||||
|
@ -7063,7 +7063,7 @@ static void ShowExampleAppSimpleOverlay(bool* p_open)
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Example App: Manipulating Window Titles / ShowExampleAppWindowTitles()
|
// [SECTION] Example app: Manipulating Window Titles / ShowExampleAppWindowTitles()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Demonstrate using "##" and "###" in identifiers to manipulate ID generation.
|
// Demonstrate using "##" and "###" in identifiers to manipulate ID generation.
|
||||||
|
@ -7095,7 +7095,7 @@ static void ShowExampleAppWindowTitles(bool*)
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Example App: Custom Rendering using ImDrawList API / ShowExampleAppCustomRendering()
|
// [SECTION] Example app: Custom Rendering using ImDrawList API / ShowExampleAppCustomRendering()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Demonstrate using the low-level ImDrawList to draw custom shapes.
|
// Demonstrate using the low-level ImDrawList to draw custom shapes.
|
||||||
|
@ -7337,7 +7337,7 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Example App: Docking, DockSpace / ShowExampleAppDockSpace()
|
// [SECTION] Example app: Docking, DockSpace / ShowExampleAppDockSpace()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Demonstrate using DockSpace() to create an explicit docking node within an existing window.
|
// Demonstrate using DockSpace() to create an explicit docking node within an existing window.
|
||||||
|
@ -7453,7 +7453,7 @@ void ShowExampleAppDockSpace(bool* p_open)
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Example App: Documents Handling / ShowExampleAppDocuments()
|
// [SECTION] Example app: Documents Handling / ShowExampleAppDocuments()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Simplified structure to mimic a Document model
|
// Simplified structure to mimic a Document model
|
||||||
|
|
|
@ -127,7 +127,7 @@ int drawable_width, drawable_height;
|
||||||
drawable_width = [view frame].size.width * [view contentScaleFactor];
|
drawable_width = [view frame].size.width * [view contentScaleFactor];
|
||||||
drawable_height = [view frame].size.height * [view contentScaleFactor];
|
drawable_height = [view frame].size.height * [view contentScaleFactor];
|
||||||
|
|
||||||
engine = new Engine(0, nullptr);
|
engine = new prism::Engine(0, nullptr);
|
||||||
|
|
||||||
app = new @APP_CLASS@();
|
app = new @APP_CLASS@();
|
||||||
engine->set_app(app);
|
engine->set_app(app);
|
||||||
|
|
|
@ -294,7 +294,7 @@ int main(int argc, char* argv[]) {
|
||||||
xcb_screen_next(&iter);
|
xcb_screen_next(&iter);
|
||||||
screen = iter.data;
|
screen = iter.data;
|
||||||
|
|
||||||
engine = new Engine(argc, argv);
|
engine = new prism::Engine(argc, argv);
|
||||||
|
|
||||||
app = new @APP_CLASS@();
|
app = new @APP_CLASS@();
|
||||||
engine->set_app(app);
|
engine->set_app(app);
|
||||||
|
|
|
@ -496,7 +496,7 @@ int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
NSApp = [NSApplication sharedApplication];
|
NSApp = [NSApplication sharedApplication];
|
||||||
|
|
||||||
engine = new Engine(argc, argv);
|
engine = new prism::Engine(argc, argv);
|
||||||
|
|
||||||
app = new @APP_CLASS@();
|
app = new @APP_CLASS@();
|
||||||
engine->set_app(app);
|
engine->set_app(app);
|
||||||
|
|
|
@ -178,7 +178,7 @@ void platform::unmute_output() {
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
SDL_Init(SDL_INIT_VIDEO);
|
SDL_Init(SDL_INIT_VIDEO);
|
||||||
|
|
||||||
engine = new Engine(argc, argv);
|
engine = new prism::Engine(argc, argv);
|
||||||
|
|
||||||
app = new @APP_CLASS@();
|
app = new @APP_CLASS@();
|
||||||
engine->set_app(app);
|
engine->set_app(app);
|
||||||
|
|
|
@ -98,7 +98,7 @@ int drawable_width, drawable_height;
|
||||||
drawable_width = [view frame].size.width * [view contentScaleFactor];
|
drawable_width = [view frame].size.width * [view contentScaleFactor];
|
||||||
drawable_height = [view frame].size.height * [view contentScaleFactor];
|
drawable_height = [view frame].size.height * [view contentScaleFactor];
|
||||||
|
|
||||||
engine = new Engine(0, nullptr);
|
engine = new prism::Engine(0, nullptr);
|
||||||
|
|
||||||
app = new @APP_CLASS@();
|
app = new @APP_CLASS@();
|
||||||
engine->set_app(app);
|
engine->set_app(app);
|
||||||
|
|
|
@ -144,7 +144,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow
|
||||||
instance = hInstance;
|
instance = hInstance;
|
||||||
cmdShow = nCmdShow;
|
cmdShow = nCmdShow;
|
||||||
|
|
||||||
engine = new Engine(0, nullptr);
|
engine = new prism::Engine(0, nullptr);
|
||||||
|
|
||||||
ginterface = new GFXVulkan();
|
ginterface = new GFXVulkan();
|
||||||
if(ginterface->initialize(GFXCreateInfo())) {
|
if(ginterface->initialize(GFXCreateInfo())) {
|
||||||
|
|
|
@ -102,7 +102,7 @@ AssetType get_asset_type() {
|
||||||
|
|
||||||
constexpr int thumbnail_resolution = 256;
|
constexpr int thumbnail_resolution = 256;
|
||||||
|
|
||||||
class CommonEditor : public App {
|
class CommonEditor : public prism::app {
|
||||||
public:
|
public:
|
||||||
CommonEditor(std::string id);
|
CommonEditor(std::string id);
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ 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");
|
file::set_domain_path(file::Domain::App, "data");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -24,7 +24,7 @@ std::string get_filename(const std::string path) {
|
||||||
|
|
||||||
std::vector<Editor*> editors;
|
std::vector<Editor*> editors;
|
||||||
|
|
||||||
void app_main(Engine* engine) {
|
void app_main(prism::Engine* engine) {
|
||||||
CommonEditor* editor = (CommonEditor*)engine->get_app();
|
CommonEditor* editor = (CommonEditor*)engine->get_app();
|
||||||
|
|
||||||
platform::open_window("Prism Editor",
|
platform::open_window("Prism Editor",
|
||||||
|
|
Reference in a new issue