[osg-users] Composite Viewer issue with QT
Hi, I'm working on a QT application that has several views / viewports onto a scene (different perspectives and projections). One of these needs to have a transparent QT HUD. I've spent a lot of time going over examples and archive posts, and it seems to me that the most up-to-date way to do this is to render the QT Hud onto a QGraphicsScene attached to a QGraphicsView, and to set the Viewport of the QGraphicsView to be the osg GLWidget. This is how QT supports using generic GL Widget rendering as the background of a QGraphicsView (the QT Boxes demo is a good example). However, I'm running into a couple of problems that are preventing me from fully realizing the goals of my application. The main points that I need to hit: 1. Composite Viewer managing multiple views 2. (At least) One of the views needs to support a QGraphicsScene HUD. (1) is easy - the osgViewerQt example covers it pretty simply, and modifying that to use a QGraphicsView with the viewport set to the GL widget rather than adding the GLWidget to the layout directly worked just fine. I was able to get (2) working for a single view without too much additional difficulty. However, when I add more views to the compositeViewer after the first with the HUD, I start to get rendering errors. The console spits out Warning: detected OpenGL error 'invalid value' at after RenderBin::draw(..) over and over, and it appears that all of the views are rendering to the same viewport. I think it has something to do with the context not switching properly, because frame() gets called from within the QGraphicsScene's drawBackground() method. I thought to try to subclass the compositeViewer and override frame() to allow you to call it seperately for each view attached to the viewer, but that's a pretty serious undertaking and I'm not even sure it is going to address my problem. Cheers, Nick -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=61202#61202 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgViewerQT example question
I'm using the new version, under Linux (although I will eventually be testing under windows as well, I need it to work on Ubuntu first). Like I mentioned, I am trying to extend the example to fit into the QGraphicsView approach. Based on various guides and discussions that I have found, this involves setting the GLWidget as the viewport of the QGraphicsView. In theory, this should let me use the OSG View as the background of the widget, and place QGraphicsItems in a QGraphicsScene that will appear on top of it. I can get this to work using the osgViewer::Viewer, for a single window, but when I try the same approach with a CompositeViewer and multiple windows, I get a variety of errors. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=61146#61146 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgViewerQT example question
I've made a couple of attempts, and I feel like I am very close... On one attempt, using a seperate osgViewer for each View, everything works but the Database Pager isn't happy about having multiple viewers looking at the same data. (osgEarth data under PagedLOD nodes flickers in and out of the various levels of detail) On another attempt, using a composite viewer, everything works as I would expect it to if I only have one view, and I am able to add QGraphicsItems to the scene, but if I attempt to add a second View, they get rendered to the same viewport, fighting over it, spit out a bunch of detected invalid value after renderBin draw errors, then crashes. On another attempt, having multiple views works fine, until I add a QGraphicsScene to the graphicsView. The items in the QGraphicsScene will render, but the osg view will not, sending Cannot make context current errors to the console. Across these three failure modes is the set of features I need working; I just need to find the proper way to mesh them together -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=61152#61152 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] osgViewerQT example question
Hi, I'm looking at extending the osgViewerQT example by being able to add items to the QGraphicsView (by setting a QGraphicsScene and adding items to that). These items include some QT controls that need to be embedded in the window with transparency enabled. When I simply create the scene and add the controls (using a GraphicsProxyWidget), the view begins flickering black and white and the log prints QGLContext::makeCurrent(): Failed. over and over. It seems like QT and OSG are fighting over the context. I've heard that you can get around this by subclassing the QGraphicsScene and doing your OSG rendering in the drawBackground() method, storing and retrieving the context before/after, but I'm not exactly sure what that means - calling frame() there? Thank you! Cheers, Nick -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=61113#61113 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] QT and OSG openGL issues
Hi, I'm currently walking down the oft-treaded path of creating Qt Widget overlays on top of an OSG scene. I've been doing a lot of reading and searching over the archives, and it seems like there are 2 main approaches. Eveything I can find on the topic is 3-5 years old, however, so I was wondering if I'd missed anything. The first approach is to use osgQT::QWidgetImage to render the QWidgets to a texture and display that within the OSG scene. I've gotten that working, with a little bit of sub-classing to make a full-screen ortho projection work to create a HUD and to handle events properly. There is a bit of wonkiness to it though so I also want to try... The second approach: to use a QGraphicsScene and to do the osg rendering in the drawBackground method. I'm currently trying to get this approach to work, but running into some issues. I've gathered, from the archives, that I need to save the openGL state at the beginning, then restore it once finished with the osg rendering, but I'm not sure exactly what the osg rendering consists of. I tried calling frame() on an osgviewer from there, but got a fistfull of openGL errors QGLContext::makeCurrent(): Failed. QGLShader: could not create shader Vertex shader for simpleShaderProg (MainVertexShader PositionOnlyVertexShader) failed to compile QGLShader: could not create shader Fragment shader for simpleShaderProg (MainFragmentShader ShockingPinkSrcFragmentShader) failed to compile QGLShaderProgram: could not create shader program Errors linking simple shader: QGLShader: could not create shader Vertex shader for blitShaderProg (MainWithTexCoordsVertexShader UntransformedPositionVertexShader) failed to compile QGLShader: could not create shader Fragment shader for blitShaderProg (MainFragmentShader ImageSrcFragmentShader) failed to compile QGLShaderProgram: could not create shader program Errors linking blit shader: QGLContext::makeCurrent(): Failed. Maybe I am just setting things up wrong? I have a QWidget that creates a QGraphicsView and an osgViewer::Viewer. I set the viewport of the GraphicsView to be the GLWidget from the Viewer's graphicsWindow.getGLWidget(). I subclassed the QGraphicsScene to give it a pointer to the viewer, and in the drawBackground method I saved off the openGL state, called frame() on the viewer, and restored the state, but the window doesn't render and gives me those errors. Has anyone had success with this? And if so, has anyone gotten it to work with anything other than a single-threaded approach? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60822#60822 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Event handler Priority
Hi, Is there any way to specify the order that your event handlers / camera manipulator will see events? In my application, under certain circumstances, I want to override the default left-click behavior from camera manipulation to something else. Thank you! Cheers, Nick -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60648#60648 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] OSG Pick Tex Coords
Thanks Robert, My branch is using 3.0.1, which did not have that functionality, but I was able to piece it together from the implementation in 3.2.0, since it doesn't appear that we are upgrading any time soon. Thanks for the pointer-works just the way I hoped! Thank you! Cheers, Nick -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=59362#59362 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] RTT Magnifying Glass with multiple zooms
I ended up solving 1 and 2 by using a single texture for the RTT to render the whole window, then setting the drawable's tex coords such that each quad zoomed in on the appropriate area. I haven't decided what to do about the resizing, but it doesn't seem to be stretching the texture (which I was worried about), just the shape of the magnifying box, and I may just keep that behavior. Cheers, Nick -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=59315#59315 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] OSG Pick Tex Coords
Is there a quick/convenient way to get the tex-coord for the vertex/drawable returned from an intersection (i.e. the way that osgpick example returns the vertex world and local coordinates)? Or do you have to compute the tex coord yourself? Cheers, Nick -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=59317#59317 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgQt QWidgetImage as HUD not getting events
In case anyone comes across this, I ended up solving the problem by subclassing the InteractiveImageHandler, QWidgetImage, and QGraphicsViewAdapter. I had to get the InteractiveImageHandler to do the right coordinate projection for the the clicks, and I had to get the QWidgetImage and QGraphicsViewAdapter to only handle events on the widgets I wanted; which I solved by adding a check for a custom QT Dynamic Property on my widgets; that way only interactive widgets would handle the events, and others would be passed on to the manipulators. Thank you! Cheers, Nick -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=59218#59218 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] RTT Magnifying Glass with multiple zooms
Hi, I'm working on a zoom/magnifying lens feature, that I am implementing using RTT. I'm setting up a slave camera to the main view and rendering to a texture, which I place on a quad on the HUD. I've got a few questions: 1. Whats the best way to move the slave camera to magnify different areas? Moving the slave RTT Camera viewport? Setting a matrix offset for the slave with respect to the main camera? Something else? 2. If I want to show multiple zoom levels of magnification at the same time (on adjacent quads on the HUD), do I need to render to texture multiple times, or can I somehow index the higher zoom quads into the texture so that a smaller chunk of the texture gets put on the same-size quad (effectively blowing it up?) 3. When my HUD resizes (due to a window resize), the size/aspect ratio of the quads gets thrown off. How could I handle that to keep it the same? (use a MatrixTransform to scale the quad to the right aspect ratio? Resize the quad?) Cheers, Nick -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=59219#59219 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgQt QWidgetImage as HUD not getting events
I've managed to get the HUD to process events. The problem is that it is now capturing all events, and I cannot use the camera manipulators underneath the HUD. It seems to be the case that the InteractiveWidgetHandler is always returning true, because the widget is full-screen and thus always getting picked. However, I only want that to return true when the QWidget actually handles the event (i.e. a button gets pressed or a slider gets dragged or something), not when an empty part of the widget is clicked. Any thoughts? Thank you! Cheers, Nick -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=59062#59062 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgQt QWidgetImage as HUD not getting events
I have tried adding the InteractiveImageHandler to the view that I want to handle them, but they still do not get any events. Any other suggestions? Cheers, Nick -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=59038#59038 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgQt QWidgetImage as HUD not getting events
I found that I was using the wrong constructor for the Interactive Image Handler, I think; It seems that the IIH expects the image to either be part of the scene OR be a full screen HUD, not the sort of half-and-half that I have. Using the other constructor for the IIH, one of my widgetImages gets events, but the other doesn't, and the position and aspect ratio of them gets broken. The Handler doesn't seem to support non-fullscreen HUDs. Working on a subclass... Anyone have a similar experience before / have a quick fix? Cheers, Nick -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=59039#59039 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] osgQt QWidgetImage as HUD not getting events
I have a Composite Viewer setup with multiple views/cameras, and a 2D Ortho HUD camera that I add to the root node of my scene to render HUD elements. One of these elements is a textured quad with a QWidgetImage. I set up the InteractiveImageHandler and gave it to the drawable as event and cull callbacks. However, it is not handling my click presses. I think that it is because it is a child of the HUD camera, and not of the camera that I give to the views? How do I get events to the interactive image handler? Code: //HUD Camera osg::Camera *HUDCam = new osg::Camera(); group-addChild(HUDCam); HUDCam-setProjectionMatrix(osg::Matrix::ortho2D(0, 1280, 0, 1024)); HUDCam-setViewMatrix(osg::Matrix::identity()); HUDCam-setReferenceFrame(osg::Transform::ABSOLUTE_RF); HUDCam-setClearMask(GL_DEPTH_BUFFER_BIT); HUDCam-setRenderOrder(osg::Camera::POST_RENDER); HUDCam-setAllowEventFocus(true); //Quad osg::PositionAttitudeTransform *pat = new osg::PositionAttitudeTransform(); QWidget* widget = new HudWidget(); osg::ref_ptrosgQt::QWidgetImage widgetImage = new osgQt::QWidgetImage(widget); widgetImage-getQGraphicsViewAdapter()-setBackgroundColor(QColor(0,0,0,0)); osg::ref_ptrosgViewer::InteractiveImageHandler handler = new osgViewer::InteractiveImageHandler( widgetImage.get() ); osg::ref_ptrosg::Texture2D texture = new osg::Texture2D; texture-setImage( widgetImage.get() ); osg::ref_ptrosg::Geode geode = new osg::Geode(); osg::ref_ptrosg::Geometry quad = osg::createTexturedQuadGeometry(osg::Vec3(), osg::Vec3(widgetImage-s(),0,0), osg::Vec3(0,widgetImage-t(),0)); pat-setPosition(osg::Vec3(0, 1024-widgetImage-t(), -1)); quad-setEventCallback( handler.get() ); quad-setCullCallback( handler.get() ); geode-addDrawable(quad); geode-getOrCreateStateSet()-setTextureAttributeAndModes(0, texture.get(), osg::StateAttribute::ON); geode-getOrCreateStateSet()-setMode(GL_LIGHTING, osg::StateAttribute::OFF); geode-getOrCreateStateSet()-setRenderingHint(osg::StateSet::TRANSPARENT_BIN); geode-getOrCreateStateSet()-setMode(GL_BLEND, osg::StateAttribute::ON); pat-addChild(geode); HUDCam-addChild(pat); [/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=58971#58971 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Composite Viewer framerate multiple cameras on large data
Hi, I tracked this down to a driver issue, I think; I'm running on a laptop with Nvidia Optimus graphics using Ubuntu 12.04, and support for the dual-gpu is a little wonky. I reconfigured my drivers, xorg headers, and bumblebee optimus support, and got everything working happily. Thank you! Mods can close this thread, I guess. Cheers, Nick -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=58822#58822 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Composite Viewer framerate multiple cameras on large data
nsm4d wrote: Hi, I pulled the osgviewerQt example code into my project, and built and ran that. 3 out of 4 times, it runs fast (~60 fps), however, sometimes it runs slowly (~7 fps). So I don't think that the problem is my dataset or viewer setup. Attached are the stats when it runs fast vs. slow. Nothing about my system configuration changed between runs - I ran it once, it was fast, I took the screenshot. I ran it and closed it a few more times, and one of them was slow, I took another screenshot. I ran it again after that, and it was fast. It looks like there is a big gap between the Draw and the GPU when it is running slow. Driver issue? Thank you! Cheers, Nick Fast http://imgur.com/lZQkDIT Slow http://imgur.com/ohuka2J Moderator blocked my post with attached images, so I edited and linked to them instead. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=58795#58795 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Composite Viewer framerate multiple cameras on large data
Hi, I have a scene graph set up with a large dataset ( A Geocentric Earth from osgEarth). In my composite viewer, I want to have multiple viewpoints (with separate camera manipulators/projection matrices; ie. an Orthographic, perspective, etc) each within a QT widget. I got this set up the way I wanted it by following the osgViewerQt example, using the CullDrawThreadPerContext threading model, but the framerate is pretty low. Are there any tricks I can do to improve the performance? Sharing graphics contexts, etc? Thank you! Cheers, Nick -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=58772#58772 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Primitive colors overwriting textured quad
Hi, I have a simple scene where I create a textured quad, and then add some simple objects to it (spheres, lines, etc). Using the ubuntu distro OSG (3.0.0 I believe), this was working fine. When I upgraded to 3.3.0, adding the new objects now seems to overwrite the colors in the texture - for example, if I have an image showing on the quad, and add a green(0, 1, 0, 1) line to the scene, the image becomes a greenscale version of itself. If i continue to add objects of other colors, the most recently added object/color takes precedence. I tracked this down to commit eb7929b85ad87316a2437da03b4bb810cded7366: Added SceneView::Options enum enetries APPLY_GLOBAL_DEFAULTS and CLEAR_GLOBAL_STATESET to control whether a _globalStateSet-clear() and _globalStateSet-setGlobalDefaults() should be called. osgViewer::Renderer doesn't use these enum settings so now no longer has a calls StateSet::clear() or StateSet::setGlobalDefaults() on the osg::Camera's StateSet. Previously these were being called and breaking the ability to attached state to Camera's StateSet. I am inheriting CompositeViewer, so it seems to me that with the removal of StateSet::Clear() in osgViewer, some behavior has changed that is allowing the stateset of the texture to get overwritten when new objects are added. Likely, there is a bug in my program that was hidden by the old behavior. So here are some snippets. Code: //Setting up the texture m_texture = new osg::Texture2D(img); m_texture-setResizeNonPowerOfTwoHint(false); m_texture-setDataVariance(osg::Object::DYNAMIC); m_texture-setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); m_texture-setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); m_texture-setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR); m_texture-setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR); //setting up the quad int w = m_quad_size.x(); int h = m_quad_size.y(); osg::Vec3Array* vertices = new osg::Vec3Array; vertices-push_back( osg::Vec3(-w/2, 0, h/2) ); // front left vertices-push_back( osg::Vec3(w/2, 0, h/2) ); // front right vertices-push_back( osg::Vec3(w/2, 0, -h/2) ); // back right vertices-push_back( osg::Vec3(-w/2, 0, -h/2) ); // back left osg::Vec2Array *texcoord = new osg::Vec2Array; texcoord-push_back(osg::Vec2(0.0, 0.0)); texcoord-push_back(osg::Vec2(1.0, 0.0)); texcoord-push_back(osg::Vec2(1.0, 1.0)); texcoord-push_back(osg::Vec2(0.0, 1.0)); osg::Geometry *geom = new osg::Geometry; geom-setVertexArray(vertices); geom-setTexCoordArray(0, texcoord); geom-addPrimitiveSet(new osg::DrawArrays(GL_QUADS, 0, 4)); osg::Geode *geode = new osg::Geode; geode-addDrawable(geom); geode-getOrCreateStateSet()-setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON); //Creating a line to add osg::ref_ptrosg::Geode geode = new osg::Geode; osg::ref_ptrosg::Geometry geometry = new osg::Geometry(); osg::ref_ptrosg::Vec3Array vertices = new osg::Vec3Array(2); (*vertices)[0].set(p1[0], p1[1], p1[2]); (*vertices)[1].set(p2[0], p2[1], p2[2]); geometry-setVertexArray(vertices); osg::ref_ptrosg::Vec4Array colors = new osg::Vec4Array; colors-push_back(color); geometry-setColorArray(colors); geometry-setColorBinding(osg::Geometry::BIND_OVERALL); osg::ref_ptrosg::Vec3Array normals = new osg::Vec3Array; normals-push_back(osg::Vec3(0.0f,-1.0f,0.0f)); geometry-setNormalArray(normals); geometry-setNormalBinding(osg::Geometry::BIND_OVERALL); geometry-addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,2)); geometry-setUseDisplayList(false); osg::ref_ptrosg::StateSet state = new osg::StateSet(); if (no_depth_test) { state-setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF); } state-setRenderBinDetails(100, RenderBin); geode-setStateSet(state); geode-addDrawable(geometry); The quad and the line are both children of an osg::Group that is set as the osgViewer::View's scenedata. Thank you! Cheers, Nick Code: -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=57705#57705 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [vpb] osgdem and HAE/MSL
Hi, When providing elevation data to osgdem. is it expected to be in HAE (height above ellipoid), or MSL (mean sea level), or can it tell from the input? For example, I am providing elevation data in the AIG/Arc/Info Binary Grid format (.adf). The data represents the elevation of the area in meters MSL. However, when I osgpick a point and convert it to Lat-Lon-Alt MSL, the altitude is off by about 30m (the difference between HAE and MSL at this location). This are the options I ran osgdem with $ osgdem --geocentric -o output.ive -l 8 -d ./path-to-dted/ -t image.tif Is it possible to specify a vertical datum or coordinate system, such as EGM96? Thank you! Cheers, Nick -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=55984#55984 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org