Open Gl Preview Window

Linden's icon

Hello

I've tried to figure out how to set up a preview window in Open Gl Context.
I wanna use a gl.handle in a preview window so that the mouse isn't visible in the main output window.
The examples which have been posted didn't work for me also the jitter recipe 39.
I am running windows 7. Could this be a problem in this case?
Kind regards

laserpilot's icon

Preview windows can be pretty tricky..I had to come to the forum to get help with mine. Try posting an example patch of what you've got so far and we can probably help you the rest of the way.

Linden's icon

Hello Laserpilot

Thx for the reply. I recognized that you've started a similar post. The exmple given in your thread didn't work for me. The preview pwindow remained white. maybe i am missing something?
i've attached my patch. it's messy and maybe some things don't make senes or can be done better. i am relatively new to jitter so there are many things to learn and explore for me.
basicly i wanna process a camera image and after some processing put it on a videoplane to achieve some more different effects.
so my preview window is right now the end of the videoprocessing chain. but i wanna be able to get a real preview, after the end of the 3d objects chain... and i also wanna use the handle in this preview window so that i can take control from it to the main output window? or is something like auto rotate possible without the handle?

i am working within max for live. so maybe there have to be made some modifications - for exmaple with the audio input.

i didnn't know how to paste my patch as text so i attached it

1159.gl_prev.maxpat
Max Patch
laserpilot's icon

Oof..that is quite an ugly patch..reminds me of my old days, but mine were worse :)

I got it working by cobbling together pieces from my patch

So here is what I did:

-Gave your gl.mesh a render name: finalrender

-Told gl.sketch to draw 'finalrender' (this is uneccessary i believe..but if you end up with multiple gl.mesh objects you can use this to draw them for you)

-added a second preview gl.render context that is shared with your original (see your render patcher) ..this captures the coloursexist as a texture and then puts it on it's own videoplane

-created a pwindow which is named 'coloursexistpreview' (name it with the inspector)...it will latch onto a videoplane that is named the same but it requires no bangs for output, it just works

-changed the context of the gl.handle to now be 'coloursexistpreview' so now you can use your mouse on the preview window only

i think that's it..took me about 5 minutes..less time than it took me initially, haha

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

also..in the future, to copy as text..you select everything and then in the 'edit' menu select 'copy compressed' and it will copy everything to your clipboard

Linden's icon

thank you very much for your time!
sorry for the ugly patch. in fact the original is much uglier and it was allready a "cleaned" version.
i ve looked at it and it was the same as with the examples i've allready tried: the preview screen doesn't show an image. are you on macintosh?
i have the suspect that these may be some windows issues? have tested it under win7 and xp and got the same problem.
at least i can now control the zoom and rotation from a seperate window!

what is the atribute capture for (gl sketch)? didn't find it in the reference...

Have cleaned it up even further so that others could also have maybe a more pleasent look...

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

Rob Ramirez's icon

hi, please check out the following basic example of creating an opengl preview window (as well as post-processing an opengl scene).

if this is not working for you, please provide all relevant computer specs (OS, GPU, max version).

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

if you have any questions about the technique, please ask:

Linden's icon

i've checked this example allready on two different computers. on both the preview pwindow remains white, after having pressed the dishes movie message and turned on the metro.
the max window says: Object (jit.gl.render): ob3d_draw_end_texture:GL Error:Invalid Opreation
i am running windows 7 64 bit with 8gig ram, m4live 5.1.5 and a geforce gt 230.

Rob Ramirez's icon

i will take a look on a windows machine when i get a chance.

Rob Ramirez's icon

i can reproduce this. thanks for the report.

in the meantime, you may be able to make it work by doing the following.
create an empty message box and put the following in it (without quotations but include the semi-colon).

"; jitter glreadback rtt"

Linden's icon

ok i don't understand why but it works now!
many thanks for your help!!

Ben Bracken's icon

In the next Max release, rtt mode will be default for Windows, as it already is for Mac.

In the meantime, we would love to get some feedback in regards to if this works for people's patches/graphics cards/drivers.

In order to have Max start up with rtt mode as the default glreadback, create a text document with the following:

jitter glreadback rtt;

Title it 'jitter-config.txt' and save it somewhere in Max's search path, though not in the 'init' folder. For example, I saved mine in Max 5.0/Cycling '74/.

If you do experience any problems, please send an email to support at cycling 74 dot com, with your system specs and a simple patch with steps to reproduce. It may be that with older cards/drivers, ctt will perform better, but with most modern harddware rtt is probably the way to go for now.

Thanks for playing along!

-Ben

Linden's icon

Hello again

I recognized that when i use a preview window in my render context and do some mesh transformation the edges get kind of distorted.
Also when you drag and resize the main render window with the mouse the preview window did react in a strange way.
Maybe i am using the gl handle in a wrong way?

Maybe i am doing something wrong with the rendering? For example i didn't get what the gl.slab is about, which was used in the example...

In my patch i made two render contextes one with the other without the preview window. hit the metro for mesh transformation.
you can switch to fullscreen with "esc" or "1" respectivly to see the difference. the one without the preview window has smoother edges in my setup at least...

here is the patch

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

pieter.coussement's icon

Hello,

I've been trying to get my head around this, but can't seem to work out how to get the result I want.

I've based my patch on OpenGL Preview Window wiki entry: https://cycling74.com/wiki/index.php?title=OpenGL_Preview_Window

Now the thing I want to do is to have a highQuality output of the geometry I make in my main window which will end up as a syphon texture to resolume.
I've figured out that I need a jit.window to get the disired dimensions of the texture (which is 3600x720), with eventually an attribute @visible 0

I also want a preview window which will be (720x 144) just to know what's going on.
Based on the wiki I've put in a node where I draw my geometry to, outputting a texture using @capture 1 that goes into a jit.gl.videoplane.
However the videoplane is in no way spreading over the whole area, since it is scaled at 1 1 1, rescaling it to 5 1 1 makes it stretch over the whole screen but completely disforms the texture. I get why it does that, but I have a texture that is 3600x720 in size and hi quality.

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

How can I use the 3600x720 texture on the mainwindow on something that displays the texture with high resolution without the videoplane being just a black square in the middle of the big screen?

Andro's icon

Videplane @transform reset 2 ?

pieter.coussement's icon

Hi Andro, thx for you're advice, unfortunately this doesn't help. I already set the attribute to 2

Rob Ramirez's icon

you need to set the dims that you want to capture your texture at in the jit.gl.node (@adapt 0 @dim 3600×720). your jit.window or preview window can then have independent dimensions to your render texture that gets sent to syphon.

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

you shouldn't need a separate preview window in this case.

pieter.coussement's icon

Thanks Rob for the explenation, I 've got one (hopefully) last question though. The texture that comes out of the jit.gl.node seems to be stretched when send via syphon.
When drawing directly to an example window that has the same aspect ratio this is different. I'm preparing something for a 3 projector setup and want to span 1 render engine via a matrox over 3 screens. The reason it needs to go through syphon is that the blend of the screens is done in resolume.

So basicly my question is how to mimic the behaviour of the jit.window example in a texture using jit.gl.node

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

Thanx in advance for having a look.

Rob Ramirez's icon

interesting!

so yeah, that's unexpected, but fortunately there's an easy solution. the problem is that the texture's fbo is setting up a viewport based on the window dimensions of the gl.render. in order to get it to set a proper viewport based on the dimensions of the gl.node, we must simply add a gl.camera to the gl.node sub-context.
so simply add a "jit.gl.camera subctx" to your patch, and you're good to go.

pieter.coussement's icon

thx, funny enough I already did this for completely non related reasosn though.
should I/we add this to the wiki on preview window or better yet at the sharing syphon textures?

Pieter

Rob Ramirez's icon