MS Windows 中的 QT 和本机 OpenGL 支持 [英] QT and native OpenGL support in MS Windows

查看:29
本文介绍了MS Windows 中的 QT 和本机 OpenGL 支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试导入 cube通过 QT 插件在 MS Visual Studio 2013 中的示例.

I'm trying to import the cube example in MS visual studio 2013 via the QT add-in.

不幸的是,当我尝试打开 .pro 文件时,出现以下错误:

Unfortunately, when trying to open the .pro file I get the following error:

项目错误:此示例需要使用 -opengl desktop 配置 Qt

在网络上做了一些研究,我意识到默认情况下 QT OpenGL 支持建立在 ANGLE-library 上 据我所知,这是一个 OpenGL 到 DirectX9.0 的转换器.

Doing a little research in the web I realized that by default QT OpenGL support is build on ANGLE-library which as I realized is an OpenGL to DirectX9.0 kind of translator.

因此,我有两个选择(link):

Thus, I have two options (link):

  1. 安装角度.
  2. 使用选项 -opengl desktop 重新编译 QTv5.3.
  1. Install ANGLE.
  2. Recompile QTv5.3 with option -opengl desktop.

问题是我通过 Windows 的 QT 在线安装程序安装了 QTv5.3.

The problem is that I installed QTv5.3 via QT online installer for windows.

考虑到上述情况,当我通过 Windows 在线安装程序安装 QTv5.3 时,我应该如何使用原生 OpenGL 支持(即,使用 -opengl desktop 选项)重新编译 QTv5.3?

Considering the above, how am I supposed to recompile QTv5.3 with native OpenGL support (i.e., with -opengl desktop option) when I've installed QTv5.3 via the windows online installer?

推荐答案

尽管您可以使用任何您希望的标志自行编译它,但还有一个更简单的选择.Qt 在线安装程序提供了多种发行版:不同版本的 Qt,针对不同的目标,有或没有 OpenGL 支持.

Although you can compile it yourself with any flags you wish, there is a simpler option. Qt online installer provides several distributions: different versions of Qt, for different targets, with or without OpenGL support.

  • 运行 <QT_FOLDER>MaintenanceTool.exe(如果您还没有安装 Qt,则运行在线安装程序)
  • 选择Package manager,按Next
  • Qt->5.3 下检查 msvc2013 32-bit OpenGL(以及您需要的任何其他版本)
  • 下一步...
  • run <QT_FOLDER>MaintenanceTool.exe (or online installer if you have never installed Qt yet)
  • choose Package manager, press Next
  • Under Qt->5.3 check msvc2013 32-bit OpenGL (along with any other version you need)
  • Press Next...

会安装在msvc2013_opengl

那么你可能需要将Visual Studio AddIn指向正确的Qt文件夹(它可以携带多个版本).

Then you probably will need to pointVisual Studio AddIn to correct Qt folder (it can carry multiple versions).

您可以通过运行 qmake 从 Qt 的项目 .pro 文件轻松生成 Visual Studio .vcxproj 文件.无需任何插件.

You can easily generate Visual Studio .vcxproj file from Qt' project .pro file by running qmake. No any addons required.

要做到这一点:

  • 打开VS2013 x86 Native Tools Command Prompt(或用"C:Program Files (x86)Microsoft Visual Studio 12.0VCvcvarsall.bat" x86设置路径代码>)
  • 将所需的 Qt 版本添加到路径:

  • open VS2013 x86 Native Tools Command Prompt (or set up path with "C:Program Files (x86)Microsoft Visual Studio 12.0VCvcvarsall.bat" x86)
  • add desired Qt version to path:

set PATH=%PATH%;<QT_FOLDER>msvc2013_openglin

  • 转到Qt项目文件夹并生成MSVC项目:

  • go to Qt project folder and generate MSVC project:

    cd <pro_folder>
    qmake -tp vc
    

  • 您会在同一个文件夹中找到一个 .vcxproj 文件,其中包含所有 Qt 的花里胡哨(moc'ing、uic'ing、rcc'ing 等),就像构建事件一样
  • 每当您更改 .pro 文件时,请重复此操作.每次都重新加载 .vcxproj(无需关闭 Visual Studio;它会在检测到更改时要求您重新加载).将 .vcxproj 视为临时生成的文件,不要手动更改它.调整 .pro 中的所有内容.
  • You will find in the same folder a .vcxproj file with all Qt's bells and whistles (moc'ing, uic'ing, rcc'ing etc.) set up like build events
  • Repeat this operation whenever you change .pro file. Reload .vcxproj each time (no need to close Visual Studio; it will ask you to reload when it detects changes). Consider .vcxproj as temporary, generated file and don't change it manually. Tweak all the stuff in .pro.
  • 提示:编写 .bat 文件以自动完成所有这些工作.

    Hint: write .bat file to do all this stuff automatically.

    HTH

    这篇关于MS Windows 中的 QT 和本机 OpenGL 支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆