Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I hunt down these OpenGL calls that are distorting objects in my scene?
    primarykey
    data
    text
    <p>I'm mixing two libraries that use OpenGL: Qt and OpenSceneGraph. I'm targeting OpenGL ES 2, so everything is done with shaders and ES 2 compatible calls. </p> <p>I'm specifically using OSG with QtDeclarative by trying to paint OSG onto a QDeclarativeItem. I do this the way suggested in Qt documentation: wrap all OpenGL calls between beginNativePainting()/endNativePainting(). </p> <p>This works fine until I use textures in my OpenSceneGraph scene. When I do this, my QML window gets "messed up" for lack of a better word. To keep it as simple as possible, my OSG scene consists of a plane with a texture applied to it. I recreated the scene using basic OpenGL calls and the problem no longer occurs. Here's the problem summarized as a bunch of pictures:</p> <ul> <li>The QtDeclarative engine uses OpenGL to paint stuff. I set up a simple QML page:</li> </ul> <p><img src="https://i.stack.imgur.com/ow2oP.png" alt="enter image description here"></p> <ul> <li>I create a simple scene using OpenGL directly. It's a plane with a texture painted onto it.</li> </ul> <p><img src="https://i.imgur.com/8WtGA.png" alt="enter image description here"></p> <ul> <li>Now I try to set up the same scene in OSG... identical shaders, etc.</li> </ul> <p><img src="https://i.stack.imgur.com/CpvOs.png" alt="enter image description here"></p> <p>You can see something odd is going on with the last screenshot. Don't worry about the black background where the original OpenGL scene was transparent, that's just OSG using a black clear color. The problem is that the other items set up with QML (the rectangles) get messed up.</p> <p><strong>Edit</strong>: To clarify what happens: The rectangles I draw with QML are all stretched out to the right edge of the screen. I also noticed if I draw rectangles <em>after</em> the OpenSceneGraph item in QML, they don't show up (I didn't notice this before). I draw the purpley black rectangle after the OSG item in the following screenshots... note that it disappears. There might be more weird stuff happening, but this is all I've observed playing with rectangles.</p> <p><strong>Before</strong> <img src="https://i.stack.imgur.com/JIoMF.png" alt="enter image description here"></p> <p><strong>After</strong> <img src="https://i.stack.imgur.com/3sZWZ.png" alt="enter image description here"></p> <p>I'm fairly new to OpenGL so I don't know what kind of call/state setting would cause something like this to happen. <strong>I think that OpenSceneGraph makes some OpenGL state change that's messing up Qt's paint engine. I also know that this only occurs when OSG uses textures... if I don't apply textures in my OSG scene, this doesn't happen.</strong> This is where I'm stuck.</p> <p>Also, I tried to use BuGLe to get an OpenGL call trace with and without textures enabled in OSG to see if I could figure out the problematic state change(s). I found a few differences, and even some global state that OSG changed (such as glPixelStorei()) between the two, but resetting the changes I found made no difference. It would help a lot if I knew what to look for. If anyone's feeling insane, I also have the stack traces:</p> <ul> <li>OSG with texturing: <a href="http://pastie.org/4223182" rel="noreferrer">http://pastie.org/4223182</a> (osg texture stuff is lines 637~650)</li> <li>OSG without texturing: <a href="http://pastie.org/4223197" rel="noreferrer">http://pastie.org/4223197</a></li> </ul> <p><strong>Edit 2:</strong> Here's a diff that might be helpful. You'll need to scroll way down before the relevant lines are apparent. <a href="http://www.mergely.com/nUEePufa/" rel="noreferrer">http://www.mergely.com/nUEePufa/</a></p> <p><strong>Edit 3:</strong> Woah! Okay, that diff helped me out quite a bit. OSG enables VertexAttribArray 3 but doesn't disable it. Calling glDisableVertexAttribArray(3) after OSG renders its frame seems to partially solve the problem; there's no more stretching of the QML rectangles. <strong>However, rectangles drawn after the OSG item still don't show up</strong>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload