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" <[email protected]>:
> 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
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org