Skip to content

Commit

Permalink
Update projectM_emscripten.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
ford442 authored Aug 30, 2024
1 parent 0a59f7b commit b26607a
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions projectM_emscripten.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,35 @@ extern "C" {
}

int init() {

EM_ASM({
FS.mkdir('/presets');
FS.mkdir('/textures');


function getShader(pth,fname){
const ff=new XMLHttpRequest();
ff.open('GET',pth,true);
ff.responseType='arraybuffer';
document.querySelector('#stat').innerHTML='Downloading Shader';
document.querySelector('#stat').style.backgroundColor='yellow';
ff.addEventListener("load",function(){
let sarrayBuffer=ff.response;
if(sarrayBuffer){
let sfil=new Uint8ClampedArray(sarrayBuffer);
FS.writeFile('/presets/'+fname,sfil);
document.querySelector('#stat').innerHTML='Downloaded Shader';
document.querySelector('#stat').style.backgroundColor='blue';
}
});
ff.send(null);
}

var pth=document.querySelector('#milkPath').innerHTML;
getShader(pth,'/presets/preset.milk');

});

if (pm) return 0;

// initialize WebGL context attributes
Expand Down

0 comments on commit b26607a

Please sign in to comment.