Forums > Jitter

jit.gl.gridshape, jit.gl.render, rendering to a matrix and changing the dims

May 15, 2014 | 9:01 am

I’ve got a problem in my patch: when I’ve got a jit.gl.gridshape and a jit.gl.render working together to draw a shape to a matrix, when I change the dimensions of that matrix, the resulting animation no longer fills the matrix.

I change my matrix dims all the time, and I need the gl side of things to adapt immediately. How should I do this?

Here’s my example code. Click the message box labeled ‘change dimensions…’ to see what I mean.

– Pasted Max Patch, click to expand. –

May 15, 2014 | 11:02 am

here you go !

– Pasted Max Patch, click to expand. –

May 16, 2014 | 6:29 am

Hey DiscoPatrick,

Just out of curiosity why would you want to do this? If you want to make a smaller OpenGL display why not resize the pwindow? If you want to resize something for the purposes of displaying it, why are you not using a texture? Is there some other scenario where you would want to
resize a matrix?

Anthony


May 16, 2014 | 9:37 am

Thanks Andro, that’s great.

Anthony, I’d be happy to explain. My ultimate output is not to a screen or window, but to an array of DMX controllable lights. So eventually I have to convert my video from the GL paradigm (which doesn’t care about pixels) to the matrix paradigm (which is of a fixed width and height) so that I can map each pixel value to the appropriate light.

Sometimes I spread the image across the whole array, sometimes just a section of it – so I need to be able to change the matrix dimensions.


May 16, 2014 | 9:46 am

Andro – if I remove the jit.window from the patch, the animation stops. Seems odd. Is there a way to just use the matrix and pwindow?



SID
May 16, 2014 | 3:32 pm

Send the message ‘visible 0′ to the jit.window object.


May 17, 2014 | 3:16 am

SID nailed it there ! I also do this when I’m sending video from max to syphon so I don’t need to draw the render output twice.


May 20, 2014 | 3:12 pm

Hi Sid and Andro,

Yes, using ‘@visible 0′ would indeed sort the problem. I guess I’m still a little confused as to why you need the window object at all. Seems unintuitive if you only wish to render to a matrix. Feels like a workaround rather than a proper solution.

Ahhh… I think I’ve found the answer. If I delete the window object, the jit.gl.node object stops outputting to its pwindow (and the matrix). But if I save, close, reopen, and then name the matrix the same as the other objects, it works:

– Pasted Max Patch, click to expand. –

May 21, 2014 | 1:03 pm

Hey folks,

So I see how this is being done now, very cool. So I have a javascript interface that I have developed that creates objects and adds the to a rendering context. I want to take the output of this context and send it to a matrix as we did above. The problem is my objects are created in javascript land. I could create a jit.gl.node in javascript, but how do I tell it what objects I want it to capture?


May 21, 2014 | 1:21 pm

you simply set the @drawto of your objects to the @name of the jit.gl.node.
the node can be inside or outside of the JS.


May 21, 2014 | 2:19 pm

So my creating my gl.node would look something like this…

RenderNode = new JitterObject("jit.gl.node", RendererContext);
RenderNode.name = RenderNodeName;

And creating objects would look like this…
var object = new JitterObject("jit.gl.gridshape", RendererContext);
object.drawto = RenderNodeName;

Yes?


May 21, 2014 | 3:12 pm

that would work, or you can skip the last line and do:
var object = new JitterObject("jit.gl.gridshape", RenderNodeName);


May 21, 2014 | 6:47 pm

So I am having a little bit of trouble with getting the output to show up in the output matrix. The problem seems to be the name I am trying to assign to the output matrix. When I try to have everything use the render context, javascript complains that the name is already in use. If I use a different render node name, and change the name of the matrix in javascript, I do not see the output.

I have attached my example. If you could give it a quick look over I would be grateful.


May 22, 2014 | 12:56 pm

I updated my example to better demonstrate the issue i am seeing. Also if I explicitly set the output matrix "name" in the patch to the render node name, I get the following error…

name GlRenderNode already in use. ob3d does not allow multiple bindings


May 26, 2014 | 11:51 am

Hey Rob, is there any word on this issue. It would be great to have this example working in javascript as well. The problem seems to be specifying the name of the output matrix within in the patcher or alternately trying to change it in script.


May 28, 2014 | 5:44 am

i’m not really sure what you’re trying to achieve or what’s not working.
your patch works fine for me.

if you want to capture your gl-scene output to a matrix, use gl.asyncread:

– Pasted Max Patch, click to expand. –

May 30, 2014 | 9:34 am

Hey Rob, thanks for your response. Yes using gl.asyncread works, but I thought the idea was to use jit.gl.node. In which case the example I posted should demonstrate that the matrix is not capturing the jit.gl.node output. I am not sure if this is a bug or not.


May 30, 2014 | 11:50 am

Thanks Rob Ramirez, I think jit.gl.asyncread was exactly what I was looking for in the first place – it allows me to convert gl stuff back into the matrix world.


June 2, 2014 | 11:16 am

if jit.gl.node has capturing enabled (@capture 1) it will output a jit.gl.texture.
within javascript you can get that gl.texture by querying the jit.gl.node @out_name:
var nodeoutname = mynode.out_name

you can then send this texture name to any jitter matrix, prepended with the "jit_gl_texture" message, and the matrix will draw the texture.
so from js, if you want to draw to a matrix in your patch, connect the js out to the matrix and send the message out:
outlet(0, "jit_gl_texture", nodeoutname);


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