Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Chinese
  4. Qt5 中使用 OpenGL 原生 API 包括 glBegin(...) glVertex3f(...) ?
Forum Updated to NodeBB v4.3 + New Features

Qt5 中使用 OpenGL 原生 API 包括 glBegin(...) glVertex3f(...) ?

Scheduled Pinned Locked Moved Chinese
3 Posts 2 Posters 9.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    elerao
    wrote on last edited by
    #1

    发现 Qt5 VC2010 里无法调用 OpenGL 原生 API 例如 glBegin(...) glVertex3f(...) 等等,包括 <GL/gl.h> 就会提示 GLdouble 重定义,查了一下是在 qgl.h 中 将 GLfloat 定义为 GLdouble ,这是为 Qt 嵌入式 <GLES/gl2.h> 里弄的。Qt5 文档里的例子都是使用 QGLFunction 类的成员,然而 QGLFunction 类的成员没有 glBegin(...) glVertex3f(...) 等等。有人解释说 Qt5 使用的是 OpenGL 2 而 Windows 只支持 OpenGL 1.1 因此 Qt5 不允许使用 Windows 的 <GL/gl.h> 而是自己实现了一个嵌入式的 OpenGL(就是 <GLES/gl2.h> 和 QGLFunction 那些玩意),但是这个实现没有提供 glBegin(...) 等管线函数。。。

    以前在 Qt4 写的 OpenGL 程序都是基于 glBegin(...) glVertex3f(...) 等等实现的,现在老师让迁移到 Qt5 里,总不能把以前的东西都重新写一遍吧,而且说实在把以前那些glBegin(...) glVertex3f(...) 等等实现转到 QGLFunction 那些接口上确实不易。

    各位有什么好的方法能在 Qt5 VC2010 里调用 OpenGL 原生 API 分享一下?

    1 Reply Last reply
    0
    • E Offline
      E Offline
      elerao
      wrote on last edited by
      #2

      这个地方提到了一些解决方案,但重新编译也太什么了吧。。。

      "http://qt-project.org/forums/viewthread/22821":http://qt-project.org/forums/viewthread/22821

      bq. OK that is the source of your issues then. The pre-compiled Windows desktop version of Qt5 is built against ANGLE which only provides OpenGL ES 2 support by implementing it on top of DirectX 9.
      This was done to ensure that QtQuick2 works on all windows systems, including those with crappy Intel OpenGL drivers ;)
      OpenGL ES 2 does not support the legacy fixed function pipeline, only a shader-based one.
      There is a bug open to provide a build of Qt 5 using the native desktop OpenGL implementation for Qt 5.0.1. Please go vote for https://bugreports.qt-project.org/browse/QTBUG-28715 to see this happen.
      For now, you have two choices:

      Live with OpenGL ES 2 support and don’t use legacy OpenGL

      Build your own copy of Qt 5 to use the native OpenGL drivers by passing in "-opengl desktop" to configure. With the 2nd option you should have access to OpenGL from 1.0 up to 4.3 (if your card/driver support it).

      1 Reply Last reply
      0
      • D Offline
        D Offline
        deleted487
        wrote on last edited by
        #3

        官方发布中开始提供opengl的二进制包了
        http://download.qt-project.org/official_releases/qt/5.0/5.0.2/
        qt-windows-opensource-5.0.2-msvc2010_32_opengl-x86-offline.exe

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved