jit.window + jit.gl.sketch value scaling

Jun 27, 2010 at 7:48pm

jit.window + jit.gl.sketch value scaling

I’m using Graham Wakefield’s GL buffer patch to try and learn some openGL stuff in Jitter. I’m finding the scaling relationship between the pixel-position of the mouse within jit.window and the value range needed to draw into it with jit.gl.sketch confusing.

I can’t work out the relationship between these value ranges……..the patch will demonstrate this; it works until the window is re-sized, after which my scaling is incorrect (understandably) but I can’t work out how to fix this.

Thanks for the help.

– Pasted Max Patch, click to expand. –
Jun 28, 2010 at 8:55pm

I know I’m impatient :) …….but *bump*

Does anyone know?

Jun 28, 2010 at 9:47pm

i would probably just use the “screentoworld” message to gl.render:

– Pasted Max Patch, click to expand. –
Jun 28, 2010 at 10:09pm

Ok thanks, that takes care of one issue…….now to figure out how to stop window resizing from changing the selection size relative to the size of jit.window.

Is there an explanation anywhere in the max docs about how the GL drawing scale relates to pixels that I’ve overlooked? Your suggestion works, but I still don’t understand what the relationship is between screen and “world” coordinates.

Thanks for the help!

Jun 29, 2010 at 6:37pm

Back again, do you know why this patch only draws the upper half of the green line?

* warning – noob question *

Is it because I need more than one “plane” to draw into with jit.gl.render, so that the drawing commands of the line and the selection box don’t conflict?

Cheers for the help.

– Pasted Max Patch, click to expand. –
Jun 29, 2010 at 7:06pm

i believe the linesegment message should be like this:
linesegment $1 2 -2 $1 -2 -2

you will want to turn on blend_enable on your gl.sketch, and provide an alpha value of less than 1. for the glcolor that colorizes the glrect.
this will allow you to see through the rect to the green line.


You must be logged in to reply to this topic.