Forums > Jitter

captured texture from GL render to shared context on windows

June 15, 2011 | 1:18 am

I am struggling to find a cross-platform solution for capturing a GL scene as a texture and use this in a shared context for preview purposes.
Basically I am using the technique described by Wes Smith, using copy_texture and shared_context:

http://cycling74.com/forums/topic.php?id=8936

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 326 146 34 196617 reset;
#P newex 29 291 232 196617 jit.window mixprev @size 320 240 @pos 10 400;
#P newex 321 166 185 196617 jit.gl.handle mix @inherit_transform 1;
#P number 310 121 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 265 138 55 196617 qmetro 33;
#P newex 265 156 50 196617 t b erase;
#P newex 265 189 370 196617 jit.gl.render mix @ortho 2 @shared_context
mixprev @copy_texture mixwatch;
#P toggle 104 153 15 0;
#P message 104 171 45 196617 sync $1;
#P toggle 31 152 15 0;
#P newex 31 128 35 196617 sel 27;
#P message 31 170 68 196617 fullscreen $1;
#P newex 30 192 221 196617 jit.window mix @size 320 240 @depthbuffer 1;
#P newex 31 104 40 196617 key;
#P comment 287 102 77 196617 render main;
#P newex 263 305 106 196617 jit.gl.render mixprev;
#P newex 263 282 50 196617 t b erase;
#P newex 263 259 57 196617 qmetro 30;
#P newex 262 357 311 196617 jit.gl.videoplane mixprev @texture
mixwatch @transform_reset 2;
#P newex 262 338 191 196617 jit.gl.texture mixprev @name mixwatch;
#P toggle 263 230 20 0;
#P toggle 265 99 19 0;
#P window linecount 2;
#P newex 668 126 225 196617 jit.gl.gridshape mix @shape torus @color
0.8 0.1 0.1 0.8 @lighting_enable 1 @blend_enable 1;
#P window linecount 1;
#P comment 288 232 77 196617 render preview;
#P connect 23 0 21 0;
#P fasten 12 0 11 0 36 187 35 187;
#P fasten 15 0 11 0 109 187 35 187;
#P fasten 10 0 13 0 36 121 36 121;
#P fasten 13 0 14 0 36 142 36 142;
#P connect 14 0 12 0;
#P connect 16 0 15 0;
#P connect 3 0 6 0;
#P connect 6 0 7 0;
#P connect 7 0 8 0;
#P connect 7 1 8 0;
#P connect 2 0 19 0;
#P connect 19 0 18 0;
#P connect 21 0 17 0;
#P connect 18 0 17 0;
#P connect 18 1 17 0;
#P connect 20 0 19 1;
#P window clipboard copycount 24;

This works fine on mac, but does not work when I try it in windows xp. If I go to fullscreen the preview doesn´t work anymore.

The only example using shared_context that works in full screen on windows for me is the jitter recipe nr 39 by Andrew Benson, but his example captures individual GL objects, not the render output.

So, is there a secret way of combining capturing GL render output to texture with shared_context that works in windows?


June 15, 2011 | 12:06 pm

I’ve tried your patch on Windows 7 64 bit (Max 5.1.8) and the same thing happens to me: whenever I go fullscreen it stops working. I’ve found that it’s not only fullscreen, if you change the floating attribute the same thing happens. Even if you resize the main window (mix) it stops working.

In order to be certain that the problem is not with fullscreen itself, I’ve changed your patch a little: I’ve put the main window to my 2nd monitor in fullscreen automatically using "jit.window mix @size 320 240 @pos 1930 10 @depthbuffer 1 @fullscreen 1" so it initializes that way and it’s working fine.

So I guess the problem is whenever the main window (or perhaps rendering context?) needs to re-initialize, the shared_context is lost.

– Pasted Max Patch, click to expand. –

June 15, 2011 | 12:23 pm

Hi,
thanks for trying this out. I need to be able to switch fullscreen on and off.
I guess what I am looking for is a consistent method on windows for re-initializing the rendering context.
In my finished patch on mac osX I don´t need to do this when going fullscreen, but when I switch between floating and normal window I send the shared_context and copy_texture commands to my renderer, but this doesnt do anything on windows.


June 15, 2011 | 3:55 pm

I had issues with something similar back before Max 5, and my solution was to trick Jitter into rebuilding the context and its attached drawables by sending ‘drawto xxxx’ messages to the associated jit.gl.renderers. Id specify a named CPU matrix "dummy" or some such as a temporary destination, then change it back to the window, forcing a rebuild.

Perhaps prior to going fullscreen, switch the rendering destination to a matrix for all of your targets, then switch it back once full screen. Same for when leaving full screen. Worth a shot. Also be sure to change the shared_context and copy_texture destinations, so things all update to logical destinations.


June 17, 2011 | 12:27 pm

I think I have tried every possible combination now, without success.


June 17, 2011 | 11:37 pm

Let´s hope to hear from Cycling if there’s some sort of attribute missing, a correct order to initialize the objects, or any other workaround…


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