Creating Large Messages (OpenGL commands)

Jan 16, 2010 at 2:43am

Creating Large Messages (OpenGL commands)

Hi all,

I am trying to generate an openGL message to feed into jit.gl.sketch
(something like the messege bellow). It’s not a complicated shape and
I want to dynamically control some of the the coordinates from Max/MSP/Jitter.

So, what I want is the following message (copied at the bottom of this message) with openGL commands, but with the ability to change the numbers dynamically.

My first attempt, I used changeable arguments (“glvertex $1 $2 $3″) and
connected it to numberboxes to the message boxes but quickly learned that they only go up to $9, which is not enough in this case.

I also tried constructing the message from smaller messages by using
“combine”… I generated a smaller message using “sprintf”. First message would be gl commands for polygon 1 -4 and then combined them with the gl
commands for polygon 5-6)… to create the final gl message below.

All my attempts, while it seems algorithmically correct, crashes. I suspect that the messages are becoming too long. (It says that the size of the message can go up to 256 items?).

Q1. I suspect this is not specific to openGL but has to do with the length of the messages. Is there a way to generate very long messages (that I would eventually feed into jit.gl.sketch)?

Q2. It would seem like modifying a 3D shape on the fly (move vertices…etc) would be something people would do. I was wondering if you all had any suggestions or experiences on this.

Thanks so much!

Aki.

The kind of message I want to generate on the fly. (I’d like to specify u, v coordinates to this so the text will most likely be twice the current length and I’d like 1/3 or so of the numbers to bedyncamically generated (eg.from number boxes).

“reset, glmatrixmode modelview, glpushmatrix, glscale 0.1 0.1 0.1,
glcolor 1 1 1 1, glbegin quads, glvertex -7. 6. 3.5, glvertex -3.5
6. 1.1, glvertex -3.5 3. 1.1, glvertex -1. 3. 3.5, glend, glbegin
quads, glvertex -3.5 6. 1.1, glvertex 0. 6. -1.3, glvertex 0. 3. -1.3,
glvertex -3.5 3. 1.1, glend, glbegin quads, glvertex 0. 6. -1.3,
glvertex 2.5 6. 1.1, glvertex 2.5 3. 1.1, glvertex 0. 3. -1.3, glend,
glbegin quads, glvertex 2.5 6. 1.1, glvertex 5. 6. 3.5, glvertex
5. 3. 3.5, glvertex 2.5 3. 1.1, glend, glbegin quads, glvertex
-2. 3. 3.5, glvertex -3.5 3. 1.1, glvertex -2.5 0. 1.1, glvertex
-5. 0. 3.5, glend, glbegin quads, glvertex -3.5 3. 1.1, glvertex
0. 3. -1.3, glvertex 0. 0. -1.3, glvertex -2.5 0. 1.1, glend, glbegin
quads, glvertex 0. 3. -1.3, glvertex 2.5 3. 1.1, glvertex 2.5 0. 1.1,
glvertex 0. 0. -1.3, glend, glbegin quads, glvertex 2.5 3. 1.1,
glvertex 5. 3. 3.5, glvertex 5. 0. 3.5, glvertex 2.5 0. 1.1, glend,
glbegin quads, glvertex -5. 0. 3.5, glvertex -2.5 0. 1.1, glvertex
-2.5 0. 3.85, glvertex -5. 0. 6.25, glend, glbegin quads, glvertex
-2.5 0. 1.1, glvertex 0. 0. -1.3, glvertex 0. 0. 3.85, glvertex -2.5
0. 3.85, glend, glbegin quads, glvertex 0. 0. -1.3, glvertex 2.5
0. 1.1, glvertex 2.5 0. 3.85, glvertex 0. 0. 3.85, glend, glbegin
quads, glvertex 2.5 0. 1.1, glvertex 5. 0. 3.5, glvertex 5. 0. 6.25,
glvertex 2.5 0. 3.85, glend, glbegin quads, glvertex -5. 0. 6.25,
glvertex -2.5 0. 3.85, glvertex -2.5 0. 9., glvertex -5. 0. 9., glend,
glbegin quads, glvertex -2.5 0. 3.85, glvertex 0. 0. 3.85, glvertex
0. 0. 9., glvertex -2.5 0. 9., glend, glbegin quads, glvertex
0. 0. 3.85, glvertex 2.5 0. 3.85, glvertex 2.5 0. 9., glvertex
0. 0. 9., glend, glbegin quads, glvertex 2.5 0. 3.85, glvertex
5. 0. 6.25, glvertex 5. 0. 9., glvertex 2.5 0. 9., glend, glpopmatrix”

#47816
Jan 16, 2010 at 4:14am

hi. i moved your topic to the jitter forum.

the short answer is you don’t have to supply all the draw commands in one message box.

the long answer is to check out the excellent darwin grosse article on creating a “sketchpad” for gl.sketch:

http://cycling74.com/2009/08/31/creating-a-sketchpad-for-jitglsketch/

– Pasted Max Patch, click to expand. –
#171966
Jan 16, 2010 at 4:57am

Most of your commands are:

glbegin quads
glvertex $1 $2 $3
glvertex $1 $2 $3
glvertex $1 $2 $3
glvertex $1 $2 $3
glend

use a [coll] or other means to store triples of your vertex points, then bang them out for each glvertex command. no need for anything greater than $3, because each command only needs X Y Z. You can even avoid the $1 $2 $3 by simply putting [prepend glvertex] after your triples.

look at [trigger] to get your order of operations right, which include the glbegin quads and glend commands.

You can even put them into a simple .txt file, each on their own line, and use a [text] object to send them out using the “line $1″ message…

#171967
Jan 16, 2010 at 8:57pm

Ahhhh! Thanks all.
I forgot that “commas” create a sequence of messages…

Best,

Aki.

#171968
Jan 17, 2010 at 2:29pm

hey miyos,
it is also possible to control very large jit.gl.sketch
commandlists. (with cmd_replace)
my actual project has over 7000 commandlist lines.
it works without problems.

best,
t.

#171969
Jan 21, 2010 at 2:26pm

A small performance-related question on modifying large command lists:

When modifying parameters in a commandlist, would it be more effective to use cmd_replace, or to re-create the entire commandlist?

I assume that the jit.gl.sketch object only sends the commands to the GPU when it’s requested by the jit.gl.render object. Or in case @automatic = 0, when a bang is fired?
Or does any modification to the commandlist result in communication with the GPU?

#171970

You must be logged in to reply to this topic.