Re: [osg-users] hook osg into other window
Hi, Maybe you can set up a timer there and call your viewer->frame() on the timer event. Or launch a thread? On Mon, Aug 1, 2016 at 3:12 PM, Sebastian Messerschmidt < sebastian.messerschm...@gmx.de> wrote: > Am 01.08.2016 um 15:04 schrieb Han Hu: > >> Hi Sebastian , >> >> Sketchup doesn't have any API to allow render into its openGL context. >> >> And thanks for your snippet on handling the HWND. But I think the real >> problem lies in that I do not have access to the render loop. So there is >> nowhere for me to place the viewer->frame() to render the stuffs. >> > Maybe you can use the Sketchup-API to at least "pause" the original > applications rendering, so you can sneak in and perfrom your frame. > > >> At last thanks again. >> >> Cheers, >> Han >> >> -- >> Read this topic online here: >> http://forum.openscenegraph.org/viewtopic.php?p=68233#68233 >> >> >> >> >> >> ___ >> osg-users mailing list >> osg-users@lists.openscenegraph.org >> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >> > > > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > -- trajce nikolov nick ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] hook osg into other window
Hi Sebastian , Sketchup doesn't have any API to allow render into its openGL context. And thanks for your snippet on handling the HWND. But I think the real problem lies in that I do not have access to the render loop. So there is nowhere for me to place the viewer->frame() to render the stuffs. At last thanks again. Cheers, Han -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=68233#68233 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] hook osg into other window
Hi Han Hi, Here is my problem. I am writing a plugin for a 3D modeling software , sketchup, and going to draw some 3D things into the OpenGL context. But it does not have any Api for customizing the rendering. So I have to hook my rendering stuffs into its render loop, which I do not have access. Hasn't Sketchup some sort of plugin mechanism to allow for custom rendering? I can get the Windows handle HWND of the top window, maybe from that I can track to which window is doing rendering and the OpenGL context. So here is my question, 1. If I get the HWND of the rendering window, can I draw additional things into it? Even if I do not have the access to the render loop, and start my own loop. You can in general obtain the window handle and setup the OSG viewer associated to it. I've attached some snippet which should illustrate this. I think you need to obtain some control over rendering order to make this work. osg::ref_ptr traits = new osg::GraphicsContext::Traits; RECT rect; auto hwnd = HWND(window_handle); if (!GetWindowRect(hwnd, )) { std::cout << "Error getting window rect from handle. Aborting" << std::endl; return false; } //TODO: get other traits from external window handle: traits->x = 0; traits->y = 0; traits->width = rect.right - rect.left; traits->height = rect.bottom - rect.top; traits->windowDecoration = false; traits->doubleBuffer = true; traits->inheritedWindowData = new osgViewer::GraphicsWindowWin32::WindowData(hwnd); traits->supportsResize = true; traits->sampleBuffers = mConfig.mNumSamples > 0 ? 1: 0; traits->samples = mConfig.mNumSamples; traits->depth = mConfig.mDepthBits; osg::ref_ptr gc = osg::GraphicsContext::createGraphicsContext( traits.get() ); if (gc) { osg::ref_ptr camera = new osg::Camera; camera->setGraphicsContext(gc); camera->setViewport(new osg::Viewport(0,0, traits->width, traits->height)); camera->setProjectionMatrixAsPerspective(30.0, double(traits->width/ traits->height), 1.0, 1000.0); mMainViewer->setCamera(camera); camera->getOrCreateStateSet()->setGlobalDefaults(); } else { std::cout << "Error creating context from traits" << std::endl; return false; } 2. Another strategy, create another window and OpenGL context, that is overlaid on to existing window, but the overlay is transparent and do not interact with user.The new context only retrieves matrix from the existing one. You can give it try if the first method fails. But you will have to make sure to resize/transform the overlay window according to the "parent"s transforms. Cheers Sebastian Thank you! Cheers, Han -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=68226#68226 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] hook osg into other window
Hi, Here is my problem. I am writing a plugin for a 3D modeling software , sketchup, and going to draw some 3D things into the OpenGL context. But it does not have any Api for customizing the rendering. So I have to hook my rendering stuffs into its render loop, which I do not have access. I can get the Windows handle HWND of the top window, maybe from that I can track to which window is doing rendering and the OpenGL context. So here is my question, 1. If I get the HWND of the rendering window, can I draw additional things into it? Even if I do not have the access to the render loop, and start my own loop. 2. Another strategy, create another window and OpenGL context, that is overlaid on to existing window, but the overlay is transparent and do not interact with user.The new context only retrieves matrix from the existing one. Thank you! Cheers, Han -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=68226#68226 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org