jit.window + jit.gl.sketch value scaling

Tim Lloyd's icon

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.

Max Patch
Copy patch and select New From Clipboard in Max.

Thanks for the help.

Tim Lloyd's icon

I know I'm impatient :) .......but *bump*

Does anyone know?

Rob Ramirez's icon
Max Patch
Copy patch and select New From Clipboard in Max.

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

Tim Lloyd's icon

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!

Tim Lloyd's icon

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?

Max Patch
Copy patch and select New From Clipboard in Max.

Cheers for the help.

Rob Ramirez's icon

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.