From 494b1bf025031add56621f3c8e435c92cb5ae5ef Mon Sep 17 00:00:00 2001 From: Jonathan <41275844+Jonathhhan@users.noreply.github.com> Date: Sun, 21 Aug 2022 11:25:53 +0200 Subject: [PATCH 01/14] Add files via upload --- .../src/ofxAppEmscriptenWindow.cpp | 385 ------------------ 1 file changed, 385 deletions(-) diff --git a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp index b17505f59b4..e69de29bb2d 100644 --- a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp +++ b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp @@ -1,385 +0,0 @@ -/* - * ofAppEmscriptenWindow.cpp - * - * Created on: May 8, 2014 - * Author: arturo - */ - -#include "ofxAppEmscriptenWindow.h" -#include "ofLog.h" -#include "ofEvents.h" -#include "ofGLProgrammableRenderer.h" - -using namespace std; - -ofxAppEmscriptenWindow * ofxAppEmscriptenWindow::instance = NULL; - -// from http://cantuna.googlecode.com/svn-history/r16/trunk/src/screen.cpp -#define CASE_STR(x,y) case x: str = y; break - -static const char* eglErrorString(EGLint err) { - string str; - switch (err) { - CASE_STR(EGL_SUCCESS, "no error"); - CASE_STR(EGL_NOT_INITIALIZED, "EGL not, or could not be, initialized"); - CASE_STR(EGL_BAD_ACCESS, "access violation"); - CASE_STR(EGL_BAD_ALLOC, "could not allocate resources"); - CASE_STR(EGL_BAD_ATTRIBUTE, "invalid attribute"); - CASE_STR(EGL_BAD_CONTEXT, "invalid context specified"); - CASE_STR(EGL_BAD_CONFIG, "invald frame buffer configuration specified"); - CASE_STR(EGL_BAD_CURRENT_SURFACE, "current window, pbuffer or pixmap surface is no longer valid"); - CASE_STR(EGL_BAD_DISPLAY, "invalid display specified"); - CASE_STR(EGL_BAD_SURFACE, "invalid surface specified"); - CASE_STR(EGL_BAD_MATCH, "bad argument match"); - CASE_STR(EGL_BAD_PARAMETER, "invalid paramater"); - CASE_STR(EGL_BAD_NATIVE_PIXMAP, "invalid NativePixmap"); - CASE_STR(EGL_BAD_NATIVE_WINDOW, "invalid NativeWindow"); - CASE_STR(EGL_CONTEXT_LOST, "APM event caused context loss"); - default: str = "unknown error " + ofToString(err); break; - } - return str.c_str(); -} - -ofxAppEmscriptenWindow::ofxAppEmscriptenWindow() -:display(NULL) -,context(NULL) -,surface(NULL) -,bEnableSetupScreen(true){ - instance = this; - -} - -ofxAppEmscriptenWindow::~ofxAppEmscriptenWindow() { - // TODO Auto-generated destructor stub -} - -void ofxAppEmscriptenWindow::setup(const ofGLESWindowSettings & settings){ - EGLint numConfigs; - EGLint majorVersion; - EGLint minorVersion; - EGLConfig config; - EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE }; - std::vector attribList = - { - EGL_RED_SIZE, EGL_DONT_CARE, - EGL_GREEN_SIZE, EGL_DONT_CARE, - EGL_BLUE_SIZE, EGL_DONT_CARE, - EGL_ALPHA_SIZE, EGL_DONT_CARE, - EGL_DEPTH_SIZE, EGL_DONT_CARE, - EGL_STENCIL_SIZE, EGL_DONT_CARE, - EGL_SAMPLE_BUFFERS, EGL_DONT_CARE, - EGL_NONE - }; - - // We'll try these depth sizes in order ending with EGL_DONT_CARE if we don't get anything higher. - std::vector depthPreference = {24, 16, EGL_DONT_CARE}; - - // Find the index for the value EGL_DEPTH_SIZE uses, so we can try a few different values till we get a successful config. - int attribListDepthIndex = -1; - for(int i = 0; i < attribList.size(); i++){ - if( attribList[i] == EGL_DEPTH_SIZE ){ - attribListDepthIndex = i+1; - break; - } - } - - // Get Display - display = eglGetDisplay((EGLNativeDisplayType)EGL_DEFAULT_DISPLAY); - if ( display == EGL_NO_DISPLAY ){ - ofLogError() << "coudln't get display"; - return; - } - - // Initialize EGL - if ( !eglInitialize(display, &majorVersion, &minorVersion) ){ - ofLogError() << "couldn't initialize display"; - return; - } - - // Get configs - if ( !eglGetConfigs(display, NULL, 0, &numConfigs) ){ - ofLogError() << "couldn't get configs"; - return; - } - - // Choose the config based on our attribute list - // Try higher EGL_DEPTH_SIZE first - for(int i = 0; i < depthPreference.size(); i++){ - // Set EGL_DEPTH_SIZE - attribList[attribListDepthIndex] = depthPreference[i]; - - // Try out that depth value - if ( !eglChooseConfig(display, &attribList[0], &config, 1, &numConfigs) ){ - - // Finally fail like we did before if no preference works - if( depthPreference[i] == EGL_DONT_CARE ){ - ofLogError() << "couldn't choose display"; - return; - } - - }else{ - // Got a good configuration. Stop searching. - break; - } - } - - // Create a surface - surface = eglCreateWindowSurface(display, config, NULL, NULL); - if ( surface == EGL_NO_SURFACE ){ - ofLogError() << "couldn't create surface"; - return; - } - - // Create a GL context - context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs ); - if ( context == EGL_NO_CONTEXT ){ - ofLogError() << "couldn't create context"; - return; - } - - // Make the context current - if ( !eglMakeCurrent(display, surface, surface, context) ){ - ofLogError() << "couldn't make current display"; - return; - } - - setWindowShape(settings.getWidth(),settings.getHeight()); - - _renderer = make_shared(this); - ((ofGLProgrammableRenderer*)_renderer.get())->setup(2,0); - - emscripten_set_keydown_callback(0,this,1,&keydown_cb); - emscripten_set_keyup_callback(0,this,1,&keyup_cb); - emscripten_set_mousedown_callback(0,this,1,&mousedown_cb); - emscripten_set_mouseup_callback(0,this,1,&mouseup_cb); - emscripten_set_mousemove_callback(0,this,1,&mousemoved_cb); - - emscripten_set_touchstart_callback(0,this,1,&touch_cb); - emscripten_set_touchend_callback(0,this,1,&touch_cb); - emscripten_set_touchmove_callback(0,this,1,&touch_cb); - emscripten_set_touchcancel_callback(0,this,1,&touch_cb); -} - -void ofxAppEmscriptenWindow::loop(){ - - instance->events().notifySetup(); - - - // Emulate loop via callbacks - emscripten_set_main_loop( display_cb, -1, 1 ); -} - -void ofxAppEmscriptenWindow::update(){ - events().notifyUpdate(); -} - -void ofxAppEmscriptenWindow::draw(){ - /////////////////////////////////////////////////////////////////////////////////////// - // set viewport, clear the screen - renderer()->startRender(); - if( bEnableSetupScreen ) renderer()->setupScreen(); - - events().notifyDraw(); - - renderer()->finishRender(); - - - EGLBoolean success = eglSwapBuffers( display, surface ); - if( !success ) { - EGLint error = eglGetError(); - ofLogNotice("of::emscripten::EGLPage") << "display(): eglSwapBuffers failed: " << eglErrorString(error); - } -} - -void ofxAppEmscriptenWindow::display_cb(){ - if(instance){ - instance->update(); - instance->draw(); - } -} - -int ofxAppEmscriptenWindow::keydown_cb(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData){ - int key = keyEvent->key[0]; - if(key==0){ - key = keyEvent->which + 32; - } - instance->events().notifyKeyPressed(key); - return 0; -} - -int ofxAppEmscriptenWindow::keyup_cb(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData){ - int key = keyEvent->key[0]; - if(key==0){ - key = keyEvent->which + 32; - } - instance->events().notifyKeyReleased(key); - return 0; -} - -int ofxAppEmscriptenWindow::mousedown_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData){ - instance->events().notifyMousePressed(ofGetMouseX(),ofGetMouseY(),mouseEvent->button); - return 0; -} - -int ofxAppEmscriptenWindow::mouseup_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData){ - instance->events().notifyMouseReleased(ofGetMouseX(),ofGetMouseY(),mouseEvent->button); - return 0; - -} - -int ofxAppEmscriptenWindow::mousemoved_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData){ - if(ofGetMousePressed()){ - instance->events().notifyMouseDragged(mouseEvent->canvasX,mouseEvent->canvasY,0); - }else{ - instance->events().notifyMouseMoved(mouseEvent->canvasX,mouseEvent->canvasY); - } - return 0; - -} - -int ofxAppEmscriptenWindow::touch_cb(int eventType, const EmscriptenTouchEvent* e, void* userData) { - - ofTouchEventArgs::Type touchArgsType; - switch (eventType) { - case EMSCRIPTEN_EVENT_TOUCHSTART: - touchArgsType = ofTouchEventArgs::down; - break; - case EMSCRIPTEN_EVENT_TOUCHEND: - touchArgsType = ofTouchEventArgs::up; - break; - case EMSCRIPTEN_EVENT_TOUCHMOVE: - touchArgsType = ofTouchEventArgs::move; - break; - case EMSCRIPTEN_EVENT_TOUCHCANCEL: - touchArgsType = ofTouchEventArgs::cancel; - break; - default: - return 1; - } - int numTouches = e->numTouches; - for (int i = 0; i < numTouches; i++) { - ofTouchEventArgs touchArgs; - touchArgs.type = touchArgsType; - touchArgs.id = i; - touchArgs.x = e->touches[i].canvasX; - touchArgs.y = e->touches[i].canvasY; - instance->events().notifyTouchEvent(touchArgs); - } - return 0; -} - -void ofxAppEmscriptenWindow::hideCursor(){ - emscripten_hide_mouse(); -} - - -void ofxAppEmscriptenWindow::showCursor(){ - -} - -void ofxAppEmscriptenWindow::setWindowPosition(int x, int y){ - -} - -void ofxAppEmscriptenWindow::setWindowShape(int w, int h){ - emscripten_set_canvas_element_size(NULL,w,h); -} - - - -glm::vec2 ofxAppEmscriptenWindow::getWindowPosition(){ - return glm::vec2(0,0); -} - - -glm::vec2 ofxAppEmscriptenWindow::getWindowSize(){ - int width; - int height; - emscripten_get_canvas_element_size(NULL, &width, &height); - return glm::vec2(width,height); -} - -glm::vec2 ofxAppEmscriptenWindow::getScreenSize(){ - return getWindowSize(); -} - -void ofxAppEmscriptenWindow::setOrientation(ofOrientation orientation){ - -} - -ofOrientation ofxAppEmscriptenWindow::getOrientation(){ - return OF_ORIENTATION_DEFAULT; -} - -bool ofxAppEmscriptenWindow::doesHWOrientation(){ - return false; -} - -//this is used by ofGetWidth and now determines the window width based on orientation -int ofxAppEmscriptenWindow::getWidth(){ - return getWindowSize().x; -} - -int ofxAppEmscriptenWindow::getHeight(){ - return getWindowSize().y; -} - -void ofxAppEmscriptenWindow::setWindowTitle(string title){ - -} - -ofWindowMode ofxAppEmscriptenWindow::getWindowMode(){ - return OF_WINDOW; -} - -void ofxAppEmscriptenWindow::setFullscreen(bool fullscreen){ - if(fullscreen){ - emscripten_request_fullscreen(0,1); - }else{ - emscripten_exit_fullscreen(); - } -} - -void ofxAppEmscriptenWindow::toggleFullscreen(){ - EmscriptenFullscreenChangeEvent fullscreenStatus; - emscripten_get_fullscreen_status(&fullscreenStatus); - if(fullscreenStatus.isFullscreen){ - setFullscreen(false); - }else if(fullscreenStatus.fullscreenEnabled){ - setFullscreen(true); - } -} - -void ofxAppEmscriptenWindow::enableSetupScreen(){ - bEnableSetupScreen = true; -} - - -void ofxAppEmscriptenWindow::disableSetupScreen(){ - bEnableSetupScreen = false; -} - -void ofxAppEmscriptenWindow::setVerticalSync(bool enabled){ - eglSwapInterval(display, enabled ? 1 : 0); -} - -EGLDisplay ofxAppEmscriptenWindow::getEGLDisplay(){ - return display; -} - - -EGLContext ofxAppEmscriptenWindow::getEGLContext(){ - return context; -} - -EGLSurface ofxAppEmscriptenWindow::getEGLSurface(){ - return surface; -} - -ofCoreEvents & ofxAppEmscriptenWindow::events(){ - return _events; -} - -shared_ptr & ofxAppEmscriptenWindow::renderer(){ - return _renderer; -} From baacdf84172ac2ef40212647d1d34f1f42b782f8 Mon Sep 17 00:00:00 2001 From: Jonathan <41275844+Jonathhhan@users.noreply.github.com> Date: Sun, 21 Aug 2022 11:26:29 +0200 Subject: [PATCH 02/14] Add files via upload --- .../emscripten/config.emscripten.default.mk | 284 ------------------ 1 file changed, 284 deletions(-) diff --git a/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk b/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk index 467467ccf74..e69de29bb2d 100644 --- a/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk +++ b/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk @@ -1,284 +0,0 @@ - ################################################################################ -# CONFIGURE CORE PLATFORM MAKEFILE -# This file has linux common rules for all the platforms (x86_64, i386,armv6l -# and armv7l) -# -################################################################################ - -################################################################################ -# PLATFORM SPECIFIC CHECKS -# This is a platform defined section to create internal flags to enable or -# disable the addition of various features within this makefile. For -# instance, on Linux, we check to see if there GTK+-2.0 is defined, allowing -# us to include that library and generate DEFINES that are interpreted as -# ifdefs within the openFrameworks core source code. -################################################################################ - -PLATFORM_PROJECT_RELEASE_TARGET = bin/$(BIN_NAME).html -PLATFORM_PROJECT_DEBUG_TARGET = bin/$(BIN_NAME).html -BYTECODECORE=1 -PLATFORM_CORELIB_DEBUG_TARGET = $(OF_CORE_LIB_PATH)/libopenFrameworksDebug.bc -PLATFORM_CORELIB_RELEASE_TARGET = $(OF_CORE_LIB_PATH)/libopenFrameworks.bc - -################################################################################ -# PLATFORM DEFINES -# Create a list of DEFINES for this platform. The list will be converted into -# CFLAGS with the "-D" flag later in the makefile. An example of fully -# qualified flag might look something like this: -DTARGET_OPENGLES2 -# -# DEFINES are used throughout the openFrameworks code, especially when making -# #ifdef decisions for cross-platform compatibility. For instance, when -# choosing a video playback framework, the openFrameworks base classes look at -# the DEFINES to determine what source files to include or what default player -# to use. -# -# Note: Leave a leading space when adding list items with the += operator -################################################################################ - -PLATFORM_DEFINES = __EMSCRIPTEN__ - -################################################################################ -# PLATFORM REQUIRED ADDON -# This is a list of addons required for this platform. This list is used to -# EXCLUDE addon source files when compiling projects, while INCLUDING their -# header files. During core library compilation, this is used to include -# required addon header files as needed within the core. -# -# For instance, if you are compiling for Android, you would add ofxAndroid -# here. If you are compiling for Raspberry Pi, you would add ofxRaspberryPi -# here. -# -# Note: Leave a leading space when adding list items with the += operator -################################################################################ - -PLATFORM_REQUIRED_ADDONS = ofxEmscripten - -################################################################################ -# PLATFORM CFLAGS -# This is a list of fully qualified CFLAGS required when compiling for this -# platform. These flags will always be added when compiling a project or the -# core library. These flags are presented to the compiler AFTER the -# PLATFORM_OPTIMIZATION_CFLAGS below. -# -# Note: Leave a leading space when adding list items with the += operator -################################################################################ - -# Code Generation Option Flags (http://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html) -PLATFORM_CFLAGS = -Wall -std=c++17 -Wno-warn-absolute-paths - - -################################################################################ -# PLATFORM LDFLAGS -# This is a list of fully qualified LDFLAGS required when linking for this -# platform. These flags will always be added when linking a project. -# -# Note: Leave a leading space when adding list items with the += operator -################################################################################ - -ifdef PROJECT_EMSCRIPTEN_TOTAL_MEMORY - PLATFORM_EMSCRIPTEN_TOTAL_MEMORY=$(PROJECT_EMSCRIPTEN_TOTAL_MEMORY) -else - PLATFORM_EMSCRIPTEN_TOTAL_MEMORY=134217728 -endif - -ifdef USE_CCACHE - ifeq ($(findstring ccache, $(CC)),) - ORIGINAL_CC = $(CC) - CC := ccache $(ORIGINAL_CC) - ORIGINAL_CXX = $(CXX) - CXX := ccache $(ORIGINAL_CXX) - endif -endif - -PLATFORM_LDFLAGS = -Wl --gc-sections --preload-file bin/data@data --emrun -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0 -PLATFORM_LDFLAGS += --js-library $(OF_ADDONS_PATH)/ofxEmscripten/libs/html5video/lib/emscripten/library_html5video.js -PLATFORM_LDFLAGS += --js-library $(OF_ADDONS_PATH)/ofxEmscripten/libs/html5audio/lib/emscripten/library_html5audio.js - -ifdef PROJECT_EMSCRIPTEN_TEMPLATE - PLATFORM_LDFLAGS += --shell-file $(PROJECT_EMSCRIPTEN_TEMPLATE) -else - PLATFORM_LDFLAGS += --shell-file $(OF_LIBS_PATH)/openFrameworksCompiled/project/emscripten/template.html -endif - -PLATFORM_OPTIMIZATION_LDFLAGS_RELEASE = -O3 -s TOTAL_MEMORY=$(PLATFORM_EMSCRIPTEN_TOTAL_MEMORY) --memory-init-file 1 - -PLATFORM_OPTIMIZATION_LDFLAGS_DEBUG = -g3 -s TOTAL_MEMORY=134217728 --memory-init-file 1 -s DEMANGLE_SUPPORT=1 -s ASSERTIONS=2 - -################################################################################ -# PLATFORM OPTIMIZATION CFLAGS -# These are lists of CFLAGS that are target-specific. While any flags could -# be conditionally added, they are usually limited to optimization flags. -# These flags are added BEFORE the PLATFORM_CFLAGS. -# -# PLATFORM_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to -# RELEASE targets. -# -# PLATFORM_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to -# DEBUG targets. -# -# Note: Leave a leading space when adding list items with the += operator -################################################################################ - -# RELEASE Debugging options (http://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html) -PLATFORM_OPTIMIZATION_CFLAGS_RELEASE = -O3 - -# DEBUG Debugging options (http://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html) -PLATFORM_OPTIMIZATION_CFLAGS_DEBUG = -g3 -s DEMANGLE_SUPPORT=1 -s ASSERTIONS=2 - -################################################################################ -# PLATFORM CORE EXCLUSIONS -# During compilation, these makefiles will generate lists of sources, headers -# and third party libraries to be compiled and linked into a program or core -# library. The PLATFORM_CORE_EXCLUSIONS is a list of fully qualified file -# paths that will be used to exclude matching paths and files during list -# generation. -# -# Each item in the PLATFORM_CORE_EXCLUSIONS list will be treated as a complete -# string unless teh user adds a wildcard (%) operator to match subdirectories. -# GNU make only allows one wildcard for matching. The second wildcard (%) is -# treated literally. -# -# Note: Leave a leading space when adding list items with the += operator -################################################################################ - -PLATFORM_CORE_EXCLUSIONS = - -# core sources -PLATFORM_CORE_EXCLUSIONS += %.mm -PLATFORM_CORE_EXCLUSIONS += %.m -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/video/ofQtUtils.cpp -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/video/ofQuickTimeGrabber.cpp -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/video/ofQuickTimePlayer.cpp -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/video/ofDirectShowGrabber.cpp -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/video/ofDirectShowPlayer.cpp -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/video/ofGstUtils.cpp -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/video/ofGstVideoGrabber.cpp -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/video/ofGstVideoPlayer.cpp -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/communication/%.cpp -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/sound/ofFmodSoundPlayer.cpp -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/sound/ofOpenALSoundPlayer.cpp -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/sound/ofRtAudioSoundStream.cpp -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/app/ofAppGlutWindow.cpp -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/app/ofAppGLFWWindow.cpp -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/app/ofAppEGLWindow.cpp -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/graphics/ofCairoRenderer.cpp -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/gl/ofGLRenderer.cpp -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/utils/ofThread.cpp -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/utils/ofThreadChannel.cpp - -# third party -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/glew/% -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/boost/include/boost/% -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/videoInput/% -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/assimp/% -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/fmod/% - -################################################################################ -# PLATFORM HEADER SEARCH PATHS -# These are header search paths that are platform specific and are specified -# using fully-qualified paths. The include flag (i.e. -I) is prefixed -# automatically. These are usually not required, but may be required by some -# experimental platforms such as the raspberry pi or other other embedded -# architectures. -# -# Note: Leave a leading space when adding list items with the += operator -################################################################################ - -PLATFORM_HEADER_SEARCH_PATHS = -PLATFORM_HEADER_SEARCH_PATHS += "$(OF_ROOT)/addons/ofxEmscripten/src" - -################################################################################ -# PLATFORM LIBRARIES -# These are library names/paths that are platform specific and are specified -# using names or paths. The library flag (i.e. -l) is prefixed automatically. -# -# PLATFORM_LIBRARIES are libraries that can be found in the library search -# paths. -# PLATFORM_STATIC_LIBRARIES is a list of required static libraries. -# PLATFORM_SHARED_LIBRARIES is a list of required shared libraries. -# PLATFORM_PKG_CONFIG_LIBRARIES is a list of required libraries that are -# under system control and are easily accesible via the package -# configuration utility (i.e. pkg-config) -# -# See the helpfile for the -l flag here for more information: -# http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html -# -# Note: Leave a leading space when adding list items with the += operator -################################################################################ - -PLATFORM_LIBRARIES = - - -#static libraries (fully qualified paths) -PLATFORM_STATIC_LIBRARIES = - -# shared libraries -PLATFORM_SHARED_LIBRARIES = -#PLATFORM_SHARED_LIBRARIES += $(OF_LIBS_PATH)/freetype/lib/$(ABI_LIB_SUBPATH)/libfreetype.bc - - -################################################################################ -# PLATFORM LIBRARY SEARCH PATHS -# These are library search paths that are platform specific and are specified -# using fully-qualified paths. The lib search flag (i.e. -L) is prefixed -# automatically. The -L paths are used to find libraries defined above with -# the -l flag. -# -# See the the following link for more information on the -L flag: -# http://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html -# -# Note: Leave a leading space when adding list items with the += operator -################################################################################ - -PLATFORM_LIBRARY_SEARCH_PATHS = - -################################################################################ -# PLATFORM FRAMEWORKS -# These are a list of platform frameworks. -# These are used exclusively with Darwin/OSX. -# -# Note: Leave a leading space when adding list items with the += operator -################################################################################ -#PLATFORM_FRAMEWORKS = - -################################################################################ -# PLATFORM FRAMEWORK SEARCH PATHS -# These are a list of platform framework search paths. -# These are used exclusively with Darwin/OSX. -# -# Note: Leave a leading space when adding list items with the += operator -################################################################################ -#PLATFORM_FRAMEWORKS_SEARCH_PATHS = - -################################################################################ -# LOW LEVEL CONFIGURATION BELOW -# The following sections should only rarely be modified. They are meant for -# developers who need fine control when, for instance, creating a platform -# specific makefile for a new openFrameworks platform, such as raspberry pi. -################################################################################ - -################################################################################ -# PLATFORM CONFIGURATIONS -# These will override the architecture vars generated by configure.platform.mk -################################################################################ -#PLATFORM_ARCH = -#PLATFORM_OS = -#PLATFORM_LIBS_PATH = - -################################################################################ -# PLATFORM CXX -# Don't want to use a default compiler? -################################################################################ -#PLATFORM_CXX= - -afterplatform: $(TARGET_NAME) - @echo - @echo " compiling done" - @echo " to launch the application on the default browser, run:" - @echo - @echo " emrun bin/$(BIN_NAME).html" - @echo " " - @echo " some browsers, like safari, don't support webgl" - @echo " " - @emrun --list_browsers 2>/dev/null - @echo From 38a7b9b42558a4a718f3fdaf062dd2e05d236f46 Mon Sep 17 00:00:00 2001 From: Jonathan <41275844+Jonathhhan@users.noreply.github.com> Date: Sun, 21 Aug 2022 11:27:56 +0200 Subject: [PATCH 03/14] Add files via upload --- .../emscripten/config.emscripten.default.mk | 286 ++++++++++++++++++ 1 file changed, 286 insertions(+) diff --git a/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk b/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk index e69de29bb2d..98b9785b957 100644 --- a/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk +++ b/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk @@ -0,0 +1,286 @@ + ################################################################################ +# CONFIGURE CORE PLATFORM MAKEFILE +# This file has linux common rules for all the platforms (x86_64, i386,armv6l +# and armv7l) +# +################################################################################ + +################################################################################ +# PLATFORM SPECIFIC CHECKS +# This is a platform defined section to create internal flags to enable or +# disable the addition of various features within this makefile. For +# instance, on Linux, we check to see if there GTK+-2.0 is defined, allowing +# us to include that library and generate DEFINES that are interpreted as +# ifdefs within the openFrameworks core source code. +################################################################################ + +PLATFORM_PROJECT_RELEASE_TARGET = bin/$(BIN_NAME).html +PLATFORM_PROJECT_DEBUG_TARGET = bin/$(BIN_NAME).html +BYTECODECORE=1 +PLATFORM_CORELIB_DEBUG_TARGET = $(OF_CORE_LIB_PATH)/libopenFrameworksDebug.bc +PLATFORM_CORELIB_RELEASE_TARGET = $(OF_CORE_LIB_PATH)/libopenFrameworks.bc + +################################################################################ +# PLATFORM DEFINES +# Create a list of DEFINES for this platform. The list will be converted into +# CFLAGS with the "-D" flag later in the makefile. An example of fully +# qualified flag might look something like this: -DTARGET_OPENGLES2 +# +# DEFINES are used throughout the openFrameworks code, especially when making +# #ifdef decisions for cross-platform compatibility. For instance, when +# choosing a video playback framework, the openFrameworks base classes look at +# the DEFINES to determine what source files to include or what default player +# to use. +# +# Note: Leave a leading space when adding list items with the += operator +################################################################################ + +PLATFORM_DEFINES = __EMSCRIPTEN__ + +################################################################################ +# PLATFORM REQUIRED ADDON +# This is a list of addons required for this platform. This list is used to +# EXCLUDE addon source files when compiling projects, while INCLUDING their +# header files. During core library compilation, this is used to include +# required addon header files as needed within the core. +# +# For instance, if you are compiling for Android, you would add ofxAndroid +# here. If you are compiling for Raspberry Pi, you would add ofxRaspberryPi +# here. +# +# Note: Leave a leading space when adding list items with the += operator +################################################################################ + +PLATFORM_REQUIRED_ADDONS = ofxEmscripten + +################################################################################ +# PLATFORM CFLAGS +# This is a list of fully qualified CFLAGS required when compiling for this +# platform. These flags will always be added when compiling a project or the +# core library. These flags are presented to the compiler AFTER the +# PLATFORM_OPTIMIZATION_CFLAGS below. +# +# Note: Leave a leading space when adding list items with the += operator +################################################################################ + +# Code Generation Option Flags (http://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html) +PLATFORM_CFLAGS = +PLATFORM_CXXFLAGS = -Wall -std=c++17 -Wno-warn-absolute-paths + +################################################################################ +# PLATFORM LDFLAGS +# This is a list of fully qualified LDFLAGS required when linking for this +# platform. These flags will always be added when linking a project. +# +# Note: Leave a leading space when adding list items with the += operator +################################################################################ + +ifdef PROJECT_EMSCRIPTEN_TOTAL_MEMORY + PLATFORM_EMSCRIPTEN_TOTAL_MEMORY=$(PROJECT_EMSCRIPTEN_TOTAL_MEMORY) +else + PLATFORM_EMSCRIPTEN_TOTAL_MEMORY=134217728 +endif + +CUR_CC = $(CC) +CC := $(CUR_CC) -r + +ifdef USE_CCACHE + ifeq ($(findstring ccache, $(CC)),) + ORIGINAL_CC = $(CC) + CC := ccache $(ORIGINAL_CC) + ORIGINAL_CXX = $(CXX) + CXX := ccache $(ORIGINAL_CXX) + endif +endif + +PLATFORM_LDFLAGS = -Wl --gc-sections --preload-file bin/data@data --emrun -s USE_FREETYPE=1 +PLATFORM_LDFLAGS += --js-library $(OF_ADDONS_PATH)/ofxEmscripten/libs/html5video/lib/emscripten/library_html5video.js +PLATFORM_LDFLAGS += --js-library $(OF_ADDONS_PATH)/ofxEmscripten/libs/html5audio/lib/emscripten/library_html5audio.js + +ifdef PROJECT_EMSCRIPTEN_TEMPLATE + PLATFORM_LDFLAGS += --shell-file $(PROJECT_EMSCRIPTEN_TEMPLATE) +else + PLATFORM_LDFLAGS += --shell-file $(OF_LIBS_PATH)/openFrameworksCompiled/project/emscripten/template.html +endif + +PLATFORM_OPTIMIZATION_LDFLAGS_RELEASE = -O3 -s TOTAL_MEMORY=$(PLATFORM_EMSCRIPTEN_TOTAL_MEMORY) --memory-init-file 1 + +PLATFORM_OPTIMIZATION_LDFLAGS_DEBUG = -g3 -s TOTAL_MEMORY=134217728 --memory-init-file 1 -s DEMANGLE_SUPPORT=1 -s ASSERTIONS=2 + +################################################################################ +# PLATFORM OPTIMIZATION CFLAGS +# These are lists of CFLAGS that are target-specific. While any flags could +# be conditionally added, they are usually limited to optimization flags. +# These flags are added BEFORE the PLATFORM_CFLAGS. +# +# PLATFORM_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to +# RELEASE targets. +# +# PLATFORM_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to +# DEBUG targets. +# +# Note: Leave a leading space when adding list items with the += operator +################################################################################ + +# RELEASE Debugging options (http://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html) +PLATFORM_OPTIMIZATION_CFLAGS_RELEASE = -O3 + +# DEBUG Debugging options (http://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html) +PLATFORM_OPTIMIZATION_CFLAGS_DEBUG = -g3 -s DEMANGLE_SUPPORT=1 -s ASSERTIONS=2 + +################################################################################ +# PLATFORM CORE EXCLUSIONS +# During compilation, these makefiles will generate lists of sources, headers +# and third party libraries to be compiled and linked into a program or core +# library. The PLATFORM_CORE_EXCLUSIONS is a list of fully qualified file +# paths that will be used to exclude matching paths and files during list +# generation. +# +# Each item in the PLATFORM_CORE_EXCLUSIONS list will be treated as a complete +# string unless teh user adds a wildcard (%) operator to match subdirectories. +# GNU make only allows one wildcard for matching. The second wildcard (%) is +# treated literally. +# +# Note: Leave a leading space when adding list items with the += operator +################################################################################ + +PLATFORM_CORE_EXCLUSIONS = + +# core sources +PLATFORM_CORE_EXCLUSIONS += %.mm +PLATFORM_CORE_EXCLUSIONS += %.m +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/video/ofQtUtils.cpp +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/video/ofQuickTimeGrabber.cpp +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/video/ofQuickTimePlayer.cpp +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/video/ofDirectShowGrabber.cpp +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/video/ofDirectShowPlayer.cpp +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/video/ofGstUtils.cpp +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/video/ofGstVideoGrabber.cpp +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/video/ofGstVideoPlayer.cpp +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/communication/%.cpp +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/sound/ofFmodSoundPlayer.cpp +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/sound/ofOpenALSoundPlayer.cpp +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/sound/ofRtAudioSoundStream.cpp +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/app/ofAppGlutWindow.cpp +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/app/ofAppGLFWWindow.cpp +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/app/ofAppEGLWindow.cpp +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/graphics/ofCairoRenderer.cpp +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/gl/ofGLRenderer.cpp +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/utils/ofThread.cpp +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/utils/ofThreadChannel.cpp +# third party +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/glew/% +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/boost/include/boost/% +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/videoInput/% +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/fmod/% +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/freetype/lib/% + +################################################################################ +# PLATFORM HEADER SEARCH PATHS +# These are header search paths that are platform specific and are specified +# using fully-qualified paths. The include flag (i.e. -I) is prefixed +# automatically. These are usually not required, but may be required by some +# experimental platforms such as the raspberry pi or other other embedded +# architectures. +# +# Note: Leave a leading space when adding list items with the += operator +################################################################################ + +PLATFORM_HEADER_SEARCH_PATHS = +PLATFORM_HEADER_SEARCH_PATHS += "$(OF_ROOT)/addons/ofxEmscripten/src" + +################################################################################ +# PLATFORM LIBRARIES +# These are library names/paths that are platform specific and are specified +# using names or paths. The library flag (i.e. -l) is prefixed automatically. +# +# PLATFORM_LIBRARIES are libraries that can be found in the library search +# paths. +# PLATFORM_STATIC_LIBRARIES is a list of required static libraries. +# PLATFORM_SHARED_LIBRARIES is a list of required shared libraries. +# PLATFORM_PKG_CONFIG_LIBRARIES is a list of required libraries that are +# under system control and are easily accesible via the package +# configuration utility (i.e. pkg-config) +# +# See the helpfile for the -l flag here for more information: +# http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html +# +# Note: Leave a leading space when adding list items with the += operator +################################################################################ + +PLATFORM_LIBRARIES = + + +#static libraries (fully qualified paths) +PLATFORM_STATIC_LIBRARIES = + +# shared libraries +PLATFORM_SHARED_LIBRARIES = +#PLATFORM_SHARED_LIBRARIES += $(OF_LIBS_PATH)/freetype/lib/$(ABI_LIB_SUBPATH)/libfreetype.bc + + +################################################################################ +# PLATFORM LIBRARY SEARCH PATHS +# These are library search paths that are platform specific and are specified +# using fully-qualified paths. The lib search flag (i.e. -L) is prefixed +# automatically. The -L paths are used to find libraries defined above with +# the -l flag. +# +# See the the following link for more information on the -L flag: +# http://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html +# +# Note: Leave a leading space when adding list items with the += operator +################################################################################ + +PLATFORM_LIBRARY_SEARCH_PATHS = + +################################################################################ +# PLATFORM FRAMEWORKS +# These are a list of platform frameworks. +# These are used exclusively with Darwin/OSX. +# +# Note: Leave a leading space when adding list items with the += operator +################################################################################ +#PLATFORM_FRAMEWORKS = + +################################################################################ +# PLATFORM FRAMEWORK SEARCH PATHS +# These are a list of platform framework search paths. +# These are used exclusively with Darwin/OSX. +# +# Note: Leave a leading space when adding list items with the += operator +################################################################################ +#PLATFORM_FRAMEWORKS_SEARCH_PATHS = + +################################################################################ +# LOW LEVEL CONFIGURATION BELOW +# The following sections should only rarely be modified. They are meant for +# developers who need fine control when, for instance, creating a platform +# specific makefile for a new openFrameworks platform, such as raspberry pi. +################################################################################ + +################################################################################ +# PLATFORM CONFIGURATIONS +# These will override the architecture vars generated by configure.platform.mk +################################################################################ +#PLATFORM_ARCH = +#PLATFORM_OS = +#PLATFORM_LIBS_PATH = + +################################################################################ +# PLATFORM CXX +# Don't want to use a default compiler? +################################################################################ +#PLATFORM_CXX= + +afterplatform: $(TARGET_NAME) + @echo + @echo " compiling done" + @echo " to launch the application on the default browser, run:" + @echo + @echo " emrun bin/$(BIN_NAME).html" + @echo " " + @echo " some browsers, like safari, don't support webgl" + @echo " " + @emrun --list_browsers 2>/dev/null + @echo From 611da251c3dbb8011ef4e761104f77c22d4cb42c Mon Sep 17 00:00:00 2001 From: Jonathan <41275844+Jonathhhan@users.noreply.github.com> Date: Sun, 21 Aug 2022 11:29:08 +0200 Subject: [PATCH 04/14] Add files via upload --- .../src/ofxAppEmscriptenWindow.cpp | 275 ++++++++++++++++++ .../src/ofxAppEmscriptenWindow.h | 50 +++- 2 files changed, 309 insertions(+), 16 deletions(-) diff --git a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp index e69de29bb2d..b881e589158 100644 --- a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp +++ b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp @@ -0,0 +1,275 @@ +/* + * ofAppEmscriptenWindow.cpp + * + * Created on: May 8, 2014 + * Author: arturo + */ + +#include "ofxAppEmscriptenWindow.h" +#include "ofLog.h" +#include "ofEvents.h" +#include "ofGLProgrammableRenderer.h" + +using namespace std; + +ofxAppEmscriptenWindow * ofxAppEmscriptenWindow::instance = NULL; + + +ofxAppEmscriptenWindow::ofxAppEmscriptenWindow(){ + instance = this; +} + +ofxAppEmscriptenWindow::~ofxAppEmscriptenWindow() { + if(context != 0){ + emscripten_webgl_destroy_context(context); + } +} + +void ofxAppEmscriptenWindow::setup(const ofGLESWindowSettings & settings){ + setWindowShape(settings.getWidth(),settings.getHeight()); + 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); + + makeCurrent(); + + _renderer = make_shared(this); + ((ofGLProgrammableRenderer*)_renderer.get())->setup(2,0); + + emscripten_set_keydown_callback("#canvas",this,1,&keydown_cb); + emscripten_set_keyup_callback("#canvas",this,1,&keyup_cb); + + emscripten_set_mousedown_callback("#canvas",this,1,&mousedown_cb); + emscripten_set_mouseup_callback("#canvas",this,1,&mouseup_cb); + emscripten_set_mousemove_callback("#canvas",this,1,&mousemoved_cb); + emscripten_set_mouseenter_callback("#canvas",this,1,&mouseenter_cb); + emscripten_set_mouseleave_callback("#canvas",this,1,&mouseleave_cb); + + emscripten_set_touchstart_callback("#canvas",this,1,&touch_cb); + emscripten_set_touchend_callback("#canvas",this,1,&touch_cb); + emscripten_set_touchmove_callback("#canvas",this,1,&touch_cb); + emscripten_set_touchcancel_callback("#canvas",this,1,&touch_cb); + +} + +void ofxAppEmscriptenWindow::loop(){ + + instance->events().notifySetup(); + + // Emulate loop via callbacks + emscripten_set_main_loop( display_cb, -1, 1); +} + +void ofxAppEmscriptenWindow::update(){ + if (bSetMainLoopTiming) { + emscripten_set_main_loop_timing(1, 2); + bSetMainLoopTiming = false; + } + events().notifyUpdate(); +} + +void ofxAppEmscriptenWindow::draw(){ + // set viewport, clear the screen + renderer()->startRender(); + if( bEnableSetupScreen ) renderer()->setupScreen(); + + events().notifyDraw(); + + renderer()->finishRender(); +} + +void ofxAppEmscriptenWindow::display_cb(){ + if(instance){ + instance->update(); + instance->draw(); + } +} + +int ofxAppEmscriptenWindow::keydown_cb(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData){ + int key = keyEvent->key[0]; + if(key==0){ + key = keyEvent->which + 32; + } + instance->events().notifyKeyPressed(key); + return 0; +} + +int ofxAppEmscriptenWindow::keyup_cb(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData){ + int key = keyEvent->key[0]; + if(key==0){ + key = keyEvent->which + 32; + } + instance->events().notifyKeyReleased(key); + return 0; +} + +int ofxAppEmscriptenWindow::mousedown_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData){ + instance->events().notifyMousePressed(mouseEvent->targetX,mouseEvent->targetY,mouseEvent->button); + return 0; +} + +int ofxAppEmscriptenWindow::mouseup_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData){ + instance->events().notifyMouseReleased(mouseEvent->targetX,mouseEvent->targetY,0); + return 0; +} + +int ofxAppEmscriptenWindow::mousemoved_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData){ + if(ofGetMousePressed()){ + instance->events().notifyMouseDragged(mouseEvent->targetX,mouseEvent->targetY,0); + }else{ + instance->events().notifyMouseMoved(mouseEvent->targetX,mouseEvent->targetY); + } + return 0; +} + +int ofxAppEmscriptenWindow::mouseenter_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData){ + instance->events().notifyMouseEntered(mouseEvent->targetX,mouseEvent->targetY); + if(mouseEvent->buttons == 0){ + instance->events().notifyMouseReleased(mouseEvent->targetX,mouseEvent->targetY,mouseEvent->button); + } + return 0; +} + +int ofxAppEmscriptenWindow::mouseleave_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData){ + instance->events().notifyMouseExited(mouseEvent->targetX,mouseEvent->targetY); + return 0; + +} + +int ofxAppEmscriptenWindow::touch_cb(int eventType, const EmscriptenTouchEvent* e, void* userData) { + + ofTouchEventArgs::Type touchArgsType; + switch (eventType) { + case EMSCRIPTEN_EVENT_TOUCHSTART: + touchArgsType = ofTouchEventArgs::down; + break; + case EMSCRIPTEN_EVENT_TOUCHEND: + touchArgsType = ofTouchEventArgs::up; + break; + case EMSCRIPTEN_EVENT_TOUCHMOVE: + touchArgsType = ofTouchEventArgs::move; + break; + case EMSCRIPTEN_EVENT_TOUCHCANCEL: + touchArgsType = ofTouchEventArgs::cancel; + break; + default: + return 1; + } + int numTouches = e->numTouches; + for (int i = 0; i < numTouches; i++) { + ofTouchEventArgs touchArgs; + touchArgs.type = touchArgsType; + touchArgs.id = i; + touchArgs.x = e->touches[i].targetX; + touchArgs.y = e->touches[i].targetY; + instance->events().notifyTouchEvent(touchArgs); + } + return 0; +} + +void ofxAppEmscriptenWindow::hideCursor(){ + emscripten_hide_mouse(); +} + +void ofxAppEmscriptenWindow::setWindowShape(int w, int h){ + emscripten_set_canvas_size(w,h); +} + +glm::vec2 ofxAppEmscriptenWindow::getWindowPosition(){ + return glm::vec2(0,0); +} + +glm::vec2 ofxAppEmscriptenWindow::getWindowSize(){ + int width; + int height; + + emscripten_get_canvas_element_size("#canvas", &width, &height); + return glm::vec2(width,height); +} + +glm::vec2 ofxAppEmscriptenWindow::getScreenSize(){ + return getWindowSize(); +} + +ofOrientation ofxAppEmscriptenWindow::getOrientation(){ + return OF_ORIENTATION_DEFAULT; +} + +bool ofxAppEmscriptenWindow::doesHWOrientation(){ + return false; +} + +//this is used by ofGetWidth and now determines the window width based on orientation +int ofxAppEmscriptenWindow::getWidth(){ + return getWindowSize().x; +} + +int ofxAppEmscriptenWindow::getHeight(){ + return getWindowSize().y; +} + +ofWindowMode ofxAppEmscriptenWindow::getWindowMode(){ + return OF_WINDOW; +} + +void ofxAppEmscriptenWindow::setFullscreen(bool fullscreen){ + if(fullscreen){ + emscripten_request_fullscreen(0,1); + }else{ + emscripten_exit_fullscreen(); + } +} + +void ofxAppEmscriptenWindow::toggleFullscreen(){ + EmscriptenFullscreenChangeEvent fullscreenStatus; + emscripten_get_fullscreen_status(&fullscreenStatus); + if(fullscreenStatus.isFullscreen){ + setFullscreen(false); + }else if(fullscreenStatus.fullscreenEnabled){ + setFullscreen(true); + } +} + +void ofxAppEmscriptenWindow::enableSetupScreen(){ + bEnableSetupScreen = true; +} + + +void ofxAppEmscriptenWindow::disableSetupScreen(){ + bEnableSetupScreen = false; +} + + +ofCoreEvents & ofxAppEmscriptenWindow::events(){ + return _events; +} + +shared_ptr & ofxAppEmscriptenWindow::renderer(){ + return _renderer; +} + +void ofxAppEmscriptenWindow::makeCurrent(){ + if(context != 0){ + emscripten_webgl_make_context_current(context); + } +} + +void ofxAppEmscriptenWindow::startRender(){ + renderer()->startRender(); +} + +void ofxAppEmscriptenWindow::finishRender(){ + renderer()->finishRender(); +} + diff --git a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.h b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.h index 0443d80ac18..d2b1c538d05 100644 --- a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.h +++ b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.h @@ -14,6 +14,7 @@ #include "EGL/egl.h" #include #include +#include // For Emscripten WebGL API headers (see also webgl/webgl1_ext.h and webgl/webgl2.h) class ofxAppEmscriptenWindow: public ofAppBaseGLESWindow { public: @@ -30,16 +31,16 @@ class ofxAppEmscriptenWindow: public ofAppBaseGLESWindow { void setup(const ofGLESWindowSettings & settings); void hideCursor(); - void showCursor(); + // void showCursor(); - void setWindowPosition(int x, int y); + // void setWindowPosition(int x, int y); void setWindowShape(int w, int h); glm::vec2 getWindowPosition(); glm::vec2 getWindowSize(); glm::vec2 getScreenSize(); - void setOrientation(ofOrientation orientation); + ofOrientation getOrientation(); bool doesHWOrientation(); @@ -47,7 +48,7 @@ class ofxAppEmscriptenWindow: public ofAppBaseGLESWindow { int getWidth(); int getHeight(); - void setWindowTitle(std::string title); + ofWindowMode getWindowMode(); @@ -57,33 +58,50 @@ class ofxAppEmscriptenWindow: public ofAppBaseGLESWindow { void enableSetupScreen(); void disableSetupScreen(); - void setVerticalSync(bool enabled); + void setVerticalSync(bool enabled){} - EGLDisplay getEGLDisplay(); - EGLContext getEGLContext(); - EGLSurface getEGLSurface(); ofCoreEvents & events(); std::shared_ptr & renderer(); + + void update(); + void draw(); + + virtual void makeCurrent(); + virtual void startRender(); + virtual void finishRender(); + + + bool bIsSetup = false; private: + static ofxAppEmscriptenWindow * instance; + + + // 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 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 touch_cb(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData); - void update(); - void draw(); - EGLDisplay display; - EGLContext context; - EGLSurface surface; - static ofxAppEmscriptenWindow * instance; - bool bEnableSetupScreen; + static int mouseenter_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData); + static int mouseleave_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData); + + static int touch_cb(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData); + + int id; + + + EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = 0; + + bool bSetMainLoopTiming = true; + bool bEnableSetupScreen = true; ofCoreEvents _events; std::shared_ptr _renderer; }; #endif /* OFAPPEMSCRIPTENWINDOW_H_ */ + From 1e968732cfb7d183ecc75ce2c48b6802d6b383d5 Mon Sep 17 00:00:00 2001 From: Jonathan <41275844+Jonathhhan@users.noreply.github.com> Date: Sun, 21 Aug 2022 16:50:47 +0200 Subject: [PATCH 05/14] Update config.emscripten.default.mk --- .../project/emscripten/config.emscripten.default.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk b/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk index 98b9785b957..5f6267acb25 100644 --- a/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk +++ b/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk @@ -93,7 +93,7 @@ ifdef USE_CCACHE endif endif -PLATFORM_LDFLAGS = -Wl --gc-sections --preload-file bin/data@data --emrun -s USE_FREETYPE=1 +PLATFORM_LDFLAGS = -Wl --gc-sections --preload-file bin/data@data --emrun -s USE_FREETYPE=1 PLATFORM_LDFLAGS += --js-library $(OF_ADDONS_PATH)/ofxEmscripten/libs/html5video/lib/emscripten/library_html5video.js PLATFORM_LDFLAGS += --js-library $(OF_ADDONS_PATH)/ofxEmscripten/libs/html5audio/lib/emscripten/library_html5audio.js From 6aa60b5120c32bab6b14dde10f81e54320b4831a Mon Sep 17 00:00:00 2001 From: Jonathan <41275844+Jonathhhan@users.noreply.github.com> Date: Mon, 22 Aug 2022 01:40:08 +0200 Subject: [PATCH 06/14] Update config.emscripten.default.mk --- .../project/emscripten/config.emscripten.default.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk b/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk index 5f6267acb25..5aa864336f4 100644 --- a/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk +++ b/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk @@ -93,7 +93,7 @@ ifdef USE_CCACHE endif endif -PLATFORM_LDFLAGS = -Wl --gc-sections --preload-file bin/data@data --emrun -s USE_FREETYPE=1 +PLATFORM_LDFLAGS = -Wl --gc-sections --preload-file bin/data@data --emrun --bind --profiling-funcs -s USE_FREETYPE=1 PLATFORM_LDFLAGS += --js-library $(OF_ADDONS_PATH)/ofxEmscripten/libs/html5video/lib/emscripten/library_html5video.js PLATFORM_LDFLAGS += --js-library $(OF_ADDONS_PATH)/ofxEmscripten/libs/html5audio/lib/emscripten/library_html5audio.js From 5a7c75c0d94a64022f2aee80dd2e525a568422c5 Mon Sep 17 00:00:00 2001 From: Jonathan <41275844+Jonathhhan@users.noreply.github.com> Date: Tue, 23 Aug 2022 21:07:26 +0200 Subject: [PATCH 07/14] Update config.emscripten.default.mk --- .../project/emscripten/config.emscripten.default.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk b/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk index 5aa864336f4..ea03cb7376a 100644 --- a/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk +++ b/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk @@ -93,7 +93,7 @@ ifdef USE_CCACHE endif endif -PLATFORM_LDFLAGS = -Wl --gc-sections --preload-file bin/data@data --emrun --bind --profiling-funcs -s USE_FREETYPE=1 +PLATFORM_LDFLAGS = -Wl --gc-sections --preload-file bin/data@data --emrun --bind --profiling-funcs -s USE_FREETYPE=1 -s DYNCALLS=1 PLATFORM_LDFLAGS += --js-library $(OF_ADDONS_PATH)/ofxEmscripten/libs/html5video/lib/emscripten/library_html5video.js PLATFORM_LDFLAGS += --js-library $(OF_ADDONS_PATH)/ofxEmscripten/libs/html5audio/lib/emscripten/library_html5audio.js From d34c5dba5c86e1c4fa6f805b9b2eaf278760289d Mon Sep 17 00:00:00 2001 From: Jonathan <41275844+Jonathhhan@users.noreply.github.com> Date: Sat, 27 Aug 2022 00:28:43 +0200 Subject: [PATCH 08/14] Update build-emscripten.yml --- .github/workflows/build-emscripten.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-emscripten.yml b/.github/workflows/build-emscripten.yml index 92ea6720615..6172e598cc5 100644 --- a/.github/workflows/build-emscripten.yml +++ b/.github/workflows/build-emscripten.yml @@ -21,7 +21,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Docker Step - run: "docker run -di --name emscripten -v $PWD:/src emscripten/emsdk:1.40.0 bash" + run: "docker run -di --name emscripten -v $PWD:/src emscripten/emsdk:3.1.19 bash" - name: Download libs run: ./scripts/$TARGET/download_libs.sh - name: Install dependencies From 9e59218a0ec79d99c8d57a6f90dce6f681438268 Mon Sep 17 00:00:00 2001 From: Jonathan <41275844+Jonathhhan@users.noreply.github.com> Date: Sun, 28 Aug 2022 01:05:01 +0200 Subject: [PATCH 09/14] Update library_html5audio.js --- .../libs/html5audio/lib/emscripten/library_html5audio.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/ofxEmscripten/libs/html5audio/lib/emscripten/library_html5audio.js b/addons/ofxEmscripten/libs/html5audio/lib/emscripten/library_html5audio.js index a984e36422e..b6b24108952 100644 --- a/addons/ofxEmscripten/libs/html5audio/lib/emscripten/library_html5audio.js +++ b/addons/ofxEmscripten/libs/html5audio/lib/emscripten/library_html5audio.js @@ -199,7 +199,7 @@ var LibraryHTML5Audio = { } } - dynCall('viiii',callback, [bufferSize,inputChannels,outputChannels,userData]); + {{{ makeDynCall('viiii', 'callback') }}}(bufferSize,inputChannels,outputChannels,userData); if(outputChannels>0){ for(c=0;c Date: Sun, 28 Aug 2022 01:05:44 +0200 Subject: [PATCH 10/14] Update config.emscripten.default.mk --- .../project/emscripten/config.emscripten.default.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk b/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk index ea03cb7376a..5aa864336f4 100644 --- a/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk +++ b/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk @@ -93,7 +93,7 @@ ifdef USE_CCACHE endif endif -PLATFORM_LDFLAGS = -Wl --gc-sections --preload-file bin/data@data --emrun --bind --profiling-funcs -s USE_FREETYPE=1 -s DYNCALLS=1 +PLATFORM_LDFLAGS = -Wl --gc-sections --preload-file bin/data@data --emrun --bind --profiling-funcs -s USE_FREETYPE=1 PLATFORM_LDFLAGS += --js-library $(OF_ADDONS_PATH)/ofxEmscripten/libs/html5video/lib/emscripten/library_html5video.js PLATFORM_LDFLAGS += --js-library $(OF_ADDONS_PATH)/ofxEmscripten/libs/html5audio/lib/emscripten/library_html5audio.js From d4ae8a61276f75edb5a1bf3ec9e3e3b19f609c2e Mon Sep 17 00:00:00 2001 From: Jonathan <41275844+Jonathhhan@users.noreply.github.com> Date: Mon, 12 Sep 2022 03:57:44 +0200 Subject: [PATCH 11/14] Update build-emscripten.yml --- .github/workflows/build-emscripten.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-emscripten.yml b/.github/workflows/build-emscripten.yml index 6172e598cc5..e0b43183d1d 100644 --- a/.github/workflows/build-emscripten.yml +++ b/.github/workflows/build-emscripten.yml @@ -21,7 +21,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Docker Step - run: "docker run -di --name emscripten -v $PWD:/src emscripten/emsdk:3.1.19 bash" + run: "docker run -di --name emscripten -v $PWD:/src emscripten/emsdk:3.1.21 bash" - name: Download libs run: ./scripts/$TARGET/download_libs.sh - name: Install dependencies From 7abc9fa0418487e710269a208fe9168c42a0ef6d Mon Sep 17 00:00:00 2001 From: Jonathan <41275844+Jonathhhan@users.noreply.github.com> Date: Sun, 2 Oct 2022 16:57:42 +0200 Subject: [PATCH 12/14] Add files via upload --- .../src/ofxAppEmscriptenWindow.cpp | 44 ++++++++++++++----- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp index b881e589158..c2b3d68aa46 100644 --- a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp +++ b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp @@ -115,40 +115,62 @@ int ofxAppEmscriptenWindow::keyup_cb(int eventType, const EmscriptenKeyboardEven } int ofxAppEmscriptenWindow::mousedown_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData){ - instance->events().notifyMousePressed(mouseEvent->targetX,mouseEvent->targetY,mouseEvent->button); + int canvas_width, canvas_height; + emscripten_get_canvas_element_size("#canvas", &canvas_width, &canvas_height); + double css_width, css_height; + emscripten_get_element_css_size("#canvas", &css_width, &css_height); + instance->events().notifyMousePressed(mouseEvent->targetX * (canvas_width / css_width), mouseEvent->targetY * (canvas_height / css_height),mouseEvent->button); return 0; } int ofxAppEmscriptenWindow::mouseup_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData){ - instance->events().notifyMouseReleased(mouseEvent->targetX,mouseEvent->targetY,0); + int canvas_width, canvas_height; + emscripten_get_canvas_element_size("#canvas", &canvas_width, &canvas_height); + double css_width, css_height; + emscripten_get_element_css_size("#canvas", &css_width, &css_height); + instance->events().notifyMouseReleased(mouseEvent->targetX * (canvas_width / css_width), mouseEvent->targetY * (canvas_height / css_height),0); return 0; } int ofxAppEmscriptenWindow::mousemoved_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData){ + int canvas_width, canvas_height; + emscripten_get_canvas_element_size("#canvas", &canvas_width, &canvas_height); + double css_width, css_height; + emscripten_get_element_css_size("#canvas", &css_width, &css_height); if(ofGetMousePressed()){ - instance->events().notifyMouseDragged(mouseEvent->targetX,mouseEvent->targetY,0); + instance->events().notifyMouseDragged(mouseEvent->targetX * (canvas_width / css_width), mouseEvent->targetY * (canvas_height / css_height),0); }else{ - instance->events().notifyMouseMoved(mouseEvent->targetX,mouseEvent->targetY); + instance->events().notifyMouseMoved(mouseEvent->targetX * (canvas_width / css_width), mouseEvent->targetY * (canvas_height / css_height)); } return 0; } int ofxAppEmscriptenWindow::mouseenter_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData){ - instance->events().notifyMouseEntered(mouseEvent->targetX,mouseEvent->targetY); + int canvas_width, canvas_height; + emscripten_get_canvas_element_size("#canvas", &canvas_width, &canvas_height); + double css_width, css_height; + emscripten_get_element_css_size("#canvas", &css_width, &css_height); + instance->events().notifyMouseEntered(mouseEvent->targetX * (canvas_width / css_width), mouseEvent->targetY * (canvas_height / css_height)); if(mouseEvent->buttons == 0){ - instance->events().notifyMouseReleased(mouseEvent->targetX,mouseEvent->targetY,mouseEvent->button); + instance->events().notifyMouseReleased(mouseEvent->targetX * (canvas_width / css_width), mouseEvent->targetY * (canvas_height / css_height), mouseEvent->button); } return 0; } int ofxAppEmscriptenWindow::mouseleave_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData){ - instance->events().notifyMouseExited(mouseEvent->targetX,mouseEvent->targetY); + int canvas_width, canvas_height; + emscripten_get_canvas_element_size("#canvas", &canvas_width, &canvas_height); + double css_width, css_height; + emscripten_get_element_css_size("#canvas", &css_width, &css_height); + instance->events().notifyMouseExited(mouseEvent->targetX * (canvas_width / css_width), mouseEvent->targetY * (canvas_height / css_height)); return 0; - } int ofxAppEmscriptenWindow::touch_cb(int eventType, const EmscriptenTouchEvent* e, void* userData) { - + int canvas_width, canvas_height; + emscripten_get_canvas_element_size("#canvas", &canvas_width, &canvas_height); + double css_width, css_height; + emscripten_get_element_css_size("#canvas", &css_width, &css_height); ofTouchEventArgs::Type touchArgsType; switch (eventType) { case EMSCRIPTEN_EVENT_TOUCHSTART: @@ -171,8 +193,8 @@ int ofxAppEmscriptenWindow::touch_cb(int eventType, const EmscriptenTouchEvent* ofTouchEventArgs touchArgs; touchArgs.type = touchArgsType; touchArgs.id = i; - touchArgs.x = e->touches[i].targetX; - touchArgs.y = e->touches[i].targetY; + touchArgs.x = e->touches[i].targetX * (int)(canvas_width / css_width); + touchArgs.y = e->touches[i].targetY* (int)(canvas_height / css_height); instance->events().notifyTouchEvent(touchArgs); } return 0; From 9110fbd97b6231124b90dd7d59bdd87cbf0a49c9 Mon Sep 17 00:00:00 2001 From: Jonathan <41275844+Jonathhhan@users.noreply.github.com> Date: Mon, 3 Oct 2022 00:05:27 +0200 Subject: [PATCH 13/14] Add files via upload --- addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp index c2b3d68aa46..eda01893135 100644 --- a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp +++ b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp @@ -193,8 +193,8 @@ int ofxAppEmscriptenWindow::touch_cb(int eventType, const EmscriptenTouchEvent* ofTouchEventArgs touchArgs; touchArgs.type = touchArgsType; touchArgs.id = i; - touchArgs.x = e->touches[i].targetX * (int)(canvas_width / css_width); - touchArgs.y = e->touches[i].targetY* (int)(canvas_height / css_height); + touchArgs.x = std::ceil(e->touches[i].targetX * (canvas_width / css_width)); + touchArgs.y = std::ceil(e->touches[i].targetY* (canvas_height / css_height)); instance->events().notifyTouchEvent(touchArgs); } return 0; @@ -215,7 +215,6 @@ glm::vec2 ofxAppEmscriptenWindow::getWindowPosition(){ glm::vec2 ofxAppEmscriptenWindow::getWindowSize(){ int width; int height; - emscripten_get_canvas_element_size("#canvas", &width, &height); return glm::vec2(width,height); } From 122b6e52dfa43c97ba2e4b5461372de5e5fc3d82 Mon Sep 17 00:00:00 2001 From: Jonathan <41275844+Jonathhhan@users.noreply.github.com> Date: Sat, 19 Nov 2022 02:10:24 +0100 Subject: [PATCH 14/14] Update template.html --- .../project/emscripten/template.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/openFrameworksCompiled/project/emscripten/template.html b/libs/openFrameworksCompiled/project/emscripten/template.html index 7b09ee508ef..d6debad1ff7 100644 --- a/libs/openFrameworksCompiled/project/emscripten/template.html +++ b/libs/openFrameworksCompiled/project/emscripten/template.html @@ -117,8 +117,8 @@ Resize canvas - Lock/hide mouse pointer     - Lock/hide mouse pointer     + @@ -129,7 +129,7 @@
- +
@@ -181,7 +181,7 @@ if (text === Module.setStatus.text) return; var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/); var now = Date.now(); - if (m && now - Date.now() < 30) return; // if this is a progress update, skip it if too soon + if (m && now - Module.setStatus.last.time < 30) return; // if this is a progress update, skip it if too soon if (m) { text = m[1]; progressElement.value = parseInt(m[2])*100;