jit.gl.text2d created with javascript not working ?

Aug 30, 2010 at 3:13pm

jit.gl.text2d created with javascript not working ?

please help,
i have a simple stripped down javascript, that should write some text in a window with jit.gl.text2d.
i can see the axes of jit.gl.text2d, but not the text.
in the example below i include a jit.gl.gridshape just to show, that this one works fine.
any ideas?
thanks
klaus

autowatch = 1;
var window = new JitterObject(“jit.window”,”thewin”);
window.depthbuffer = 1;
window.idlemouse = 1;
var render = new JitterObject(“jit.gl.render”,”thewin”);
render.ortho = 2;
var tt,ss;

tt = new JitterObject(“jit.gl.gridshape”,”thewin”);
tt.scale = [0.1,0.1,0.1];
tt.position = [Math.random()-0.5,Math.random()-0.5,0];
tt.shape = “plane”;
tt.lighting_enable = 1;
tt.smooth_shading = 1;

ss = new JitterObject(“jit.gl.text2d”,”thewin”);
ss.text = “ertz”;
ss.size = 78;
ss.axes = 1;
ss.position = [Math.random()-0.5,Math.random()-0.5,0];

function bang()
{

render.erase();
render.drawclients();
render.swap();
}

#52053
Aug 30, 2010 at 8:31pm

Sounds like a depth buffering issue. You may way to disable depth buffeting for your text object and explicitly render after the gridshape.

-Joshua

#186971
Aug 30, 2010 at 9:19pm

i try ..
and turn off depth buffering here with depth_enable = 0
but the following still does not show my text:

autowatch = 1;
var window = new JitterObject(“jit.window”,”thewin”);
window.depthbuffer = 0;
window.idlemouse = 1;
var render = new JitterObject(“jit.gl.render”,”thewin”);
render.ortho = 2;
var ss;

ss = new JitterObject(“jit.gl.text2d”,”thewin”);
ss.text = “ertz”;
ss.size = 78;
ss.axes = 1;
ss.depth_enable = 0;

function bang()
{

render.erase();
render.drawclients();
render.swap();
}

#186972
Aug 29, 2012 at 5:34am

you can use ss.text("ertz"); syntax instead of ss.text = "ertz".
i had a same problem. i wish Max has more detail reference about javascript :)

#186973
Aug 30, 2012 at 3:56pm

The difference between ss.text("foobar") and (say) ss.depth_enable=0 is that text is a message to jit.gl.text2d while depth_enable is an attribute.

This is actually all documented fairly clearly in the Max reference.

Javascript will, of course happily allow you to shoot yourself in the kneecap as much as you want, but that’s another story.

BTW, size is another message that you’re treating as an attribute in the posted code.

Always remember:

- Max messages are functions in Javascript
- Max attributes are attributes in Javascript (you can set and get using simple assignment)

Ignore those two rules at your own peril

#186974

You must be logged in to reply to this topic.