From 473b3722ce8e0643937afd79635de1c126f16e7d Mon Sep 17 00:00:00 2001 From: Jonathan Frank <41275844+Jonathhhan@users.noreply.github.com> Date: Fri, 2 Aug 2024 00:56:58 +0200 Subject: [PATCH 1/3] Add files via upload --- .../src/ofxAppEmscriptenWindow.cpp | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp index 9da595ce412..96ab1751be3 100644 --- a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp +++ b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp @@ -50,21 +50,21 @@ void ofxAppEmscriptenWindow::setup(const ofGLESWindowSettings & settings){ _renderer = std::make_shared(this); ((ofGLProgrammableRenderer*)_renderer.get())->setup(2,0); - emscripten_set_keydown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,1,&keydown_cb); - emscripten_set_keyup_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,1,&keyup_cb); + emscripten_set_keydown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &keydown_cb); + emscripten_set_keyup_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &keyup_cb); - emscripten_set_mousedown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,1,&mousedown_cb); - emscripten_set_mouseup_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,1,&mouseup_cb); - emscripten_set_mousemove_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,1,&mousemoved_cb); - emscripten_set_mouseenter_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,1,&mouseenter_cb); - emscripten_set_mouseleave_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,1,&mouseleave_cb); - - emscripten_set_touchstart_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,1,&touch_cb); - emscripten_set_touchend_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,1,&touch_cb); - emscripten_set_touchmove_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,1,&touch_cb); - emscripten_set_touchcancel_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,1,&touch_cb); + emscripten_set_mousedown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &mousedown_cb); + emscripten_set_mouseup_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &mouseup_cb); + emscripten_set_mousemove_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &mousemoved_cb); + emscripten_set_mouseenter_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &mouseenter_cb); + emscripten_set_mouseleave_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &mouseleave_cb); + + emscripten_set_touchstart_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &touch_cb); + emscripten_set_touchend_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &touch_cb); + emscripten_set_touchmove_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &touch_cb); + emscripten_set_touchcancel_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &touch_cb); - emscripten_set_wheel_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,1,&mousescrolled_cb); + emscripten_set_wheel_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &mousescrolled_cb); // the following locks up the window for some reason..... //emscripten_set_resize_callback(const char *target, void *userData, EM_BOOL useCapture, em_ui_callback_func callback) @@ -163,7 +163,7 @@ void ofxAppEmscriptenWindow::display_cb(){ } //------------------------------------------------------------ -int ofxAppEmscriptenWindow::keydown_cb(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData){ +EM_BOOL ofxAppEmscriptenWindow::keydown_cb(int eventType, const EmscriptenKeyboardEvent * keyEvent, void * userData) { int key = keyEvent->key[0]; std::string id = keyEvent->key; if(key == 0){ @@ -254,7 +254,7 @@ int ofxAppEmscriptenWindow::keydown_cb(int eventType, const EmscriptenKeyboardEv } //------------------------------------------------------------ -int ofxAppEmscriptenWindow::keyup_cb(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData){ +EM_BOOL ofxAppEmscriptenWindow::keyup_cb(int eventType, const EmscriptenKeyboardEvent * keyEvent, void * userData) { int key = keyEvent->key[0]; std::string id = keyEvent->key; if(key == 0){ @@ -345,7 +345,7 @@ int ofxAppEmscriptenWindow::keyup_cb(int eventType, const EmscriptenKeyboardEven } //------------------------------------------------------------ -int ofxAppEmscriptenWindow::mousedown_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData){ +EM_BOOL ofxAppEmscriptenWindow::mousedown_cb(int eventType, const EmscriptenMouseEvent * mouseEvent, void * userData) { float mouseX = mouseEvent->targetX - EM_ASM_INT(return canvas.getBoundingClientRect().left); float mouseY = mouseEvent->targetY - EM_ASM_INT(return canvas.getBoundingClientRect().top); int canvasWidth, canvasHeight; @@ -359,7 +359,7 @@ int ofxAppEmscriptenWindow::mousedown_cb(int eventType, const EmscriptenMouseEve } //------------------------------------------------------------ -int ofxAppEmscriptenWindow::mouseup_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData){ +EM_BOOL ofxAppEmscriptenWindow::mouseup_cb(int eventType, const EmscriptenMouseEvent * mouseEvent, void * userData) { float mouseX = mouseEvent->targetX - EM_ASM_INT(return canvas.getBoundingClientRect().left); float mouseY = mouseEvent->targetY - EM_ASM_INT(return canvas.getBoundingClientRect().top); int canvasWidth, canvasHeight; @@ -373,7 +373,7 @@ int ofxAppEmscriptenWindow::mouseup_cb(int eventType, const EmscriptenMouseEvent } //------------------------------------------------------------ -int ofxAppEmscriptenWindow::mousemoved_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData){ +EM_BOOL ofxAppEmscriptenWindow::mousemoved_cb(int eventType, const EmscriptenMouseEvent * mouseEvent, void * userData) { float mouseX = mouseEvent->targetX - EM_ASM_INT(return canvas.getBoundingClientRect().left); float mouseY = mouseEvent->targetY - EM_ASM_INT(return canvas.getBoundingClientRect().top); int canvasWidth, canvasHeight; @@ -393,13 +393,13 @@ int ofxAppEmscriptenWindow::mousemoved_cb(int eventType, const EmscriptenMouseEv } //------------------------------------------------------------ -int ofxAppEmscriptenWindow::mousescrolled_cb(int eventType, const EmscriptenWheelEvent *wheelEvent, void *userData){ +EM_BOOL ofxAppEmscriptenWindow::mousescrolled_cb(int eventType, const EmscriptenWheelEvent * wheelEvent, void * userData) { instance->events().notifyMouseScrolled(ofGetMouseX(), ofGetMouseY(), wheelEvent->deltaX / 100, wheelEvent->deltaY / 100); return 0; } //------------------------------------------------------------ -int ofxAppEmscriptenWindow::mouseenter_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData){ +EM_BOOL ofxAppEmscriptenWindow::mouseenter_cb(int eventType, const EmscriptenMouseEvent * mouseEvent, void * userData) { float mouseX = mouseEvent->targetX - EM_ASM_INT(return canvas.getBoundingClientRect().left); float mouseY = mouseEvent->targetY - EM_ASM_INT(return canvas.getBoundingClientRect().top); int canvasWidth, canvasHeight; @@ -411,7 +411,7 @@ int ofxAppEmscriptenWindow::mouseenter_cb(int eventType, const EmscriptenMouseEv } //------------------------------------------------------------ -int ofxAppEmscriptenWindow::mouseleave_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData){ +EM_BOOL ofxAppEmscriptenWindow::mouseleave_cb(int eventType, const EmscriptenMouseEvent * mouseEvent, void * userData) { float mouseX = mouseEvent->targetX - EM_ASM_INT(return canvas.getBoundingClientRect().left); float mouseY = mouseEvent->targetY - EM_ASM_INT(return canvas.getBoundingClientRect().top); int canvasWidth, canvasHeight; @@ -423,7 +423,7 @@ int ofxAppEmscriptenWindow::mouseleave_cb(int eventType, const EmscriptenMouseEv } //------------------------------------------------------------ -int ofxAppEmscriptenWindow::touch_cb(int eventType, const EmscriptenTouchEvent* e, void* userData) { +EM_BOOL ofxAppEmscriptenWindow::touch_cb(int eventType, const EmscriptenTouchEvent * e, void * userData) { float boundingX = EM_ASM_INT(return canvas.getBoundingClientRect().left); float boundingY = EM_ASM_INT(return canvas.getBoundingClientRect().top); int canvasWidth, canvasHeight; From e65b0b0995a1cf885db3e4c131940a5aab63a7da Mon Sep 17 00:00:00 2001 From: Jonathan Frank <41275844+Jonathhhan@users.noreply.github.com> Date: Fri, 2 Aug 2024 01:02:12 +0200 Subject: [PATCH 2/3] Update ofxAppEmscriptenWindow.cpp --- .../src/ofxAppEmscriptenWindow.cpp | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp index 96ab1751be3..3518998e13a 100644 --- a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp +++ b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp @@ -28,43 +28,43 @@ ofxAppEmscriptenWindow::~ofxAppEmscriptenWindow() { //------------------------------------------------------------ void ofxAppEmscriptenWindow::setup(const ofGLESWindowSettings & settings){ - setWindowShape(settings.getWidth(),settings.getHeight()); + setWindowShape(settings.getWidth(),settings.getHeight()); - EmscriptenWebGLContextAttributes attrs; - emscripten_webgl_init_context_attributes(&attrs); + EmscriptenWebGLContextAttributes attrs; + emscripten_webgl_init_context_attributes(&attrs); /// when setting explicitSwapControl to 0 it is emscripten that is in charge of swapping on each render call. - attrs.explicitSwapControl = 0; - attrs.depth = 1; - attrs.stencil = 1; - attrs.antialias = 1; - attrs.majorVersion = 2; - attrs.minorVersion = 0; - attrs.alpha = 0; - - context = emscripten_webgl_create_context("#canvas", &attrs); - assert(context); + attrs.explicitSwapControl = 0; + attrs.depth = 1; + attrs.stencil = 1; + attrs.antialias = 1; + attrs.majorVersion = 2; + attrs.minorVersion = 0; + attrs.alpha = 0; + + context = emscripten_webgl_create_context("#canvas", &attrs); + assert(context); - makeCurrent(); + makeCurrent(); - _renderer = std::make_shared(this); - ((ofGLProgrammableRenderer*)_renderer.get())->setup(2,0); + _renderer = std::make_shared(this); + ((ofGLProgrammableRenderer*)_renderer.get())->setup(2,0); - emscripten_set_keydown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &keydown_cb); + emscripten_set_keydown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &keydown_cb); emscripten_set_keyup_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &keyup_cb); - emscripten_set_mousedown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &mousedown_cb); + emscripten_set_mousedown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &mousedown_cb); emscripten_set_mouseup_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &mouseup_cb); emscripten_set_mousemove_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &mousemoved_cb); emscripten_set_mouseenter_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &mouseenter_cb); emscripten_set_mouseleave_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &mouseleave_cb); - emscripten_set_touchstart_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &touch_cb); + emscripten_set_touchstart_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &touch_cb); emscripten_set_touchend_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &touch_cb); emscripten_set_touchmove_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &touch_cb); emscripten_set_touchcancel_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &touch_cb); - emscripten_set_wheel_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &mousescrolled_cb); + emscripten_set_wheel_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, true, &mousescrolled_cb); // the following locks up the window for some reason..... //emscripten_set_resize_callback(const char *target, void *userData, EM_BOOL useCapture, em_ui_callback_func callback) From 92dc58d0d77ebfd676e505dc4094e46eaa0e3ea0 Mon Sep 17 00:00:00 2001 From: Jonathan Frank <41275844+Jonathhhan@users.noreply.github.com> Date: Fri, 2 Aug 2024 01:02:31 +0200 Subject: [PATCH 3/3] Add files via upload --- .../ofxEmscripten/src/ofxAppEmscriptenWindow.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.h b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.h index 4d871d73be9..a26fd7b1b08 100644 --- a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.h +++ b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.h @@ -84,18 +84,18 @@ class ofxAppEmscriptenWindow: public ofAppBaseGLESWindow { // static int getUniqueId(); static void display_cb(); - static int keydown_cb(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData); - static int keyup_cb(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData); + static EM_BOOL keydown_cb(int eventType, const EmscriptenKeyboardEvent * keyEvent, void * userData); + static EM_BOOL keyup_cb(int eventType, const EmscriptenKeyboardEvent * keyEvent, void * userData); - static int mousedown_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData); - static int mouseup_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData); - static int mousemoved_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData); - static int mouseenter_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData); - static int mouseleave_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData); + static EM_BOOL mousedown_cb(int eventType, const EmscriptenMouseEvent * mouseEvent, void * userData); + static EM_BOOL mouseup_cb(int eventType, const EmscriptenMouseEvent * mouseEvent, void * userData); + static EM_BOOL mousemoved_cb(int eventType, const EmscriptenMouseEvent * mouseEvent, void * userData); + static EM_BOOL mouseenter_cb(int eventType, const EmscriptenMouseEvent * mouseEvent, void * userData); + static EM_BOOL mouseleave_cb(int eventType, const EmscriptenMouseEvent * mouseEvent, void * userData); - static int touch_cb(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData); + static EM_BOOL touch_cb(int eventType, const EmscriptenTouchEvent * touchEvent, void * userData); - static int mousescrolled_cb(int eventType, const EmscriptenWheelEvent *wheelEvent, void *userData); + static EM_BOOL mousescrolled_cb(int eventType, const EmscriptenWheelEvent * wheelEvent, void * userData); static EM_BOOL emscripten_game_window_resized_callback(int eventType, const void *reserved, void *userData);