2022-02-18 16:36:48 -05:00
|
|
|
#include <stdio.h>
|
2022-02-18 16:57:14 -05:00
|
|
|
#include <@APP_INCLUDE@>
|
|
|
|
#include <emscripten/html5.h>
|
|
|
|
|
|
|
|
#include "engine.hpp"
|
|
|
|
#include "platform.hpp"
|
|
|
|
#include "gfx_webgpu.hpp"
|
|
|
|
#include "file.hpp"
|
2022-02-20 20:05:05 -05:00
|
|
|
#include "string_utils.hpp"
|
2022-02-18 16:57:14 -05:00
|
|
|
|
|
|
|
@APP_CLASS@* app = nullptr;
|
|
|
|
GFX* gfx_interface = nullptr;
|
|
|
|
|
|
|
|
EM_BOOL draw(double time, void *userData) {
|
|
|
|
engine->update(time);
|
|
|
|
engine->begin_frame(time);
|
|
|
|
|
|
|
|
engine->render((void*)1);
|
|
|
|
|
|
|
|
engine->end_frame();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2022-02-18 16:36:48 -05:00
|
|
|
|
2022-02-18 17:19:37 -05:00
|
|
|
extern "C" int __main__(int argc, char* argv[]) {
|
2022-02-18 16:57:14 -05:00
|
|
|
engine = new prism::engine(argc, argv);
|
|
|
|
|
|
|
|
GFXCreateInfo info = {};
|
|
|
|
gfx_interface = new GFXWebGPU();
|
|
|
|
if(gfx_interface->initialize(info)) {
|
|
|
|
engine->set_gfx(gfx_interface);
|
|
|
|
} else {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-03-06 19:38:04 -05:00
|
|
|
app = new @APP_CLASS@();
|
2022-02-18 16:57:14 -05:00
|
|
|
app_main(engine);
|
2022-03-06 19:38:04 -05:00
|
|
|
engine->set_app(app);
|
2022-02-18 16:57:14 -05:00
|
|
|
|
2022-02-18 17:19:37 -05:00
|
|
|
engine->add_window((void*)1, (void*)1, {100, 100});
|
2022-02-18 16:57:14 -05:00
|
|
|
app->initialize_render();
|
|
|
|
|
|
|
|
emscripten_request_animation_frame_loop(draw, nullptr);
|
2022-02-18 16:36:48 -05:00
|
|
|
|
|
|
|
return 0;
|
2022-02-18 16:57:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void platform::capture_mouse(const bool capture) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
PlatformTheme platform::get_theme() {
|
|
|
|
return PlatformTheme::Light;
|
|
|
|
}
|
|
|
|
|
|
|
|
void platform::begin_text_input() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void platform::end_text_input() {
|
|
|
|
}
|
|
|
|
|
2022-03-06 19:38:04 -05:00
|
|
|
void* platform::create_surface(window_ptr window, void* surface_creation_info) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void* platform::get_next_image(window_ptr window) {
|
2022-02-18 16:57:14 -05:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool platform::is_main_window(platform::window_ptr index) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-03-06 19:38:04 -05:00
|
|
|
void* platform::get_context_information() {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool platform::supports_context(GFXContext context) {
|
|
|
|
return true;
|
2022-02-18 16:57:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void platform::show_window(const platform::window_ptr index) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool platform::supports_feature(const PlatformFeature feature) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
prism::Offset platform::get_cursor_position() {
|
|
|
|
return {0, 0};
|
|
|
|
}
|
|
|
|
|
|
|
|
std::tuple<float, float> platform::get_right_stick_position() {
|
|
|
|
return {0, 0};
|
|
|
|
}
|
|
|
|
|
|
|
|
std::tuple<float, float> platform::get_left_stick_position() {
|
|
|
|
return {0, 0};
|
|
|
|
}
|
|
|
|
|
|
|
|
bool platform::get_key_down(InputButton key) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
platform::window_ptr platform::open_window(const std::string_view title, const prism::Rectangle rect, const WindowFlags flags) {
|
|
|
|
return (void*)1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void platform::set_window_title(const platform::window_ptr index, const std::string_view title) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool platform::is_window_focused(const platform::window_ptr index) {
|
2022-02-18 17:38:41 -05:00
|
|
|
return true;
|
2022-02-18 16:57:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void platform::set_window_focused(const platform::window_ptr index) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
prism::Extent platform::get_window_size(const platform::window_ptr index) {
|
|
|
|
return {100, 100};
|
|
|
|
}
|
|
|
|
|
|
|
|
prism::Extent platform::get_window_drawable_size(const platform::window_ptr index) {
|
|
|
|
return {100, 100};
|
|
|
|
}
|
|
|
|
|
|
|
|
prism::Offset platform::get_window_position(const platform::window_ptr index) {
|
2022-02-18 17:38:41 -05:00
|
|
|
return {0, 0};
|
2022-02-18 16:57:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void platform::set_window_size(const platform::window_ptr index, const prism::Extent extent) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void platform::set_window_position(const platform::window_ptr index, const prism::Offset offset) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void platform::close_window(const platform::window_ptr index) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int platform::get_keycode(const InputButton button) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
prism::Rectangle platform::get_monitor_resolution() {
|
|
|
|
return {0, 0, 100, 100};
|
|
|
|
}
|
|
|
|
|
|
|
|
prism::Rectangle platform::get_monitor_work_area() {
|
|
|
|
return {0, 0, 100, 100};
|
|
|
|
}
|
|
|
|
|
|
|
|
prism::Offset platform::get_screen_cursor_position() {
|
2022-02-18 17:38:41 -05:00
|
|
|
return {0, 0};
|
2022-02-18 16:57:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool platform::get_mouse_button_down(const int index) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
float platform::get_monitor_dpi() {
|
|
|
|
return 1.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::tuple<float, float> platform::get_wheel_delta() {
|
2022-02-18 17:38:41 -05:00
|
|
|
return {0, 0};
|
2022-02-18 16:57:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
const char* platform::get_name() {
|
|
|
|
return "Web";
|
|
|
|
}
|
|
|
|
|
|
|
|
void prism::set_domain_path(const prism::domain domain, const prism::path& path) {
|
2022-02-20 20:05:05 -05:00
|
|
|
domain_data[(int)domain] = replace_substring(path.string(), "{resource_dir}/", "");
|
2022-02-18 16:57:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
prism::path prism::get_writeable_directory() {
|
|
|
|
|
|
|
|
}
|