jit.gl.sketch to jit.matrix

wijesijp's icon

According to the documentation of jit.gl.sketch you can draw to a jit.matrix. But I cannot get it to work
I initialized my objects as;

window = new  JitterObject("jit.window", "draw_plane");
myrender = new  JitterObject("jit.gl.render", "draw_plane");
back_draw = new JitterMatrix("matrix_render");

When I draw;

myrender.send("erase");
myrender.send("draw_pixels", new Atom[] { Atom.newAtom("matrix_render") });
myrender.send("drawswap");
sketch.setAttr("drawto", "matrix_render");
sketch.send("reset");
DrawColorSquare(vo1, vo2, vo3, vo4,1.0f,0.0f,0.0f);

If I change the line;
sketch.setAttr("drawto", "matrix_render");
to
sketch.setAttr("drawto", " draw_plane");
I can see the color square I am drawing
Can anyone give any advice on this?

pelado's icon

I can't provide the java code for you, but the 'drawto' message refers to the render context, which has to be the name of the window that you render to. matrix_render is the name you are providing for the jitter matrix that you want to draw your frame buffer into (I presume). The command that you need to provide to glsketch is something like 'drawpixels matrix_render [matrix dims]' whilst maintaining the context for your sketch object as draw_plane.

There is an example jitter patch using this method in the render to matrix examples, which might help clarify the steps and commands that you instruct jit.gl.sketch to follow. I don't remember the exact wording for the command to sketch so you're best checking this out.

There's also a java forum that might be of help to you, rather than asking here.

pelado

pelado's icon

Oh, I'm sorry about that last reply, for some reason I didn't get all of your message, and missed that you are already using the draw_pixels command. But anyway the I think the 'drawto' context part is still relevant.

pelado

pelado's icon

Ahh, reading the full message correctly... or more accurately I think, I see you are making another error. You don't send the draw pixels command to render but to sketch. So, something like

reset;
draw_pixels matrix_render;

should capture the frame buffer into the jit.matrix called matrix_render. You would then need to send the data from the jit.matrix to some processing chain and render it again to be able to see it. For example, capture the buffer, mess with the geometry, then render the result using sketch with a command like

drawmatrix 'my_messed_up_geometry';

I assume that you have created a jit.gl.sketch in your code that is not visible? If not then you probably need to do so

mysketch = new JitterObject("jit.sketch", "draw_plane");

but I'm getting out of my depth trying to answer java questions. Again you might get more help from the java forum

pelado