From 9bd2f08c8f5dd9d5a05bc2d0a90b757cda69059d Mon Sep 17 00:00:00 2001 From: themancalledjakob Date: Fri, 29 Mar 2024 09:19:37 +0100 Subject: [PATCH] fix (partially) linux compilation dependencies hashes: openFrameworks d78075f4bca6be2a2533c6e51a75cc1f18404501 ofxMsdfgen e14da13d02c4dff04fb69d7923469f606924e6c3 ofxGPUFont d482bb7cbdf6b296fa4ab5abcf73fb5ff8c8b239 ofxVariableLab 0b5f9bdebc1e5550621957e73c040c258ec6317b ofxProfiler a868e34fa1a79189dd4fbdede2938e308535e5e8 theatre 86d3e07f6f2c75fd6e08fca8c97e3617c9e23b18 --- src/ofApp.cpp | 33 ++++++++++++++++++++------------- src/ofApp.h | 45 +++++++++++++++++++++++++++++++-------------- 2 files changed, 51 insertions(+), 27 deletions(-) diff --git a/src/ofApp.cpp b/src/ofApp.cpp index 2e1e174..d312fa1 100644 --- a/src/ofApp.cpp +++ b/src/ofApp.cpp @@ -31,7 +31,9 @@ namespace VariableEditor { //-------------------------------------------------------------- void ofApp::setup(){ OFX_PROFILER_FUNCTION(); - EM_ASM({window.setLoadingTask('setting up rendering', 0)}); + #ifdef TARGET_EMSCRIPTEN + EM_ASM({window.setLoadingTask('setting up rendering', 0)}); + #endif { ofFile sf("appSettings.json"); @@ -58,7 +60,9 @@ void ofApp::setup(){ 10000000, // farDist glm::vec2(0, 0) // lensOffset ); - EM_ASM({window.setLoadingTask('setting up rendering', 10)}); + #ifdef TARGET_EMSCRIPTEN + EM_ASM({window.setLoadingTask('setting up rendering', 10)}); + #endif ofDisableArbTex(); fboSettings.width = ofGetWidth() * AA; @@ -79,25 +83,26 @@ void ofApp::setup(){ //fbo.allocate(ofGetWidth() * AA, ofGetHeight() * AA, GL_RGB); - EM_ASM({window.setLoadingTask('setting up rendering', 30)}); + #ifdef TARGET_EMSCRIPTEN + EM_ASM({window.setLoadingTask('setting up rendering', 30)}); + #endif layerComposition.setup(); - EM_ASM({window.setLoadingTask('setting up rendering', 90)}); + #ifdef TARGET_EMSCRIPTEN + EM_ASM({window.setLoadingTask('setting up rendering', 90)}); + #endif layerComposition.setVFlip(true); - #ifndef TARGET_OPENGLES + #ifndef TARGET_EMSCRIPTEN { - std::string fontPath = "data/fonts/Version-2-var.ttf"; - ofxVariableLab::LayerType type = ofxVariableLab::LayerType::GPUFONT; + std::string fontPath = "data/fonts/Version-2.ttf"; ofxVariableLab::Layer::Props props; props.fontPath = fontPath; props.text = "yo, whatever you want, and especially pancakes"; props.y = 120; props.x = 95; - layerComposition.addLayer( - {fontPath, type}, - props, - {{"Weight", 100.0}, {"Weight", 700.0}} - ); + if(ofFile(fontPath).exists()){ + layerComposition.addLayer(props, "layer-0"); + } } #endif @@ -130,7 +135,9 @@ void ofApp::setup(){ << " | Minor(" << ofToString(glMajor) << ")" << endl; artboard.setup(); - EM_ASM({window.setLoadingTask('setting up rendering', 100)}); + #ifdef TARGET_EMSCRIPTEN + EM_ASM({window.setLoadingTask('setting up rendering', 100)}); + #endif } //-------------------------------------------------------------- diff --git a/src/ofApp.h b/src/ofApp.h index d2ae3ec..791ca2a 100644 --- a/src/ofApp.h +++ b/src/ofApp.h @@ -5,6 +5,7 @@ #include "conversion.h" #include "Artboard.h" #include "ofEasyCam.h" +#include "ofFileUtils.h" #include "ofMain.h" #include "ofQuaternion.h" #include "ofTrueTypeFont.h" @@ -58,10 +59,14 @@ class ZipProjectSaver : void update(){ if(freshDownload.load()){ - emscripten_browser_file::download(filename.c_str(), - "application/zip", - buffer, - buffer_size); + #ifdef TARGET_EMSCRIPTEN + emscripten_browser_file::download(filename.c_str(), + "application/zip", + buffer, + buffer_size); + #else + ofBufferToFile(filename.c_str(), ofBuffer(buffer, buffer_size)); + #endif freshDownload.store(false); } } @@ -155,7 +160,8 @@ class ZipSaver : public ofThread { void update(){ if(freshDownload.load()){ - EM_ASM({ + #ifdef TARGET_EMSCRIPTEN + EM_ASM({ document.getElementById('export_progress_task').innerHTML = 'rendering'; let innerHTML = "|"; for(let i = 0; i < 100; i++){ @@ -167,10 +173,13 @@ class ZipSaver : public ofThread { let progress_task = document.getElementById("export_progress_task"); progress_task.innerHTML = "idle"; }); - emscripten_browser_file::download(filename.c_str(), - "application/zip", - buffer, - buffer_size); + emscripten_browser_file::download(filename.c_str(), + "application/zip", + buffer, + buffer_size); + #else + ofBufferToFile(filename.c_str(), ofBuffer(buffer, buffer_size)); + #endif freshDownload.store(false); }else if(isThreadRunning()){ setProgress(percent.load()); @@ -178,7 +187,8 @@ class ZipSaver : public ofThread { } void setProgress(int percent){ - EM_ASM_INT({ + #ifdef TARGET_EMSCRIPTEN + EM_ASM_INT({ let percent = $0; document.getElementById('export_progress_task').innerHTML = 'rendering'; let innerHTML = "|"; @@ -196,6 +206,9 @@ class ZipSaver : public ofThread { let progress_task = document.getElementById("export_progress_task"); progress_task.innerHTML = "creating zip file"; }, percent); + #else + std::cout << "progress: " << percent << "/100" << std::endl; + #endif } void threadedFunction(){ @@ -213,9 +226,9 @@ class ZipSaver : public ofThread { ofImage image; image.setUseTexture(false); image.load(filepath); - ofBuffer buffer; - ofSaveImage(image.getPixels(), buffer, OF_IMAGE_FORMAT_PNG); - zip.addBuffer(f + ".png", buffer.getData(), buffer.size()); + ofBuffer b; + ofSaveImage(image.getPixels(), b, OF_IMAGE_FORMAT_PNG); + zip.addBuffer(f + ".png", b.getData(), b.size()); percent.store((float(i) / float(total)) * 100.0f); i++; } @@ -257,7 +270,8 @@ class ZipUnpacker : public ofThread { } void setProgress(int percent){ - EM_ASM_INT({ + #ifdef TARGET_EMSCRIPTEN + EM_ASM_INT({ let percent = $0; document.getElementById('export_progress_task').innerHTML = 'uploading and unpacking'; let innerHTML = "|"; @@ -275,6 +289,9 @@ class ZipUnpacker : public ofThread { let progress_task = document.getElementById("import_progress_task"); progress_task.innerHTML = "creating zip file"; }, percent); + #else + std::cout << "progress: " << percent << "/100" << std::endl; + #endif } void threadedFunction(){