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(){
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
}
//--------------------------------------------------------------

View file

@ -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(){