Hi You could use graphics context\window created by another means (that what osg::GraphicsWindowEmbedded does), but you still should create osgviewer and stuff. You can check various osgviewer*** examples in osg source tree in examples directory.
Cheers. 09.09.2012, 03:24, "Dainon Woudstra" <dain...@gmail.com>: > Hi, > > Background: > I've written an application in C# for various reasons. SharpGL provided the > OpenGL portion, C# provided the Database, and Intellisense works with it in > VS 2010. I've rewritten this application in 3 different frameworks and have > hit issues I could not solve for one reason or another. For example, now that > my application works and I use it everyday, I'm trying to enhance some of its > features, such as loading a 3D object and good text rendering. > > I've come across OpenSceneGraph and have been trying to use it with the C# > wrappers. I couldn't get that working and read a bunch of posts providing > other solutions and mentioning it isn't supported anymore. Thus, I've learned > to write a wrapper for a C++ OSG DLL to call some native OSG functions. > > It works great, except that it doesn't, LOL. The code it fine, I've tested it > in a sample, non C# application using the viewer and all. > > The Question: > The part that I don't understand is how to use OSG to render in an existing > OpenGL viewport. Is there a way to attach to the existing OpenGL instead of > creating the OSG viewer as noted in every OSG example I've seen? > > C# SharpGL initialization > > Code: > > // Initialize SharpGL > void initSharpGL() { > openGLControl = new SharpGL.OpenGLControl(); > ((System.ComponentModel.ISupportInitialize)(openGLControl)).BeginInit(); > > // > // openGLControl > // > openGLControl.BitDepth = 32; > openGLControl.Dock = System.Windows.Forms.DockStyle.Fill; > openGLControl.DrawFPS = true; > openGLControl.FrameRate = 60; > openGLControl.Location = new System.Drawing.Point(0, 0); > openGLControl.Name = "openGLControl"; > openGLControl.RenderContextType = SharpGL.RenderContextType.FBO; > openGLControl.Size = new System.Drawing.Size(1680, 1060); > openGLControl.TabIndex = 0; > openGLControl.OpenGLInitialized += new > System.EventHandler(openGLControl_OpenGLInitialized); > openGLControl.OpenGLDraw += new > System.Windows.Forms.PaintEventHandler(openGLControl_OpenGLDraw); > openGLControl.Resized += new System.EventHandler(openGLControl_Resized); > openGLControl.Click += new System.EventHandler(OpenGL_Click); > ((System.ComponentModel.ISupportInitialize)(openGLControl)).EndInit(); > Controls.Add(openGLControl); > > ... > } > > Native OSG Code: > > Code: > > // Create the scene root > mRoot = new osg::Group; > > // The viewer > mViewer = new osgViewer::Viewer; > mWindow = mViewer->setUpViewerAsEmbeddedInWindow(0, 0, 1680, 998); > mViewer->getCamera()->setClearMask(0); > mViewer->setSceneData(mRoot); > mViewer->realize(); > > osg::ref_ptr<osg::Geode> geode = new osg::Geode; > > std::string fontFile("arial.ttf"); > font = osgText::readFontFile(fontFile); > if (font.valid()) { > > osgText::Text* text = new osgText::Text; > if (text != 0) { > text->setFont(font); > text->setColor(osg::Vec4(0.0f, 1.0f, 1.0f, 1.0f)); > text->setCharacterSize(40.0f); > text->setPosition(osg::Vec3(100.0f, 100.0f, 0.0f)); > text->setText("SomeSome!"); > > text->setLayout(osgText::Text::LEFT_TO_RIGHT); > > geode->addDrawable(text); > } > } > > mRoot->addChild(geode); > > The OSG Draw Callback function contents > > Code: > > mViewer->frame(); > > Thank you! > > Cheers, > Dainon > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=49871#49871 > > _______________________________________________ > 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