Strange rendering errors with OpenGL under Qml Scene

As a hobby, I experiment with OpenGL and write my own dumb engine with Qt + OpenGL. The latest success was the creation of the Entity System Framework, which could render a scene with shadows (from rendering to texture to RenderBuffer) with an attached physics engine (BulletPhysics).

After that, I upgraded to Qt 5.2 and was fully expressed by Qml (not trying to use it before). I experimented a bit with 2d qml graphics and decided to use qml for the user interface, but rejected the 2d project and returned to 3d. I created a new qml project, try to do some things under qml, as in the Example script - OpenGL under QML . After that, I moved my old code from a 3d project to a new project with a little refactoring (which should not affect anything).

At this moment I get tired of some strange mistake. It seems that the first frame is rendered as needed, but after that something goes wrong.

Scene view This is a slightly less normal frame (before any movement)

( ). qml. . , . - , , , .

Scene view after some shadow map rotate

, (? o_0) . qml. , .

Scene after moving camera down (-Z) (-Z)

qml, :

connect(window, &QQuickWindow::beforeRendering, this, &MyApp::renderScene, Qt::DirectConnection);

renderScene I:

  • OpenGL ( Qml, );

    glViewport(0, 0, window->width(), window->height());
    
    glClearColor(0, 0, 0, 1);
    glClearDepth(1);
    glDepthRange(0,1);
    glDepthFunc(GL_LEQUAL);
    
  • BulletPhysics ( - )

  • Render shadow map ( ) RenderBuffer ( 2048x2048, GL_DEPTH_COMPONENT24)
  • RenderBuffer ( GL_RGBA8 GL_DEPTH_COMPONENT24 )
  • Render two 2d quads - ( renderbuffer ) ( )

, . glGetError .

Scene with camera moved XY. -

:

Old project ( qml)

Old project - big screenshot ( )

Broken resize

?

: Qt Creator 3.0.0, Qt 5.2.0, Linux (Kubuntu 13.10) 64-, HD 7750

OpenGL: 3.3, 4.3 ( )

P.S. , , .

+4
1

!

, - , . . , Qml.

  glDepthMask (GL_TRUE);//42!

42 - . , Qml glDepthMask(GL_FALSE); ( emit &QQuickWindow::beforeRendering). , . , glDepthMask(GL_FALSE); ? FPS , "42" , glDepthMask(GL_FALSE); , .

"" () - .

Yippee!

Result in new project

+4

Source: https://habr.com/ru/post/1527624/


All Articles