Re: [osg-users] GL_STENCIL_TEST in draw implementation callback

2012-03-17 Thread Sergey Polischuk
afaik there are implementation dependent restrictions on viewport size, you may 
hitting those limits

16.03.2012, 19:14, Doug Domke doug.do...@boeing.com:
 UGH!  I just found that I was mistaken about the video growing properly 
 without the stencil.  It actually doesn't.  Once its viewport exceeds a 
 certain size, it no longer renders as expected.  I think I've come as far as 
 I can here.

 Thanks anyway.
 Doug

 --
 Read this topic online here:
 http://forum.openscenegraph.org/viewtopic.php?p=46353#46353

 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] GL_STENCIL_TEST in draw implementation callback

2012-03-16 Thread Doug Domke
Clearing the modelview and projection matrices helped a great deal.  Thanks 
hybr!  It now works as intended ... up to a point that is difficult to explain.

I get the digital zoom effect until about 13x.  At that point, the video 
suddenly starts translating instead of zooming.  And instead of showing video 
that is off-center (which would still be confusing and wrong to me since there 
is nothing that is doing a translation), the video is still clipped such that 
inside my stencil quad I see a repeat of other items in the application (I get 
buttons and such drawing in my video quad).

If I disable the GL_STENCIL_TEST now, the video viewport grows exactly as 
expected.  At some point, it does grow beyond the size of my application 
window.  Perhaps this is a problem for the stencil for some reason?  Can anyone 
provide additional insight for me?

Thanks again!
Doug

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=46349#46349





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] GL_STENCIL_TEST in draw implementation callback

2012-03-16 Thread Doug Domke
UGH!  I just found that I was mistaken about the video growing properly without 
the stencil.  It actually doesn't.  Once its viewport exceeds a certain size, 
it no longer renders as expected.  I think I've come as far as I can here.

Thanks anyway.
Doug

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=46353#46353





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] GL_STENCIL_TEST in draw implementation callback

2012-03-15 Thread Doug Domke
Hi,

We have an OSG-based application that uses a 3rd party library to draw video.  
We want my application to perform a digital zoom on this video.  Given the 
API to this library, we wrote an OSG node with a draw callback that calculates 
the viewport for the video to draw in, and lets the library do its magic.

My theory for the digital zoom feature is to give the library a larger 
viewport (it always draws the same scene into the viewport) and 
cull/clip/stencil the result.  My current attempt is in using a glStencil in 
the draw callback as follows:


Code:
glEnable(GL_STENCIL_TEST);
glClear(GL_STENCIL_BUFFER_BIT);
glStencilFunc(GL_ALWAYS, 1, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
glBegin(GL_QUADS);
glVertex2d(left, bottom);
glVertex2d(left, top);
glVertex2d(right, top);
glVertex2d(right, bottom);
glEnd();
glStencilFunc(GL_EQUAL, 1, 1);
draw video
glDisable(GL_STENCIL_TEST);



Unfortunately, the video ends up disappearing entirely.  If I remove the 
Code:
glEnable(GL_STENCIL_TEST); 

 line, the video draws in the larger viewport and overlaps areas that it 
shouldn't.

Can anyone identify a flaw in my code?  Is there another approach that may be 
better?

Thank you!
-Doug[/code]

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=46318#46318





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] GL_STENCIL_TEST in draw implementation callback

2012-03-15 Thread Sergey Polischuk
Hi

Are you sure your quad not being rejected by depth test? Also as it being drawn 
with fixed finction, modelview and projection matrices set by osg for opengl 
state are affecting your quad drawing.
So easy\dirty way is to attach shader which calc vertex position without using 
gl_ModelViewMatrix and gl_ProjectionMatrix, and disable GL_DEPTH_TEST when quad 
is drawn if needed.

You can avoid most of pure opengl code, if you will use 
osg::Projection(set to whatever projection your quad needs to be)-
  osg::MatrixTransform(set to identity and with ABSOLUTE_RF reference frame)-
 osg::ClearNode(set up to clear stencil buffer)-
   Geode containing your quad with correct osg::Stencil stuff setup in 
stateset.
You can skip projection and matrixtransform if you use shader mentioned above.
Then you add drawCallback to your quad, where you call
quad's default drawImplementation()
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_EQUAL, 1, 1);
draw video
glDisable(GL_STENCIL_TEST);

16.03.2012, 00:01, Doug Domke doug.do...@boeing.com:
 Hi,

 We have an OSG-based application that uses a 3rd party library to draw video. 
  We want my application to perform a digital zoom on this video.  Given the 
 API to this library, we wrote an OSG node with a draw callback that 
 calculates the viewport for the video to draw in, and lets the library do its 
 magic.

 My theory for the digital zoom feature is to give the library a larger 
 viewport (it always draws the same scene into the viewport) and 
 cull/clip/stencil the result.  My current attempt is in using a glStencil in 
 the draw callback as follows:

 Code:
 glEnable(GL_STENCIL_TEST);
 glClear(GL_STENCIL_BUFFER_BIT);
 glStencilFunc(GL_ALWAYS, 1, 1);
 glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
 glBegin(GL_QUADS);
 glVertex2d(left, bottom);
 glVertex2d(left, top);
 glVertex2d(right, top);
 glVertex2d(right, bottom);
 glEnd();
 glStencilFunc(GL_EQUAL, 1, 1);
 draw video
 glDisable(GL_STENCIL_TEST);

 Unfortunately, the video ends up disappearing entirely.  If I remove the
 Code:
 glEnable(GL_STENCIL_TEST);

  line, the video draws in the larger viewport and overlaps areas that it 
 shouldn't.

 Can anyone identify a flaw in my code?  Is there another approach that may be 
 better?

 Thank you!
 -Doug[/code]

 --
 Read this topic online here:
 http://forum.openscenegraph.org/viewtopic.php?p=46318#46318

 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] GL_STENCIL_TEST in draw implementation callback

2012-03-15 Thread Farshid Lashkari
Hi Doug,

How exactly is this library drawing the video? Is it feeding the video data
into a texture, and applying that texture onto a simple quad? If so, it
seems like the best approach would be to use the osg::TexMat class to
transform the texture coordinates of the quad to simulate a zooming in
effect. Either way, it's difficult to say what is going wrong without
knowing more about how this library works.

Cheers,
Farshid

On Thu, Mar 15, 2012 at 1:01 PM, Doug Domke doug.do...@boeing.com wrote:

 Hi,

 We have an OSG-based application that uses a 3rd party library to draw
 video.  We want my application to perform a digital zoom on this video.
  Given the API to this library, we wrote an OSG node with a draw callback
 that calculates the viewport for the video to draw in, and lets the library
 do its magic.

 My theory for the digital zoom feature is to give the library a larger
 viewport (it always draws the same scene into the viewport) and
 cull/clip/stencil the result.  My current attempt is in using a glStencil
 in the draw callback as follows:


 Code:
 glEnable(GL_STENCIL_TEST);
 glClear(GL_STENCIL_BUFFER_BIT);
 glStencilFunc(GL_ALWAYS, 1, 1);
 glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
 glBegin(GL_QUADS);
 glVertex2d(left, bottom);
 glVertex2d(left, top);
 glVertex2d(right, top);
 glVertex2d(right, bottom);
 glEnd();
 glStencilFunc(GL_EQUAL, 1, 1);
 draw video
 glDisable(GL_STENCIL_TEST);



 Unfortunately, the video ends up disappearing entirely.  If I remove the
 Code:
 glEnable(GL_STENCIL_TEST);

  line, the video draws in the larger viewport and overlaps areas that it
 shouldn't.

 Can anyone identify a flaw in my code?  Is there another approach that may
 be better?

 Thank you!
 -Doug[/code]

 --
 Read this topic online here:
 http://forum.openscenegraph.org/viewtopic.php?p=46318#46318





 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org