<div dir="ltr"><div><div><div>Hi Ronny,<br><br></div>Where the problem lies will likely be how you are managing the viewer as well as the graphics context. My hunch is that you've created the problem with your "custom" means of managing things.<br><br></div>If you can try running your application with a straight osgViewer::Viewer with it creating a single window for you rather than hand wiring things yourself, even if this doesn't give you exactly what you want for your final application it will at least give you a sanity test to compare results against. If this works then you know that the issue stems from your won custom set up.<br><br>While it possible to hand wire things up it's more complicated with more options for screwing things up if your don't know how all the various elements fully work together.<br><br></div>Robert.<br><div><div><br><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 18 April 2016 at 16:30, Ronny Hatteland <span dir="ltr"><<a href="mailto:ronnyhatteland@gmail.com" target="_blank">ronnyhatteland@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> That should not be needed at all, and indicative that something somewhere in your application or it's usage of the OSG is messing up the GL object management.<br>
><br>
><br>
> The resizeGLObjbectBuffer() is only needed when graphics context are created or destroyed.<br>
><br>
><br>
><br>
> As to what is going wrong your case I can't say - something *very* odd is happening. Are you creating your own graphics context / modifying the viewer?<br>
><br>
><br>
> Robert.<br>
<br>
<br>
</span>Yes I am creating my own GraphicsContext:<br>
<br>
Code:<br>
// Local Variable to hold window size data<br>
RECT rect;<br>
<br>
// Get the current window size<br>
::GetWindowRect(m_hWnd, &rect);<br>
<br>
// Init the GraphicsContext Traits<br>
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;<br>
<br>
// Init the Windata Variable that holds the handle for the Window to display OSG in.<br>
osg::ref_ptr<osg::Referenced> windata = new osgViewer::GraphicsWindowWin32::WindowData(m_hWnd);<br>
<br>
// Setup the traits parameters<br>
traits->x = 0;<br>
traits->y = 0;<br>
traits->width = (rect.right - rect.left);<br>
traits->height = ( rect.bottom - rect.top);<br>
<br>
traits->windowDecoration = true; // CHECK DIFFERENCE<br>
traits->doubleBuffer = false;<br>
traits->setInheritedWindowPixelFormat = true;<br>
traits->inheritedWindowData = windata;<br>
traits->samples = samples;<br>
traits->vsync = false;<br>
GraphicsContext* gc = osg::GraphicsContext::createGraphicsContext(traits.get());<br>
traits->x = 0;<br>
traits->y = 0;<br>
return gc;<br>
<br>
<br>
which afterwards is used as follows:<br>
<br>
<br>
Code:<br>
m_defaultGraphicsContext->clear();<br>
<br>
m_defaultGraphicsContext->setName("DefaultViewGraphicsContext");<br>
m_defaultGraphicsContext->getState()->setUseModelViewAndProjectionUniforms(true); //ADDED FOR SHADER<br>
m_defaultGraphicsContext->getState()->setUseVertexAttributeAliasing(true);<br>
<br>
if (m_defaultGraphicsContext->valid())<br>
{<br>
defaultCamera = mViewer->getCamera();<br>
defaultCamera->setCullMask(0x04);<br>
defaultCamera->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF );<br>
defaultCamera->getOrCreateStateSet()->setMode(osg::StateAttribute::SCISSOR , osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED);<br>
defaultCamera->getOrCreateStateSet()->removeAttribute(osg::StateAttribute::MATERIAL);<br>
defaultCamera->getView()->setLightingMode(osg::View::NO_LIGHT);<br>
defaultCamera->setGraphicsContext(m_defaultGraphicsContext);<br>
defaultCamera->setViewport(new osg::Viewport(m_defaultGraphicsContext->getTraits()->x, m_defaultGraphicsContext->getTraits()->y, m_defaultGraphicsContext->getTraits()->width, m_defaultGraphicsContext->getTraits()->height));<br>
}<br>
<br>
double fovy, aspectRatio;<br>
<br>
mViewer->getCamera()->getProjectionMatrixAsPerspective(fovy, aspectRatio, defaultCameraNear, defaultCameraFar);<br>
aspectRatio = double(m_defaultGraphicsContext->getTraits()->width) / double(m_defaultGraphicsContext->getTraits()->height);<br>
mViewer->getCamera()->setProjectionMatrixAsPerspective(fovy, aspectRatio, 0.0000000001f, defaultCameraFar);<br>
<br>
initOpenGL(m_defaultGraphicsContext, maxNumUniforms, maxUniformBlockSize);<br>
<br>
<br>
<br>
<br>
Code:<br>
<br>
void initOpenGL(osg::ref_ptr<osg::GraphicsContext> context, GLint& maxNumUniforms, GLint& maxUniformBlockSize) {<br>
context->realize();<br>
context->makeCurrent();<br>
maxNumUniforms = 0;<br>
glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &maxNumUniforms);<br>
maxUniformBlockSize = 0;<br>
glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &maxUniformBlockSize);<br>
<br>
// init glew<br>
///glewExperimental = GL_TRUE;<br>
/// if (GLEW_ARB_vertex_buffer_object == FALSE || GLEW_ARB_vertex_array_object == FALSE) return;<br>
#ifdef USE_INSTANCED_DRAWING<br>
glewInit();<br>
#endif<br>
context->releaseContext();<br>
<br>
// ATI driver 11.6 didn't return right number of uniforms which lead to a crash, when the vertex shader was compiled(WTF?!)<br>
#ifdef ATI_FIX<br>
maxNumUniforms = 576;<br>
maxUniformBlockSize = 16384;<br>
#endif<br>
}<br>
<br>
<br>
<br>
Maybe you can spot something that is clearly wrong here, otherwise it could be related to the glewInit()?<br>
<span class=""><br>
------------------<br>
Read this topic online here:<br>
</span><a href="http://forum.openscenegraph.org/viewtopic.php?p=66864#66864" rel="noreferrer" target="_blank">http://forum.openscenegraph.org/viewtopic.php?p=66864#66864</a><br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</div></div></blockquote></div><br></div>