scoop boob
This commit is contained in:
parent
2f2a134777
commit
f722ee0cf6
3 changed files with 46 additions and 4 deletions
|
@ -18,6 +18,10 @@ set(CMAKE_CXX_FLAGS
|
|||
"${CMAKE_CXX_FLAGS} --shell-file ../src/client/shell.html")
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='[\"bmp\"]'")
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -s EXPORTED_FUNCTIONS='[\"_main\", \"_resize_context\"]'")
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\"]'")
|
||||
#endif()
|
||||
|
||||
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
||||
|
|
|
@ -18,8 +18,8 @@ void draw();
|
|||
int main(int argc, char** argv) {
|
||||
using namespace sosc;
|
||||
|
||||
/*if(argc != 3)
|
||||
return -1;*/
|
||||
if(argc != 3)
|
||||
return -1;
|
||||
|
||||
int client_width = std::stoi(argv[1]),
|
||||
client_height = std::stoi(argv[2]);
|
||||
|
@ -50,6 +50,8 @@ int main(int argc, char** argv) {
|
|||
if(glewInit() != GLEW_OK)
|
||||
return -1;
|
||||
|
||||
EM_ASM(setup_resize_event());
|
||||
|
||||
ui::font_init_subsystem(_ctx.window);
|
||||
_ctx.font = new ui::Font(
|
||||
SOSC_RESC("fonts/scape.bmp"),
|
||||
|
@ -64,14 +66,40 @@ int main(int argc, char** argv) {
|
|||
|
||||
emscripten_set_main_loop(draw, 0, 1);
|
||||
|
||||
std::cout << "end test" << std::endl;
|
||||
_ctx.font->Unload();
|
||||
_ctx.text->Destroy();
|
||||
|
||||
ui::font_deinit_subsystem();
|
||||
SDL_GL_DeleteContext(_ctx.gl_ctx);
|
||||
SDL_DestroyWindow(_ctx.window);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void draw() {
|
||||
using namespace sosc;
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glClearColor(.25, .25, .25, 1);
|
||||
|
||||
_ctx.text->Render();
|
||||
|
||||
SDL_GL_SwapWindow(_ctx.window);
|
||||
|
||||
SDL_Event event;
|
||||
while(SDL_PollEvent(&event)) {
|
||||
std::cout << "an event" << std::endl;
|
||||
|
||||
if(event.type == SDL_WINDOWEVENT &&
|
||||
event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)
|
||||
{
|
||||
glViewport(0, 0, event.window.data1, event.window.data2);
|
||||
ui::font_window_changed(_ctx.window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern "C"
|
||||
void resize_context(int width, int height) {
|
||||
SDL_SetWindowSize(_ctx.window, width, height);
|
||||
}
|
|
@ -48,6 +48,16 @@
|
|||
],
|
||||
canvas: document.getElementById("canvas")
|
||||
};
|
||||
|
||||
function setup_resize_event() {
|
||||
window.onresize = function() {
|
||||
Module.ccall(
|
||||
"resize_context",
|
||||
"void", ["number", "number"],
|
||||
[window.innerWidth, window.innerHeight]
|
||||
);
|
||||
};
|
||||
}
|
||||
</script>
|
||||
{{{ SCRIPT }}}
|
||||
</body>
|
||||
|
|
Loading…
Reference in a new issue