OpenGL Position

jhdkfj39929's icon

I have a plane in jit.gl.sketch that I am setting the position of. I am not sure what the values should be and what they depend on. Do they depend on the resolution of the jit.window? How? If I wanted to align 4 planes so that the first would be filling the windows and the rest would be positioned side by side along x, how would I do it? If I, say, have 1280x1024 and 1360x768 windows?

An example would be great but a pointer to an explanation would be good too. Am not managing to find this in the docs...

Thank you.

efe's icon

Jitter tutorial 32

jhdkfj39929's icon

Thank you. I had a look but this tutorial does not answer my questions (above).

I my case the view is set @ortho 2 @up 0. 1. 0.

So, what I need to know is how to set the dimensions and the position of my plane to match the resolution/proportions of my window....

Thanks again. Excuse beginner's questions. I am sure it is simple enough...

seejayjames's icon

I don't think the window size matters at all, it's just the window proportions. If the window is square you should get a full plane by going from -1 to 1 in each axis (X and Y). Modify to suit for rectangular windows, like typical 4X3 proportions would be 1.333 for X and 1.0 for Y.

Be sure your camera is at default position, which I think is 4.0 in the Z axis, though not totally sure about that...

Joshua Kit Clayton's icon

Three possible things which may be of use:

1. jit.gl.render/sketch screentoworld message:

Converts screen coordinates to world coordinates, output out the dump outlet. The input x and y input coordinates are in pixels, and the input z coordinate is in normalized distance from camera (0.-1.), where 0. is the near clipping plane and 1. is the far clipping plane.

2. jit.gl.* transform_reset attribute:

Modelview and projection transform reset flag (default = 0) When the flag is set, the modelview and projection transforms are set to the identity transform before rendering the object. This is useful for sprite or billboard overlays, or automatic scaling to window size. The transform_reset flag modes are:
0 = do nothing (default)
1 = proportional orthographic glOrtho(-aspect, aspect, -1.0, 1.0, near_clip, far_clip);
2 = orthographic normalized glOrtho(-1.0, 1.0, -1.0, 1.0, near_clip, far_clip);
3 = proportional perspective with near clip = 0.001 gluPerspective(lens_angle, aspect, 0.001/*near_clip*/, far_clip);
4 = normalized perspective with near clip = 0.001 gluPerspective(lens_angle, 1.0, 0.001/*near_clip*/, far_clip);

3. jit.gl.sketch glortho command: Please see OpenGL documentation for usage, and read jit.gl.sketch tutorial 40 for how to use standard opengl commands in jit.gl.sketch

jhdkfj39929's icon

Thank you all. Knowing about -1 to 1 range and scaling to proportions fixed it for me it seems.

Thank you for the links. I shall check them out...

seejayjames's icon

thanks jkc for the detailed answer. I've done a lot of experimentation with these kinds of commands and it's not always totally clear what's happening.

One other note, you could simply draw everything as though it was in a square (make your objects symmetrical in X and Y), then stretch the sketch object or stretch the whole GL world, by sending "scale 1.333 1. 1." to jit.gl.sketch or jit.gl.render. This would stretch everything in the X axis by 1.333, so a square object should then fit a 640x480 window, for example.

When you have a ton of objects and you start stretching them in different axes, it looks pretty awesome...

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

In this patch i'm testing videoplane positioning on a jit.window of specific size. The images should be evenly spaced i.e have a border of equal size. In the past using jit.render @scale .885 .885 1. @ortho 2 has made sense (trial and error), in this case something's amiss.