Forums > Jitter

GL clip planes in max 5?

January 14, 2009 | 10:59 pm

Hi everyone.
OpenGL clipping planes (within jit.gl.sketch) don’t seem to be working on max 5 for me (on Dell Laptop, windows XP). This simple patch that uses them works fine on max 4.6, then the same patch doesn’t clip on max 5. Have any of the command/parameter names changed? Patch as text is pasted below, but it is just feeding a "glclipplane 0 1. 1. 1. 0." to a jit.gl.sketch (which has received "glenable clip_plane0").

Any ideas greatly appreciated!
Thanks, Dan

max v2;
#N vpatcher 10 282 610 682;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 48 51 45 9109513 loadbang;
#P message 253 256 103 9109513 glclipplane 0 1. 1. 1. 0.;
#P newex 250 216 45 9109513 loadbang;
#P flonum 122 197 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 186 217 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 169 197 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 147 216 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 145 236 67 9109513 pak 1. 1. 1. 0.;
#P message 254 310 93 9109513 gldisable clip_plane0;
#P message 265 280 91 9109513 glenable clip_plane0;
#P newex 145 265 95 9109513 prepend glclipplane 0;
#P newex 40 200 65 9109513 jit.window boo;
#P newex 141 300 74 9109513 jit.gl.sketch boo;
#P newex 135 170 237 9109513 jit.gl.gridshape boo @shape torus @scale 0.5 0.5 0.5;
#P newex 41 135 45 9109513 t b erase;
#P toggle 41 78 15 0;
#P newex 43 103 50 9109513 qmetro 50;
#P newex 42 165 72 9109513 jit.gl.render boo;
#P connect 17 0 2 0;
#P connect 1 0 3 0;
#P connect 3 0 0 0;
#P connect 3 1 0 0;
#P connect 2 0 1 0;
#P connect 16 0 5 0;
#P connect 9 0 5 0;
#P connect 8 0 5 0;
#P connect 7 0 5 0;
#P connect 14 0 10 0;
#P connect 10 0 7 0;
#P connect 11 0 10 1;
#P connect 12 0 10 2;
#P connect 13 0 10 3;
#P connect 15 0 16 0;
#P connect 15 0 8 0;


January 14, 2009 | 11:41 pm

On Jan 14, 2009, at 2:59 PM, woffle6452 wrote:

> OpenGL clipping planes (within jit.gl.sketch) don’t seem to be
> working on max 5 for me (on Dell Laptop, windows XP). This simple
> patch that uses them works fine on max 4.6, then the same patch
> doesn’t clip on max 5. Have any of the command/parameter names
> changed? Patch as text is pasted below, but it is just feeding a
> "glclipplane 0 1. 1. 1. 0." to a jit.gl.sketch (which has received
> "glenable clip_plane0").

As far as I can tell, this patch is a misuse of jit.gl.sketch in a
variety of ways, and seeming to rely on some state bleed through.

1. the gl commands to jit.gl.sketch are *added* to a list. so your
configuration for enabling, disabling, changing the clip plane in
jit.gl.sketch are just being added. send jit.gl.sketch

2. jit.gl.sketch state is only supposed to affect elements drawn
inside of jit.gl.sketch’s command list (following the relevant
commands). In old versions of jit.gl.sketch there were state bleed
through issues, which have been fixed. This patch seems like it might
expect this sort of state bleed through. It is highly discouraged to
rely on this kind of behavior unless you are very much aware of how
these objects and open gl works, but you can permit the state changes
inside jit.gl.sketch to bleed through with the attribute @pushstate 0.

Hope this helps.

-Joshua


January 15, 2009 | 1:35 am

Thanks Joshua! You are of course correct, I was expecting the old state bleed through…

Perhaps someone can suggest a better way…
I am generating shapes with jit.gl.gridshape (many with one object, using "@automatic 0" and "matrixoutput 1"). I would like to set up a clipping plane that only clips _some_ of the shapes. For now, doing it all within jit.gl.sketch isn’t really an option unfortunately.

The (inelegant!) workaround I previously had going involved a jit.gl.sketch with "automatic 0". Then for each frame, this occured in this order:
-"erase" to jit.gl.render
-"gldisable clip_plane0" to the jit.gl.sketch
-bang to jit.gl.sketch
-bang to a jit.gl.gridshape (automatic 0 and matrixoutput 1) that wouldn’t get clipped
-"glenable clip_plane0" to the jit.gl.sketch
-bang to jit.gl.sketch
-bang to a different jit.gl.gridshape (also automatic 0 and matrixoutput 1) that would get clipped
-bang to jit.gl.render

And since this grows the sketch command list, just clearing that out every once in a while (or even every frame). Ugly! But it works. Anyone have a more elegant idea?

Best,
Dan


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