I’m afraid this will be quite hard but it is not impossible. I don’t know how much you know about GL and window-system interfaces (GLX, OGL and WGL) and how GL contexts are bound to visuals/windows. This is the hardest thing as we have to assure that GL context specific things (display lists, fonts and textures) are properly initialized for every GL window / scene (in EVE we intentionally use a single GL context for all GL windows to reduce overhead when a single GL scene is shown in several viewers). TGLViewer in itself is mostly agnostic of all these details. I think the way to do it right would be:
extract virtual bases out of TGLWidget and TGLEventHandler;
implement Qt versions of these classes;
implement your window class that will tie those two together with TGLViewer (and instantiate TGLContext and TGLContextIdentity objects based on information extracted from Qt GL context classes).
I might be able to help you with this a little … but I’m busy as hell these days. Also, the changes would only go into root-6 (well, we might be able to port them back to 5.34).
Another option, requiring no changes in root, would be to base your viewer on TGLViewerBase + QtGlWindow (or however it is called) … you’d have to cut-n-paste some of the Render() functions from TGLViewer. You’ll be completely on your own with camera management (you still need to fill up a ROOT camera object and pass it through TGRnrCtx object as scenes do frustum culling based on that) though. Oh, and event handling and selection.
What exactly do you want to do with the geometry once you get it on screen? Be able to manipulate camera, select individual shapes, etc?
The GL in canvas works with creation of off-screen rendering context and copies the contents over to the window … at least it used to be that way. Also, the GL plots do not use the TGLViewer/Scene infrastructure at all. Timur knows more about this. Hmmh … maybe it would even be possible to use this method for TGLViewer/Scene rendering … but one could not use display lists, GL fonts probably would not work and you would have to write your own event handling. Also, there would be no selection (clicking on a shape and getting back what you clicked on).
I want to embed root geometry rendered with OpenGL in Qt application. My goals are:
to show root geometry which looks like in TGLSAViewer, so full shapes, not only grid,
to run this in Qt window, no in any external, the target is to embed this in pvss.
You may want to install QtRoot as prescribed by root.bnl.gov/QtRoot/How2Install4Unix.html
It provides two implementations of the ROOT TVirtualViewer3D interface, namely Coin3D-based ( libqglviewer.com/ ) .
Either one supports the t ROOT 3D geometry with some restriction ( AKA the TGeo geometry operations. ) using the pure Qt widgets
The QRoot test suite includes a few tests to show how it can be used.
fine: actually now we have Coin based 3D viewer and we do not want use Coin anymore, so QtRoot isn’t good option.
matevz: I don’t have very big experience in GL, this is my second GL project. What I’m trying to do now is to let QGLViewer to initialize the context and then call GL drawing functions from ROOT. Is it better to create class based on TGLViewerBase or based on TGLViewer in this case?
Exactly: manipulating camera, and selecting individual shapes is what I need. For example I want to create simple outline of detector, change color of broken part and allow operator to press on this part to show details (it is just example case).
Is it possible to contact you via email in case of future problems?
[quote=“Piotr Jasiun”]Thank you for responses.[quote]It provides two implementations of the ROOT TVirtualViewer3D interface, namely Coin3D-based ( coin3d.org ) and QGLViewer-based[/quote]fine: actually now we have Coin based 3D viewer and we do not want use Coin anymore, so QtRoot isn’t good option.[/quote]My be I missed your point. Did you mean you can pass the pointer of some ROOT 3D objects to your application and that can render it with Coin3D?
Anyway, I understand you want to use Qt and ROOT. To do that you have to find the correct reliable way to synch the Qt and ROOT event loops . Such synchronization is the main job of QtRoot. You need to do that one way or another. That means either you use the existent solution or (re-)invent your own QtRoot.
The OpenGL just adds the extra dimensions and extra layers to your mash-up. However, the first step to do is to create “Qt+Root” layer . [quote=“Piotr Jasiun”]What I’m trying to do now is to let QGLViewer to initialize[/quote]Sorry, did you mean QGLViewer qt-project.org/doc/qt-4.8/QGLWidget.html
I’d start with a cut-n-paste version of TGLViewer and hack calls to TGLWidget and TGLContext and just use whatever Qt provides. Then we can see if we can solve this by introducing virtual base-classes. You will still need TGLContextIdentity … you can use the default one (static member in the class) as it is needed by scenes to decided if they need to recreate display-lists for their elements. You can completely ignore ifs with (fGLDevice != -1) … this is only relevant for GL in pad.
Once you get through this, we can move on to event handling