polygon stippling

Mar 6, 2007 at 5:51pm

polygon stippling

Hello,

Does jit.gl.sketch incorporate a message to set the OpenGL polygon stippling pattern? Line stippling works fine, and apparently polygon_stipple can be enabled and disabled, but I don’t see a message to set the 32×32 pattern matrix.

thanks in advance,

Alex

#30657
Mar 6, 2007 at 6:06pm

On Mar 6, 2007, at 9:51 AM, Alex Stahl wrote:

> Does jit.gl.sketch incorporate a message to set the OpenGL polygon
> stippling pattern? Line stippling works fine, and apparently
> polygon_stipple can be enabled and disabled, but I don’t see a
> message to set the 32×32 pattern matrix.

Unfortunately, we don’t support a polygon stippling matrix at the
moment (and it probably won’t make it into 1.6.3). You might be to
just bind a texture and use one of the various auto texturing modes.
Not sure if there’s some functional problem with that for your
application, but it would seem that with some appropriate
interpolation (none), blending (on), texture generation (eyespace),
and an appropriate scaling factor to match the pixels on the screen
that it should work similar to the standard polygon stippling setting.

-Joshua

#98314
Mar 6, 2007 at 6:23pm

Thanks very much for the speedy reply, I’ll try that approach. -Alex

#98315
Mar 6, 2007 at 6:33pm

Actually you can do polygon stippling with jit.gl.lua. Here’s a patch
that takes a video and uses it to create a stippling pattern.

wes

——Stipple.mxb

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 341 126 66 196617 jit.rgb2luma;
#P flonum 540 52 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 540 73 42 196617 rate $1;
#P message 424 51 83 196617 read dishes.mov;
#P message 474 73 27 196617 stop;
#P message 440 73 31 196617 start;
#P flonum 383 52 35 9 0.5 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 341 52 15 0;
#P newex 341 72 52 196617 metro 30;
#P message 504 73 31 196617 clear;
#P newex 341 99 93 196617 jit.qt.movie 32 32;
#P newex 341 151 64 196617 prepend call;
#P newex 341 174 145 196617 jit.gl.lua test @file Stipple.lua;
#P toggle 126 54 15 0;
#P message 126 74 68 196617 fullscreen $1;
#N vpatcher 30 89 166 253;
#P window setfont “Sans Serif” 9.;
#P newex 50 71 35 196617 sel 27;
#P newex 50 50 40 196617 key;
#P outlet 50 93 15 0;
#P connect 1 0 2 0;
#P connect 2 0 0 0;
#P pop;
#P newobj 126 34 33 196617 p Esc;
#P newex 126 92 151 196617 jit.window test @depthbuffer 1;
#P message 87 92 34 196617 reset;
#P newex 87 113 186 196617 jit.gl.handle test @inherit_transform 1;
#P toggle 24 73 15 0;
#P newex 24 92 57 196617 qmetro 30;
#P newex 24 113 50 196617 t b erase;
#P newex 24 138 163 196617 jit.gl.render test @camera 0 0 10;
#P connect 12 0 22 0;
#P connect 3 0 2 0;
#P connect 2 0 1 0;
#P fasten 4 0 0 0 92 134 29 134;
#P fasten 1 1 0 0 69 134 29 134;
#P fasten 1 0 0 0 29 134 29 134;
#P connect 5 0 4 0;
#P connect 7 0 9 0;
#P connect 9 0 8 0;
#P connect 8 0 6 0;
#P connect 15 0 14 0;
#P fasten 20 0 12 0 545 94 346 94;
#P fasten 19 0 12 0 429 94 346 94;
#P fasten 18 0 12 0 479 94 346 94;
#P fasten 17 0 12 0 445 94 346 94;
#P fasten 13 0 12 0 509 94 346 94;
#P fasten 14 0 12 0 346 97 346 97;
#P connect 22 0 11 0;
#P connect 11 0 10 0;
#P connect 16 0 14 1;
#P connect 21 0 20 0;
#P window clipboard copycount 23;

————————–Stipple.lua

stippleMat = jit.matrix(1, “char”, 32, 32)

pattern = {}

for j=1, 32 do
pattern[j] = {}
for i=1, 32 do
pattern[j][i] = i*j/(32*32)*255
end
end

function jit_matrix(name)
stippleMat:frommatrix(name)

for i=1, 32 do
pattern[i] = stippleMat[i]
end
end

function draw()
gl.Color(1.0, 0.0, 0.0)
gl.Enable(“POLYGON_STIPPLE”)
gl.PolygonStipple(pattern)

gl.Begin(“POLYGON”)
gl.Vertex(-2.0, 5.0)
gl.Vertex(2.0, 5.0)
gl.Vertex(5.0, 2.0)
gl.Vertex(5.0, -2.0)
gl.Vertex(2.0, -5.0)
gl.Vertex(-2.0, -5.0)
gl.Vertex(-5.0, -2.0)
gl.Vertex(-5.0, 2.0)
gl.End()
end

#98316
Mar 6, 2007 at 7:03pm

BTW,
You can do the same thing as ploygon stippling with jit.gl.texture
@colormode lumalpha @dim 32 32 @rectangle 0 @wrap repeat. Plus you’ll
have more flexibility.

wes

#98317

You must be logged in to reply to this topic.