Add template html for Emscripten builds
All checks were successful
Run tests / Run tests (push) Successful in 8m11s
All checks were successful
Run tests / Run tests (push) Successful in 8m11s
This commit is contained in:
parent
5126dc74f8
commit
7dd55d94a9
4 changed files with 32 additions and 2 deletions
|
|
@ -61,7 +61,6 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL Emscripten)
|
|||
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
list(APPEND PSEMEK_CXX_FLAGS -g)
|
||||
endif()
|
||||
set(CMAKE_EXECUTABLE_SUFFIX ".html" PARENT_SCOPE) # we want to build html, not js
|
||||
else()
|
||||
find_package(Threads REQUIRED)
|
||||
set(OpenGL_GL_PREFERENCE LEGACY)
|
||||
|
|
|
|||
|
|
@ -21,8 +21,13 @@ namespace psemek::sdl2
|
|||
{
|
||||
|
||||
window::window(psemek::app::application::options const & options)
|
||||
: sdl_init_(init(SDL_INIT_EVENTS | SDL_INIT_VIDEO))
|
||||
{
|
||||
#ifdef __EMSCRIPTEN__
|
||||
SDL_SetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT, "#canvas");
|
||||
#endif
|
||||
|
||||
sdl_init_ = init(SDL_INIT_EVENTS | SDL_INIT_VIDEO);
|
||||
|
||||
std::uint32_t flags = SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE;
|
||||
if (options.highdpi) flags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,13 @@ function(psemek_add_executable_impl target is_application)
|
|||
else()
|
||||
target_link_libraries(${target} PUBLIC ${PSEMEK_BACKEND_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL Emscripten)
|
||||
target_link_options(${target} PRIVATE
|
||||
"--shell-file=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/web/template.html"
|
||||
)
|
||||
set_target_properties(${target} PROPERTIES SUFFIX ".html")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
install(TARGETS ${target})
|
||||
|
|
|
|||
19
package/web/template.html
Normal file
19
package/web/template.html
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<style>
|
||||
body { margin: 0; padding: 0; }
|
||||
canvas { display: block; width: 100%; height: 100%; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="canvas" oncontextmenu="event.preventDefault()"></canvas>
|
||||
<script type="text/javascript">
|
||||
var Module = {
|
||||
canvas: document.getElementById('canvas'),
|
||||
};
|
||||
</script>
|
||||
{{{ SCRIPT }}}
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue