fix (partially) linux compilation

dependencies hashes:
openFrameworks d78075f4bca6be2a2533c6e51a75cc1f18404501
ofxMsdfgen e14da13d02c4dff04fb69d7923469f606924e6c3
ofxGPUFont d482bb7cbdf6b296fa4ab5abcf73fb5ff8c8b239
ofxVariableLab 0b5f9bdebc1e5550621957e73c040c258ec6317b
ofxProfiler a868e34fa1a79189dd4fbdede2938e308535e5e8
theatre 86d3e07f6f2c75fd6e08fca8c97e3617c9e23b18
This commit is contained in:
themancalledjakob 2024-03-29 09:19:37 +01:00
parent 8a92646038
commit 9bd2f08c8f
2 changed files with 51 additions and 27 deletions

View file

@ -31,7 +31,9 @@ namespace VariableEditor {
//-------------------------------------------------------------- //--------------------------------------------------------------
void ofApp::setup(){ void ofApp::setup(){
OFX_PROFILER_FUNCTION(); OFX_PROFILER_FUNCTION();
#ifdef TARGET_EMSCRIPTEN
EM_ASM({window.setLoadingTask('setting up rendering', 0)}); EM_ASM({window.setLoadingTask('setting up rendering', 0)});
#endif
{ {
ofFile sf("appSettings.json"); ofFile sf("appSettings.json");
@ -58,7 +60,9 @@ void ofApp::setup(){
10000000, // farDist 10000000, // farDist
glm::vec2(0, 0) // lensOffset glm::vec2(0, 0) // lensOffset
); );
#ifdef TARGET_EMSCRIPTEN
EM_ASM({window.setLoadingTask('setting up rendering', 10)}); EM_ASM({window.setLoadingTask('setting up rendering', 10)});
#endif
ofDisableArbTex(); ofDisableArbTex();
fboSettings.width = ofGetWidth() * AA; fboSettings.width = ofGetWidth() * AA;
@ -79,25 +83,26 @@ void ofApp::setup(){
//fbo.allocate(ofGetWidth() * AA, ofGetHeight() * AA, GL_RGB); //fbo.allocate(ofGetWidth() * AA, ofGetHeight() * AA, GL_RGB);
#ifdef TARGET_EMSCRIPTEN
EM_ASM({window.setLoadingTask('setting up rendering', 30)}); EM_ASM({window.setLoadingTask('setting up rendering', 30)});
#endif
layerComposition.setup(); layerComposition.setup();
#ifdef TARGET_EMSCRIPTEN
EM_ASM({window.setLoadingTask('setting up rendering', 90)}); EM_ASM({window.setLoadingTask('setting up rendering', 90)});
#endif
layerComposition.setVFlip(true); layerComposition.setVFlip(true);
#ifndef TARGET_OPENGLES #ifndef TARGET_EMSCRIPTEN
{ {
std::string fontPath = "data/fonts/Version-2-var.ttf"; std::string fontPath = "data/fonts/Version-2.ttf";
ofxVariableLab::LayerType type = ofxVariableLab::LayerType::GPUFONT;
ofxVariableLab::Layer::Props props; ofxVariableLab::Layer::Props props;
props.fontPath = fontPath; props.fontPath = fontPath;
props.text = "yo, whatever you want, and especially pancakes"; props.text = "yo, whatever you want, and especially pancakes";
props.y = 120; props.y = 120;
props.x = 95; props.x = 95;
layerComposition.addLayer( if(ofFile(fontPath).exists()){
{fontPath, type}, layerComposition.addLayer(props, "layer-0");
props, }
{{"Weight", 100.0}, {"Weight", 700.0}}
);
} }
#endif #endif
@ -130,7 +135,9 @@ void ofApp::setup(){
<< " | Minor(" << ofToString(glMajor) << ")" << " | Minor(" << ofToString(glMajor) << ")"
<< endl; << endl;
artboard.setup(); artboard.setup();
#ifdef TARGET_EMSCRIPTEN
EM_ASM({window.setLoadingTask('setting up rendering', 100)}); EM_ASM({window.setLoadingTask('setting up rendering', 100)});
#endif
} }
//-------------------------------------------------------------- //--------------------------------------------------------------

View file

@ -5,6 +5,7 @@
#include "conversion.h" #include "conversion.h"
#include "Artboard.h" #include "Artboard.h"
#include "ofEasyCam.h" #include "ofEasyCam.h"
#include "ofFileUtils.h"
#include "ofMain.h" #include "ofMain.h"
#include "ofQuaternion.h" #include "ofQuaternion.h"
#include "ofTrueTypeFont.h" #include "ofTrueTypeFont.h"
@ -58,10 +59,14 @@ class ZipProjectSaver :
void update(){ void update(){
if(freshDownload.load()){ if(freshDownload.load()){
#ifdef TARGET_EMSCRIPTEN
emscripten_browser_file::download(filename.c_str(), emscripten_browser_file::download(filename.c_str(),
"application/zip", "application/zip",
buffer, buffer,
buffer_size); buffer_size);
#else
ofBufferToFile(filename.c_str(), ofBuffer(buffer, buffer_size));
#endif
freshDownload.store(false); freshDownload.store(false);
} }
} }
@ -155,6 +160,7 @@ class ZipSaver : public ofThread {
void update(){ void update(){
if(freshDownload.load()){ if(freshDownload.load()){
#ifdef TARGET_EMSCRIPTEN
EM_ASM({ EM_ASM({
document.getElementById('export_progress_task').innerHTML = 'rendering'; document.getElementById('export_progress_task').innerHTML = 'rendering';
let innerHTML = "|"; let innerHTML = "|";
@ -171,6 +177,9 @@ class ZipSaver : public ofThread {
"application/zip", "application/zip",
buffer, buffer,
buffer_size); buffer_size);
#else
ofBufferToFile(filename.c_str(), ofBuffer(buffer, buffer_size));
#endif
freshDownload.store(false); freshDownload.store(false);
}else if(isThreadRunning()){ }else if(isThreadRunning()){
setProgress(percent.load()); setProgress(percent.load());
@ -178,6 +187,7 @@ class ZipSaver : public ofThread {
} }
void setProgress(int percent){ void setProgress(int percent){
#ifdef TARGET_EMSCRIPTEN
EM_ASM_INT({ EM_ASM_INT({
let percent = $0; let percent = $0;
document.getElementById('export_progress_task').innerHTML = 'rendering'; document.getElementById('export_progress_task').innerHTML = 'rendering';
@ -196,6 +206,9 @@ class ZipSaver : public ofThread {
let progress_task = document.getElementById("export_progress_task"); let progress_task = document.getElementById("export_progress_task");
progress_task.innerHTML = "creating zip file"; progress_task.innerHTML = "creating zip file";
}, percent); }, percent);
#else
std::cout << "progress: " << percent << "/100" << std::endl;
#endif
} }
void threadedFunction(){ void threadedFunction(){
@ -213,9 +226,9 @@ class ZipSaver : public ofThread {
ofImage image; ofImage image;
image.setUseTexture(false); image.setUseTexture(false);
image.load(filepath); image.load(filepath);
ofBuffer buffer; ofBuffer b;
ofSaveImage(image.getPixels(), buffer, OF_IMAGE_FORMAT_PNG); ofSaveImage(image.getPixels(), b, OF_IMAGE_FORMAT_PNG);
zip.addBuffer(f + ".png", buffer.getData(), buffer.size()); zip.addBuffer(f + ".png", b.getData(), b.size());
percent.store((float(i) / float(total)) * 100.0f); percent.store((float(i) / float(total)) * 100.0f);
i++; i++;
} }
@ -257,6 +270,7 @@ class ZipUnpacker : public ofThread {
} }
void setProgress(int percent){ void setProgress(int percent){
#ifdef TARGET_EMSCRIPTEN
EM_ASM_INT({ EM_ASM_INT({
let percent = $0; let percent = $0;
document.getElementById('export_progress_task').innerHTML = 'uploading and unpacking'; document.getElementById('export_progress_task').innerHTML = 'uploading and unpacking';
@ -275,6 +289,9 @@ class ZipUnpacker : public ofThread {
let progress_task = document.getElementById("import_progress_task"); let progress_task = document.getElementById("import_progress_task");
progress_task.innerHTML = "creating zip file"; progress_task.innerHTML = "creating zip file";
}, percent); }, percent);
#else
std::cout << "progress: " << percent << "/100" << std::endl;
#endif
} }
void threadedFunction(){ void threadedFunction(){