QOpenGLWidget show black screen

前端 未结 3 1871
北荒
北荒 2021-01-28 20:38

I tried the QOpenGLWidget example described here: https://stackoverflow.com/a/31524956/4564882

but I get only a black widget. The code is exactly the same. this the code

3条回答
  •  孤城傲影
    2021-01-28 21:08

    The problem was because I use Qt5 binaries built with the default configuration. The default in Qt 5.5 is "dynamic" GL -- both ANGLE (ES2)

    ANGLE ((Almost Native Graphics Layer Engine) is an open source project by Google. Its aim is to map OpenGL ES 2.0 API calls to DirectX 9 API.)

    and Desktop backends (Desktop OpenGL)are built, the decision on which one to use is taken at runtime.

    The problem is that ANGLE only supports OpenGL>3.x, so the first code that I test is deprecated and not supported by ANGLE. The second is supported, that's why it worked.

    So, I rebuild Qt to target Desktop OpenGL only to support my deprecated code, using:

    configure -debug-and-release -opensource -opengl desktop -platform win32-msvc2015
    

    and then run nmake, link my application to the new binaries, and my code works well!

提交回复
热议问题