javascript gl.sketch problem

Oct 15, 2012 at 3:46pm

javascript gl.sketch problem

hi, i try to figure out why i didn’t see the light effect? its an pyramid in open gl but it looks flat without the light. can anybody give me an advice, where the failure is and how to adjust the light position? thx.
you only need to save the script to an js object and send a “draw” message to the object.

the script::
autowatch = 1;
inlets = 1;

var windowout = new JitterObject(“jit.window”,”Sketchrender”);
windowout.depthbuffer = 0;
windowout.idlemouse = 1;
windowout.fsaa = 1;

var render = new JitterObject(“jit.gl.render”,”Sketchrender”);
render.ortho = 1;
render.erase_color = [0,0,0,1];
var Objekt = [-0.5,-0.5,0,-0.5,0.5,0,0.5,0.5,0,0.5,-0.5,0,-0.5,-0.5,0];

function draw(){
var sketch = new JitterObject(“jit.gl.sketch”,”Sketchrender”);
sketch.glbegin(“triangles”);
sketch.gllightmodel(“two_side”, “true”);
sketch.glenable(“lighting”);
sketch.glenable(“light0″);
sketch.glcolor(1,1,1,1);
for(j = 0; j < 4;j++){
sketch.glvertex(0,0,1);
sketch.glvertex(Objekt[(j*3) + 0],Objekt[(j*3) + 1],Objekt[(j*3) + 2]);
sketch.glvertex(Objekt[(j*3) + 3],Objekt[(j*3) + 4],Objekt[(j*3) + 5]);
}
sketch.glend();
bang();
}

function bang(){
render.erase();
render.drawclients();
render.swap();
}

#64784
Oct 16, 2012 at 2:55pm

Did you try creating a jit.gl.light?

#233644
Oct 16, 2012 at 5:42pm

no i thought i use the light at the render, like in jitter. did i have to create a light in js?

#233645
Oct 19, 2012 at 5:24pm

You should be able to make a light anywhere, as long as its in the same context… want to post your patch?

#233646
Oct 23, 2012 at 11:22pm

Hey audiovisualist, I seem to be having some problems with gl.sketch as well.
I have been working on converting some tutorials to javascript.

http://cycling74.com/docs/max5/tutorials/jit-tut/jitterchapter40.html

In this example, only the last glcolor command shows. Which makes me think
that something is getting lost when sending commands to gl.sketch via javascript.

autowatch = 1;
inlets = 1;

var windowout = new JitterObject(“jit.window”,”Sketchrender”);
windowout.depthbuffer = 0;
windowout.idlemouse = 1;
windowout.fsaa = 1;

var render = new JitterObject(“jit.gl.render”,”Sketchrender”);
render.ortho = 1;
render.erase_color = [0,0,0,1];

function bang()
{
render.erase();
render.drawclients();
render.swap();
}

function draw()
{
drawTriangle3();
}

function drawTriangle3()
{
var sketch = new JitterObject(“jit.gl.sketch”,”Sketchrender”);
with(sketch)
{
reset();
glbegin(“triangles”);
glcolor(1, 0, 0, 1);
glvertex(-0.5, -0.5);
glcolor(0, 1, 0, 1);
glvertex(0, 0.5);
glcolor(0, 0, 1, 1);
glvertex(0.5, -0.5);
glend();
}
bang();
}

#233647

You must be logged in to reply to this topic.