Forums > Jitter

JS: loading textures on start up

January 6, 2007 | 2:03 pm

ok….. last one(I hope.) I’m trying very hard to follow the
documentation here. I hope this isn’t something stupid because I
really feel bad asking for so much help.

the problem here, is that it takes 3 tries to get a texture loaded in
jit.js. in max it appears that jit.gl.texture makes max wait until
its done loading the file. but in javascript, it lets JS executing
the code. any work arounds for this?

///////////////////////////MAX
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 196 67 48 196617 loadbang;
#P user jit.pwindow 195 186 82 62 0 1 0 0 1 0;
#X name zoe;
#P newex 196 102 88 196617 js testTexture.js;
#P window linecount 9;
#P user com 300 190 264 196617 78;
#K set 0 26990 29556 29301 25460 26991 28275 14880 3341 28001 27493
8307 30066 25888 29800 25888 26989 24935 25888 28769 29800 8297 28192
29800 25888 27233 30305 29539 29289 28788 8297 29472 24864 30305
27753 25632 28526 25869 29285 29556 24946 29728 28001 30733 27759
24932 8308 26729 29472 28769 29795 26637 26729 29728 27759 24932
25185 28263 3432 26996 8300 28513 25698 24942 26400 24935 24937 28173
25448 25955 27424 29800 25888 28001 30752 30569 28260 28535 3328;
#K end;
#P connect 3 0 1 0;
#P window clipboard copycount 4;

////////////////NAME THIS testTexture.js
autowatch=1;

var changeMeToAValidImagePath = "moooooooo"
var myrender = null;
var dirtTexture =null
var background = null
var myrender = new JitterObject("jit.gl.render","zoe");

function loadbang()
{
post("begin loadbang–n");
dirtTexture = new JitterObject("jit.gl.texture","zoe")
dirtTexture.name = "dirt"
dirtTexture.file = changeMeToAValidImagePath
post("dirtTexture.dim AFTER dirtTexture.file
assignment: ,",dirtTexture.dim,"n");

background = new JitterObject("jit.gl.gridshape","zoe")
background.shape = "plane"
background.texture = "dirt";

draw();
}

function draw()
{
myrender.erase();
myrender.drawclients();
myrender.swap();
}


Viewing 1 post (of 1 total)