[osg-users] background color fills all the window (not only the given viewport)

Simon Hammett s.d.hammett at googlemail.com
Thu Mar 26 03:30:24 PDT 2009


Yes I know.

The magic is in the use of glAddSwapHintRectWIN which is a wgl function.

I've just tested this and it works, so you can update part of the window using
plain GDI calls and do the rest with opengl.

Mind you I wouldn't trust it work on all machines.
It's probably less of head ache to just use separate windows...

2009/3/26 Robert Osfield <robert.osfield at gmail.com>:
> HI Simon,
>
> I'm afraid the OSG already uses the sissor test to make sure that the
> viewport clear only affects the region of interest.  It work, but the
> problem Fredric has really all about the fact that the OpenGL context
> affects the whole window it's assigned to.
>
> Robert.
>
> On Thu, Mar 26, 2009 at 8:59 AM, Simon Hammett <s.d.hammett at googlemail.com>
> wrote:
>>
>> This might be want you are looking for:
>>
>> http://factor-language.blogspot.com/2007_08_01_archive.html
>>
>> and
>>
>>
>> http://factor-language.blogspot.com/2007/08/opengl-redraw-bug-on-windows.html
>>
>> Basically enable the scissor test, then tell OpenGl what part of the
>> window to update when calling SwapBuffers.
>>
>> Not tried it myself though.
>>
>> 2009/3/26 Guy <guy at dvp.co.il>:
>> > Frederic,
>> >  I think you can't limit the OpenGL drawing to a limited region of a
>> > window HANDLE. You could embed a window in the region you want to use OGL,
>> > and just draw to it. Or you could first draw the OGL/OSG code, and then get
>> > the window handle and draw all your other stuff using GDI or whatever.
>> >
>> > Guy.
>> >
>> > ---------
>> >
>> >
>> > hum, the (black) color was not the problem in itself :)
>> >
>> > If I do this (update from my whole code):
>> >        gc->setClearColor( osg::Vec4f(1.2f, 0.2f, 0.6f, 1.0f) );
>> >        gc->setClearMask( 0) ;
>> >
>> >        camera->setClearColor( osg::Vec4f(0.2f, 0.2f, 1.6f, 1.0f) );
>> >        camera->setClearMask( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT
>> > );
>> > (that's to say: don't clear anything on gc, and fill background with
>> > blue on camera),
>> >
>> > I have the camera successfully drawn at the right place, with blue
>> > background. This is what I want for that camera.
>> > BUT, the problem persists, i.e. all around the viewport, the whole
>> > window is painted in black. (maybe mick jagger is singing too loud ?).
>> > it is painted in pink if I enable the
>> > gc->setClearMask(GL_COLOR_BUFFER_BIT).
>> >
>> > I can't manage to make OSG only impact the camera viewport (my blue
>> > rectangle) and leave the window around unchanged...
>> > Did anyone achieve to display an osgViewer::Viewer at some small place
>> > in a window without overwrite window content around?
>> >
>> > Fred
>> >
>> >
>> >
>> > 2009/3/25 Robert Osfield <robert.osfield at gmail.com>:
>> >> On Wed, Mar 25, 2009 at 3:03 PM, Frederic Marmond <fmarmond at gmail.com>
>> >> wrote:
>> >>>
>> >>> hum, it didn't work :(
>> >>>
>> >>> both
>> >>> //      gc->setClearColor( osg::Vec4f(1.2f, 0.2f, 0.6f, 1.0f) );
>> >>> //      gc->setClearMask( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
>> >>> and
>> >>>        gc->setClearColor( osg::Vec4f(1.2f, 0.2f, 0.6f, 1.0f) );
>> >>>        gc->setClearMask( 0 );
>> >>>
>> >>> do the same: instead of the shiny pink color, the window is filled
>> >>> with
>> >>> black
>> >>>
>> >>> any other suggestion ?
>> >>
>> >> Well you disable the clear colour in the camera's ClearMask so perhaps
>> >> this
>> >> is why it's just black.
>> >>
>> >> Robert.
>> >>
>> >> _______________________________________________
>> >> osg-users mailing list
>> >> osg-users at lists.openscenegraph.org
>> >>
>> >> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>> >>
>> >>
>> > _______________________________________________
>> > osg-users mailing list
>> > osg-users at lists.openscenegraph.org
>> >
>> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>> > _______________________________________________
>> > osg-users mailing list
>> > osg-users at lists.openscenegraph.org
>> >
>> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>> >
>>
>>
>>
>> --
>> http://www.ssTk.co.uk
>> _______________________________________________
>> osg-users mailing list
>> osg-users at lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>



-- 
http://www.ssTk.co.uk



More information about the osg-users mailing list