Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emscripten 3.1.64 - Latest Libraries #8056

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/of.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
env:
TARGET: ${{matrix.cfg.target}}
steps:

- uses: actions/checkout@v4
- name: Docker Step
run: "docker run -di --name emscripten -v $PWD:/src emscripten/emsdk:3.1.73 bash"
Expand Down
121 changes: 66 additions & 55 deletions addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,24 @@ void ofxAppEmscriptenWindow::setup(const ofGLESWindowSettings & settings){
_renderer = std::make_shared<ofGLProgrammableRenderer>(this);
((ofGLProgrammableRenderer*)_renderer.get())->setup(2,0);

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_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, true, &mousescrolled_cb);
emscripten_set_keydown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,useCapture,&keydown_cb);
emscripten_set_keyup_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,useCapture,&keyup_cb);

emscripten_set_mousedown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,useCapture,&mousedown_cb);
emscripten_set_mouseup_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,useCapture,&mouseup_cb);
emscripten_set_mousemove_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,useCapture,&mousemoved_cb);
emscripten_set_mouseenter_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,useCapture,&mouseenter_cb);
emscripten_set_mouseleave_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,useCapture,&mouseleave_cb);

emscripten_set_touchstart_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,useCapture,&touch_cb);
emscripten_set_touchend_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,useCapture,&touch_cb);
emscripten_set_touchmove_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,useCapture,&touch_cb);
emscripten_set_touchcancel_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,useCapture,&touch_cb);

emscripten_set_wheel_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,useCapture,&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)
// emscripten_set_resize_callback(const char *target, void *userData, EM_BOOL useCapture, em_ui_callback_func callback)
// emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, 1, &emscripten_window_resized_callback );

mStartWindowMode = settings.windowMode;
Expand Down Expand Up @@ -247,10 +247,10 @@ EM_BOOL ofxAppEmscriptenWindow::keydown_cb(int eventType, const EmscriptenKeyboa
}else if(id == "Ü"){
key = 220;
}else if(id == "Dead" || id == "NumLock" || id == "ScrollLock" || id == "CapsLock" || id == "Pause" || key < 0){
return 0;
return true;
}
instance->events().notifyKeyPressed(key);
return 0;
return true;
}

//------------------------------------------------------------
Expand Down Expand Up @@ -338,44 +338,48 @@ EM_BOOL ofxAppEmscriptenWindow::keyup_cb(int eventType, const EmscriptenKeyboard
}else if(id == "Ü"){
key = 220;
}else if(id == "Dead" || id == "NumLock" || id == "ScrollLock" || id == "CapsLock" || id == "Pause" || key < 0){
return 0;
return true;
}
instance->events().notifyKeyReleased(key);
return 0;
return true;
}

//------------------------------------------------------------
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);

EM_BOOL ofxAppEmscriptenWindow::mousedown_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData){
double mouseX = mouseEvent->targetX - EM_ASM_DOUBLE(return canvas.getBoundingClientRect().left);
double mouseY = mouseEvent->targetY - EM_ASM_DOUBLE(return canvas.getBoundingClientRect().top);
int canvasWidth, canvasHeight;
emscripten_get_canvas_element_size("#canvas", &canvasWidth, &canvasHeight);
double cssWidth, cssHeight;
emscripten_get_element_css_size("#canvas", &cssWidth, &cssHeight);
if(mouseX * canvasWidth / cssWidth >= 0 && mouseX * canvasWidth / cssWidth < canvasWidth && mouseY * canvasHeight / cssHeight >= 0 && mouseY * canvasHeight / cssHeight < canvasHeight){
instance->events().notifyMousePressed(mouseX * canvasWidth / cssWidth, mouseY * canvasHeight / cssHeight, mouseEvent->button);
}
return 0;
return true;
}
EM_BOOL ofxAppEmscriptenWindow::rescale(int* x, int* y) {

}

//------------------------------------------------------------
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);
double mouseX = mouseEvent->targetX - EM_ASM_DOUBLE(return canvas.getBoundingClientRect().left);
double mouseY = mouseEvent->targetY - EM_ASM_DOUBLE(return canvas.getBoundingClientRect().top);
int canvasWidth, canvasHeight;
emscripten_get_canvas_element_size("#canvas", &canvasWidth, &canvasHeight);
double cssWidth, cssHeight;
emscripten_get_element_css_size("#canvas", &cssWidth, &cssHeight);
if(ofGetMousePressed()){
instance->events().notifyMouseReleased(mouseX * canvasWidth / cssWidth, mouseY * canvasHeight / cssHeight, mouseEvent->button);
}
return 0;
return true;
}

//------------------------------------------------------------
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);
double mouseX = mouseEvent->targetX - EM_ASM_DOUBLE(return canvas.getBoundingClientRect().left);
double mouseY = mouseEvent->targetY - EM_ASM_DOUBLE(return canvas.getBoundingClientRect().top);
int canvasWidth, canvasHeight;
emscripten_get_canvas_element_size("#canvas", &canvasWidth, &canvasHeight);
double cssWidth, cssHeight;
Expand All @@ -389,43 +393,43 @@ EM_BOOL ofxAppEmscriptenWindow::mousemoved_cb(int eventType, const EmscriptenMou
}else if(mouseX * canvasWidth / cssWidth >= 0 && mouseX * canvasWidth / cssWidth < canvasWidth && mouseY * canvasHeight / cssHeight >= 0 && mouseY * canvasHeight / cssHeight < canvasHeight){
instance->events().notifyMouseMoved(mouseX * canvasWidth / cssWidth, mouseY * canvasHeight / cssHeight);
}
return 0;
return true;
}

//------------------------------------------------------------
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;
return true;
}

//------------------------------------------------------------
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);
double mouseX = mouseEvent->targetX - EM_ASM_DOUBLE(return canvas.getBoundingClientRect().left);
double mouseY = mouseEvent->targetY - EM_ASM_DOUBLE(return canvas.getBoundingClientRect().top);
int canvasWidth, canvasHeight;
emscripten_get_canvas_element_size("#canvas", &canvasWidth, &canvasHeight);
double cssWidth, cssHeight;
emscripten_get_element_css_size("#canvas", &cssWidth, &cssHeight);
instance->events().notifyMouseEntered(mouseX * canvasWidth / cssWidth, mouseY * canvasHeight / cssHeight);
return 0;
return true;
}

//------------------------------------------------------------
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);
double mouseX = mouseEvent->targetX - EM_ASM_DOUBLE(return canvas.getBoundingClientRect().left);
double mouseY = mouseEvent->targetY - EM_ASM_DOUBLE(return canvas.getBoundingClientRect().top);
int canvasWidth, canvasHeight;
emscripten_get_canvas_element_size("#canvas", &canvasWidth, &canvasHeight);
double cssWidth, cssHeight;
emscripten_get_element_css_size("#canvas", &cssWidth, &cssHeight);
instance->events().notifyMouseExited(mouseX * canvasWidth / cssWidth, mouseY * canvasHeight / cssHeight);
return 0;
return true;
}

//------------------------------------------------------------
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);
double boundingX = EM_ASM_DOUBLE(return canvas.getBoundingClientRect().left);
double boundingY = EM_ASM_DOUBLE(return canvas.getBoundingClientRect().top);
int canvasWidth, canvasHeight;
emscripten_get_canvas_element_size("#canvas", &canvasWidth, &canvasHeight);
double cssWidth, cssHeight;
Expand All @@ -445,7 +449,7 @@ EM_BOOL ofxAppEmscriptenWindow::touch_cb(int eventType, const EmscriptenTouchEve
touchArgsType = ofTouchEventArgs::cancel;
break;
default:
return 1;
return false;
}
int numTouches = e->numTouches;
for (int i = 0; i < numTouches; i++) {
Expand All @@ -468,7 +472,7 @@ EM_BOOL ofxAppEmscriptenWindow::touch_cb(int eventType, const EmscriptenTouchEve
instance->events().notifyMouseEvent(args);
}
}
return 0;
return true;
}

//------------------------------------------------------------
Expand All @@ -478,8 +482,8 @@ void ofxAppEmscriptenWindow::hideCursor(){

//------------------------------------------------------------
void ofxAppEmscriptenWindow::setWindowShape(int w, int h){
emscripten_set_canvas_size(w,h);
// emscripten_set_canvas_element_size("#canvas", w, h);
// emscripten_set_canvas_size(w,h);
emscripten_set_canvas_element_size("#canvas", w, h);
}

//------------------------------------------------------------
Expand All @@ -497,6 +501,10 @@ glm::vec2 ofxAppEmscriptenWindow::getWindowSize(){
int width;
int height;
emscripten_get_canvas_element_size("canvas", &width, &height);
if(instance) {
instance->mCachedWidth = width;
instance->mCachedHeight = height;
}
return glm::vec2(width,height);
}

Expand Down Expand Up @@ -635,7 +643,7 @@ void ofxAppEmscriptenWindow::startRender(){
renderer()->startRender();
}

//------------------------------------------------------------
//-----------------------------------------EMSCRIPTEN_RESULT-------------------
void ofxAppEmscriptenWindow::finishRender(){
renderer()->finishRender();
}
Expand All @@ -646,20 +654,23 @@ EM_BOOL ofxAppEmscriptenWindow::emscripten_game_window_resized_callback(int even
if(instance->mLastResizeFrameNum != ofGetFrameNum() ) {
double twidth, theight;
emscripten_get_element_css_size("canvas", &twidth, &theight);
int iwidth = twidth;
int iheight = theight;
int iwidth = static_cast<int>(twidth);
int iheight = static_cast<int>(theight);

emscripten_set_canvas_element_size("#canvas", int(twidth), int(theight));
emscripten_set_canvas_element_size("#canvas", twidth, theight);
ofLogVerbose("ofxAppEmscriptenWindow :: trying to set the canvas size to: ") << twidth << " x " << theight << " num frames: " << instance->nFramesSinceWindowResized;
updateCanvas(iwidth, iheight);

if( iwidth != instance->mCachedWidth || iheight != instance->mCachedHeight ) {
instance->mCachedWidth = iwidth;
instance->mCachedHeight = iheight;

instance->mLastResizeFrameNum = ofGetFrameNum();
instance->nFramesSinceWindowResized = 0;
// instance->events().notifyWindowResized( iwidth, iheight );
}
}
return true;
}

void ofxAppEmscriptenWindow::updateCanvas(int x, int y) {
if( x != instance->mCachedWidth || y != instance->mCachedHeight ) {
instance->mCachedWidth = x;
instance->mCachedHeight = y;
instance->mLastResizeFrameNum = ofGetFrameNum();
instance->nFramesSinceWindowResized = 0;
// instance->events().notifyWindowResized( x, y );
}
}
13 changes: 10 additions & 3 deletions addons/ofxEmscripten/src/ofxAppEmscriptenWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class ofxAppEmscriptenWindow: public ofAppBaseGLESWindow {
ofxAppEmscriptenWindow();
~ofxAppEmscriptenWindow();



static bool allowsMultiWindow(){ return false; }
static bool doesLoop(){ return true; }
static bool needsPolling(){ return false; }
Expand Down Expand Up @@ -71,6 +73,8 @@ class ofxAppEmscriptenWindow: public ofAppBaseGLESWindow {
ofCoreEvents & events();
std::shared_ptr<ofBaseRenderer> & renderer();

EM_BOOL useCapture = 1;

void update();
void draw();

Expand All @@ -82,19 +86,22 @@ class ofxAppEmscriptenWindow: public ofAppBaseGLESWindow {
private:
static ofxAppEmscriptenWindow * instance;


static EM_BOOL rescale(int* x, int* y);
static void updateCanvas(int x, int y);
// static int getUniqueId();
static void display_cb();
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 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 EM_BOOL touch_cb(int eventType, const EmscriptenTouchEvent * touchEvent, 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);
Expand Down
46 changes: 34 additions & 12 deletions addons/ofxOpenCv/addon_config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,40 @@ android/arm64-v8a:

emscripten:
ADDON_LIBS =
ADDON_LIBS += libs/opencv/lib/emscripten/libopencv_dnn.a
ADDON_LIBS += libs/opencv/lib/emscripten/libopencv_photo.a
ADDON_LIBS += libs/opencv/lib/emscripten/libopencv_calib3d.a
ADDON_LIBS += libs/opencv/lib/emscripten/libopencv_features2d.a
ADDON_LIBS += libs/opencv/lib/emscripten/libopencv_objdetect.a
ADDON_LIBS += libs/opencv/lib/emscripten/libopencv_video.a
ADDON_LIBS += libs/opencv/lib/emscripten/libopencv_imgproc.a
ADDON_LIBS += libs/opencv/lib/emscripten/libopencv_core.a
ADDON_LIBS += libs/opencv/lib/emscripten/libopencv_flann.a
ADDON_LIBS += libs/opencv/lib/emscripten/liblibprotobuf.a
ADDON_LIBS += libs/opencv/lib/emscripten/libquirc.a
ADDON_LIBS += libs/opencv/lib/emscripten/libzlib.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/liblibopenjp2.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/liblibprotobuf.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_aruco.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_bioinspired.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_calib3d.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_core.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_dnn_objdetect.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_dnn_superres.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_dnn.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_dpm.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_features2d.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_flann.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_fuzzy.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_hfs.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_img_hash.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_imgcodecs.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_imgproc.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_intensity_transform.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_line_descriptor.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_mcc.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_objdetect.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_phase_unwrapping.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_plot.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_rapid.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_reg.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_saliency.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_signal.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_structured_light.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_surface_matching.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_wechat_qrcode.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_xfeatures2d.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libopencv_xobjdetect.a
ADDON_LIBS += libs/opencv/lib/emscripten/%/libzlib.a



ios:
Expand Down
Loading
Loading