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 ?
Fred
2009/3/25 Robert Osfield <[email protected]>:
> Hi Fred,
>
> Ahh you're code tells the story... You are enabling the graphics window
> clear by the line:
>
> gc->setClearMask( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
>
> Just leave this in it's default value of 0 and it won't clear, the only
> clear that will happen is the camera's viewport clear.
>
> Robert.
>
> On Wed, Mar 25, 2009 at 2:44 PM, Frederic Marmond <[email protected]>
> wrote:
>>
>> thanks Robert,
>>
>> I already did it (here is my test code):
>>
>> RECT rect;
>> GetWindowRect(hwnd,&rect);
>>
>> // Set window traits and gc
>> m_Traits = new osg::GraphicsContext::Traits;
>>
>> osg::ref_ptr<osg::Referenced> windata = new
>> osgViewer::GraphicsWindowWin32::WindowData( hwnd );
>> m_Traits->width = 100; //rect.right - rect.left - m_Traits->x;
>> m_Traits->height = 100; //rect.bottom - rect.top - m_Traits->y;
>> m_Traits->x = 0;
>> m_Traits->y = rect.bottom - 0 - m_Traits->height;
>>
>> m_Traits->windowDecoration = false;
>> m_Traits->doubleBuffer = true;
>> m_Traits->sharedContext = 0;
>> m_Traits->setInheritedWindowPixelFormat = false;
>> m_Traits->inheritedWindowData = windata;
>> osg::GraphicsContext* gc =
>> osg::GraphicsContext::createGraphicsContext( m_Traits.get() );
>> gc->setClearColor( osg::Vec4f(1.2f, 0.2f, 0.6f, 1.0f) );
>> gc->setClearMask( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
>>
>> // Create camera
>> osg::ref_ptr<osg::Camera> camera = new osg::Camera;
>> camera->setGraphicsContext(gc);
>> camera->setViewport( new osg::Viewport(m_Traits->x, m_Traits->y,
>> m_Traits->width, m_Traits->height) );
>> camera->setProjectionMatrixAsPerspective( 30.0f,
>> (double)m_Traits->width/(double)m_Traits->height, 1.0f, 10000.0f );
>> camera->setClearMask( GL_DEPTH_BUFFER_BIT );
>>
>> // Create viewer
>> m_Viewer = new osgViewer::Viewer;
>> m_Viewer->setThreadingModel( osgViewer::Viewer::SingleThreaded );
>> m_Viewer->setCamera( camera.get() );
>> m_Viewer->setCameraManipulator( new osgGA::TrackballManipulator );
>>
>> // Set root node of the scene
>> m_Viewer->setSceneData(osgDB::readNodeFile("D:\\Program
>> Files\\OpenSceneGraph-2.8.0\\cessna.osg"));
>> m_Viewer->realize();
>>
>> // Create a thread for the simulation loop
>> _beginthread(&RenderThread, 0, m_Viewer);
>>
>>
>>
>>
>> the camera displays at the right place, right size (0,0,100,100 : top
>> left corner). But all other window part is filled with background
>> color.
>>
>> I'm in an activeX, I took part of the code of osgActiveX, but I can't
>> use MFC in my case.
>> The only notable difference between osgActiveX and my code, is that he
>> was using GetSafeHwnd(), and I use (for now) GetForegroundWindow() for
>> hwnd.
>> As I come from the Linux world, I'm not used to windows subtilities,
>> and I may be wrong doing this ?
>> Is there something wrong in that code, or something elsewhere I may
>> looking at ?
>>
>> best regards
>> Fred
>>
>>
>>
>> 2009/3/25 Robert Osfield <[email protected]>:
>> > Hi Fred,
>> >
>> > Just set the Camera's viewport so it only covers the part you want to
>> > render
>> > to.
>> >
>> > Robert.
>> >
>> > On Wed, Mar 25, 2009 at 2:06 PM, Frederic Marmond <[email protected]>
>> > wrote:
>> >>
>> >> hello world,
>> >>
>> >> on a win32 project, I would like to display an osg Viewer in a part of
>> >> the window.
>> >> I set my osg::GraphicsContext::Traits with coords I want, set the
>> >> inheritedWindowData with osgViewer::GraphicsWindowWin32::WindowData(
>> >> hwnd )
>> >>
>> >> my model is well placed and displayed (in the area I wanted), but the
>> >> entire window is filled with background color.
>> >> Is there any way to avoid this? any suggestion ?
>> >>
>> >> thanks in advance
>> >>
>> >> Fred
>> >> _______________________________________________
>> >> 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
>> >
>> >
>> _______________________________________________
>> 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
>
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org