Forums > Javascript

Strange behavior with gl.sketch and javascript

October 24, 2012 | 4:33 pm

I have been working on converting some tutorials to javascript.

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

In the third example of the tutorial, it defines a triangle with different colored corners.
In my javascript version, only the last glcolor command shows. Which makes me think
that something is getting lost when sending commands to gl.sketch via javascript.

Anyone have any ideas?

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();
}


October 24, 2012 | 4:51 pm

Here is my test patch as well.


Viewing 2 posts - 1 through 2 (of 2 total)