HI Aitor,

It sounds like you are trying to do an OpenGL call without a context
current.  Using makeCurrent sound solve this.

Personally I find the approach of stick OpenGL calls directly in a
main thread not idea.  It's not flexible and make assumptions that
will easily be broken by small changes in code elsewhere.  I would
recommend using a RealizeOperation, this will get called for each
context on your viewer when they get realized, this approach works
just fine with multiple context and threading.

Robert.

On Tue, Nov 2, 2010 at 8:45 AM, Aitor Ardanza <[email protected]> wrote:
> Hi,
>
> I've been reading similar problems, but I have not Found the solution ... the 
> viewer is set in singlethreaded, and I added the GraphicsContext at the 
> camera properly ...
>
>
>
> Code:
> // construct the viewer.
> int width = 800;
> int height = 600;
> osgViewer::Viewer viewer;
> viewer.addEventHandler(keh);
> viewer.setCameraManipulator(new osgGA::TrackballManipulator());
> viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded);
> int xoffset = 40;
> int yoffset = 40;
> osg::ref_ptr<osg::GraphicsContext::Traits> traits = new 
> osg::GraphicsContext::Traits;
> traits->x = xoffset + 0;
> traits->y = yoffset + 0;
> traits->width = 600;
> traits->height = 480;
> traits->windowDecoration = true;
> traits->doubleBuffer = true;
> traits->sharedContext = 0;
>
> osg::ref_ptr<osg::GraphicsContext> gc = 
> osg::GraphicsContext::createGraphicsContext(traits.get());
> osg::ref_ptr<osg::Camera> camera = new osg::Camera;
> camera->setGraphicsContext(gc.get());
> camera->setViewport(new osg::Viewport(0,0, traits->width, traits->height));
> GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
> camera->setDrawBuffer(buffer);
> camera->setReadBuffer(buffer);
>
> // add this slave camera to the viewer, with a shift left of the projection 
> matrix
> viewer.setCamera(camera.get());
>
> viewer.setSceneData(scene);
> viewer.realize();
>
> const char* vendorString = reinterpret_cast<const 
> char*>(glGetString(GL_VENDOR)); //return NULL
>
>
>
> Why I can't access the graphics card info?
>
> Thank you!
>
> Cheers,
> Aitor
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=33289#33289
>
>
>
>
>
> _______________________________________________
> 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

Reply via email to