Fill out web platform backend with a main loop
This commit is contained in:
parent
57c2bbc83a
commit
79bc598ef9
2 changed files with 175 additions and 2 deletions
|
@ -5,6 +5,8 @@ add_platform(
|
||||||
main.cpp.in
|
main.cpp.in
|
||||||
LINK_LIBRARIES
|
LINK_LIBRARIES
|
||||||
Core
|
Core
|
||||||
|
GFXWebGPU
|
||||||
|
Log
|
||||||
)
|
)
|
||||||
|
|
||||||
function(add_platform_commands target)
|
function(add_platform_commands target)
|
||||||
|
|
|
@ -1,7 +1,178 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <@APP_INCLUDE@>
|
||||||
|
#include <emscripten/html5.h>
|
||||||
|
|
||||||
|
#include "engine.hpp"
|
||||||
|
#include "platform.hpp"
|
||||||
|
#include "gfx_webgpu.hpp"
|
||||||
|
#include "file.hpp"
|
||||||
|
|
||||||
|
@APP_CLASS@* app = nullptr;
|
||||||
|
GFX* gfx_interface = nullptr;
|
||||||
|
|
||||||
|
EM_BOOL draw(double time, void *userData) {
|
||||||
|
printf("Draw\n");
|
||||||
|
|
||||||
|
engine->update(time);
|
||||||
|
engine->begin_frame(time);
|
||||||
|
|
||||||
|
engine->render((void*)1);
|
||||||
|
|
||||||
|
engine->end_frame();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
printf("Hello, world!\n");
|
engine = new prism::engine(argc, argv);
|
||||||
|
|
||||||
|
app = new @APP_CLASS@();
|
||||||
|
engine->set_app(app);
|
||||||
|
|
||||||
|
GFXCreateInfo info = {};
|
||||||
|
gfx_interface = new GFXWebGPU();
|
||||||
|
if(gfx_interface->initialize(info)) {
|
||||||
|
engine->set_gfx(gfx_interface);
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
app_main(engine);
|
||||||
|
|
||||||
|
engine->add_window(nullptr, (void*)1, {100, 100}});
|
||||||
|
app->initialize_render();
|
||||||
|
|
||||||
|
emscripten_request_animation_frame_loop(draw, nullptr);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void platform::capture_mouse(const bool capture) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
PlatformTheme platform::get_theme() {
|
||||||
|
return PlatformTheme::Light;
|
||||||
|
}
|
||||||
|
|
||||||
|
void platform::begin_text_input() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void platform::end_text_input() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void* platform::create_native_surface(platform::window_ptr index, void* instance) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool platform::is_main_window(platform::window_ptr index) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<const char*> platform::get_native_surface_extension() {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* platform::get_name() {
|
||||||
|
return "Web";
|
||||||
|
}
|
||||||
|
|
||||||
|
void prism::set_domain_path(const prism::domain domain, const prism::path& path) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
prism::path prism::get_writeable_directory() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Reference in a new issue