[Flightgear-devel] osg problem: render to image
Hi! Since people keep saying that OSG is easy, I thought I'd ask here before I go over to the OSG list. I have modified the osgdistortion example so that it uses an intermediate image instead of directly rendering to the texture. I did this to simulate my problem with rendering to an image. Here is the relevant part (front face in setDomeCorrection): osg::ref_ptr traits2 = new osg::GraphicsContext::Traits; traits2->width = camera_width; traits2->height = camera_height; traits2->pbuffer = true; osg::ref_ptr gc2 = osg::GraphicsContext::createGraphicsContext(traits2.get()); // gc2->realize(); osg::ref_ptr camera = new osg::Camera; camera->setName("Front face camera"); camera->setGraphicsContext(gc2.get()); camera->setViewport(new osg::Viewport(0,0,camera_width, camera_height)); camera->setAllowEventFocus(false); // tell the camera to use OpenGL frame buffer object where supported. camera->setRenderTargetImplementation(renderTargetImplementation); // attach the texture and use it as the color buffer. osg::ref_ptr image = new osg::Image; image->allocateImage(camera_width, camera_height, 1, GL_RGB, GL_UNSIGNED_BYTE); camera->attach(osg::Camera::COLOR_BUFFER, image.get()); This works as expected. Note however, that I have not called realize() on the gc. If I do, I get errors: Warning: GraphicsWindow not realized, cannot do makeCurrent. Error: In Texture::Extensions::setupGLExtensions(..) OpenGL version test failed, requires valid graphics context. Now, if I put the code into flightgear, I get the above errors if I _don't_ call realize()! That is, just the opposite behavior. But even if I call realize(), in the post-draw callback my image only contains the background color. Furthermore, if I try to call setDrawBuffer(GL_FRONT) or setReadBuffer(GL_FRONT), I get: before Font::Glyph::subload(): detected OpenGL error 'invalid enumerant Warning: detected OpenGL error 'invalid enumerant' after RenderBin::draw(,) (and lot more follow, I guess one per frame) The only way I got it to work was to not call attach(), add a FinalDrawCallback and use readPixels(). I guess this is suboptimal in terms of performance and I am puzzled anyway. Any ideas what could cause such behavior? Also, even though I have multiple cameras and multiple graphics contexts, I could not see any multi-threading no matter how I set /sim/rendering/multithreading-mode (it does show up on the stats screen properly, though). I have attached the patches and the config file I use. Run as: $ mkfifo /tmp/fg-snapshot $ mplayer -demuxer rawvideo -rawvideo format=rgb24:w=480:h=300 -vf flip /tmp/fg-snapshot (in another shell) $ fgfs --config=camera.xml Then, set /sim/video=1 to start streaming. Ideally, you should see your fg view (minus gui elements) playing in the mplayer window. You can select the attach vs. readPixels implementation by changing the ATTACH define in the source. -- Thanks, Csaba/Jester Index: osgdistortion.cpp === --- osgdistortion.cpp (revision 9007) +++ osgdistortion.cpp (working copy) @@ -444,6 +444,30 @@ return geometry; } +struct MyCameraPostDrawCallback : public osg::Camera::DrawCallback +{ +MyCameraPostDrawCallback(Image* image) : _f(0), _image(image) {}; +~MyCameraPostDrawCallback() +{ + if (_f) + { + fclose(_f); + _f = 0; + } +} + +virtual void operator () (const osg::Camera& camera) const +{ + if (!_f) _f = fopen("/tmp/fg-snapshot", "wb"); + fwrite(_image->data(), _image->getTotalSizeInBytes(), 1, _f); + fflush(_f); +} + +private: + mutable FILE* _f; + ref_ptr _image; +}; + void setDomeCorrection(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments) { @@ -501,18 +525,26 @@ // front face { -osg::ref_ptr camera = new osg::Camera; +osg::ref_ptr traits2 = new osg::GraphicsContext::Traits; +traits2->width = camera_width; +traits2->height = camera_height; +traits2->pbuffer = true; +osg::ref_ptr gc2 = osg::GraphicsContext::createGraphicsContext(traits2.get()); +// gc2->realize(); +osg::ref_ptr camera = new osg::Camera; camera->setName("Front face camera"); -camera->setGraphicsContext(gc.get()); +camera->setGraphicsContext(gc2.get()); camera->setViewport(new osg::Viewport(0,0,camera_width, camera_height)); -camera->setDrawBuffer(buffer); -camera->setReadBuffer(buffer); camera->setAllowEventFocus(false); // tell the camera to use OpenGL frame buffer object where supported. camera->setRenderTargetImplementation(renderTargetImplementation); // attach the texture and use it as the color buffer. -camera->attach(osg::Camera::COLOR_BUFFER, texture, 0, osg::TextureCubeMap::POSITIVE_Y); +osg::ref_ptr image = n
Re: [Flightgear-devel] osg problem
hi, another problem with osg. i fly since KSFO with the AWACS and all views became black screen (i only show the popup widget with view name and the FPS) only one view not became black screen : the airport view, but ... take a look yourself regards -- Didier Fabert [EMAIL PROTECTED] KFreeFlight project : A FlightGear GUI-Frontend designed for KDE users http://kfreeflight.sourceforge.net <> - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel
Re: [Flightgear-devel] osg problem
Le jeudi 9 novembre 2006 01:25, Georg Vollnhals a écrit : > Hi Didier, > I tested Charles de Gaulle and Orly now with the *lastest* OSG *CVS* > compile from this evening and with Mathias latest patch (see list). > You are right in one point - loading needs a lot of time, many > minutes, one could thing that the program "stucks", you see a lot of > hd-activities on your pc. But with patience I could fly from both > airports with *partially* very bad framerates, I think due to the many > objects and the development state of the OSG version. There are also > some small scenery display artifacts. When the objects are loaded, > flying with the Cessna (low speed) goes pretty fine until you come into > another region and objects are loaded from the hd, then the framerate > goes down. > Nightlighting does not work, but I will look tomorrow whether I have the > complete "original" scenery from the "helijah" site also installed in > the OSG branch. It should be but I am irritated because I could not see > any aircraft at Orly what I have in the PLIB version. > Regards > Georg first thank to interest of my problem, you're right, after five minutes, the bo105 ist at LFPO. the framerate is 15-25. a little bit, and it's completely flyable. (35-40 with plib here) i saw a problem : some buidings are with day texture, and other with night texture. i'm landing onto Paris center and, with the external view, i rotate around the aircraft. the sun position is not fixed at the same time, left side of aircraft is on shadow, with another camera position, it's the right side. that can explain why some building are day textured, and some others night textured regards -- Didier Fabert [EMAIL PROTECTED] KFreeFlight project : A FlightGear GUI-Frontend designed for KDE users http://kfreeflight.sourceforge.net <> - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel
Re: [Flightgear-devel] osg problem
Didier Fabert schrieb: > > 2 - i cannot take of from a Paris airport (i add helijah Paris scenery). the > launch block (loading scenery). this scenery is a lot of Paris building. > > thanks in advance > Hi Didier, I tested Charles de Gaulle and Orly now with the *lastest* OSG *CVS* compile from this evening and with Mathias latest patch (see list). You are right in one point - loading needs a lot of time, many minutes, one could thing that the program "stucks", you see a lot of hd-activities on your pc. But with patience I could fly from both airports with *partially* very bad framerates, I think due to the many objects and the development state of the OSG version. There are also some small scenery display artifacts. When the objects are loaded, flying with the Cessna (low speed) goes pretty fine until you come into another region and objects are loaded from the hd, then the framerate goes down. Nightlighting does not work, but I will look tomorrow whether I have the complete "original" scenery from the "helijah" site also installed in the OSG branch. It should be but I am irritated because I could not see any aircraft at Orly what I have in the PLIB version. Regards Georg - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel
Re: [Flightgear-devel] osg problem
Didier Fabert wrote: > 1 - is plib removing from dependencies ? (for now). it's clear that it's the > way. PLIB is still required for keyboard, mouse, joystick and I might forgotten something, Martin. -- Unix _IS_ user friendly - it's just selective about who its friends are ! -- - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel
[Flightgear-devel] osg problem
Le mercredi 8 novembre 2006 21:58, Mathias Fröhlich a écrit : > Hi, > I have placed a new set of openscenegraph packages at > ftp://ftp.uni-duisburg.de/FlightGear/Misc_maf/OpenSceneGraph-20061108 > That one contains an updated ac3d loader and the current osg cvs' rgb > loader. That means that the required rgb loader is in osg's cvs. >Greetings > Mathias hi, just few questions about osg 1 - is plib removing from dependencies ? (for now). it's clear that it's the way. if yes, how force fgfs compilation to not link to it ? if not what plib version must be installed (1.8.4 release, svn, etc...), and what version doen't make a running executable? 2 - i cannot take of from a Paris airport (i add helijah Paris scenery). the launch block (loading scenery). this scenery is a lot of Paris building. thanks in advance -- Didier Fabert [EMAIL PROTECTED] KFreeFlight project : A FlightGear GUI-Frontend designed for KDE users http://kfreeflight.sourceforge.net - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel