C++ 如何在 64 位 Windows 中制作 OpenGL 应用程序?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1236670/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 19:16:21  来源:igfitidea点击:

How to make OpenGL apps in 64-bit Windows?

c++winapiopenglvisual-studio-200564-bit

提问by Ruben Trancoso

My project compiles, link and run in xp32 then I tried to cross compile it to x64 and I came across a lot of questions:

我的项目在 xp32 中编译、链接和运行,然后我尝试将其交叉编译为 x64,但遇到了很多问题:

  1. There's no native x64 instalable OpenGL SDK so I link against what?
  2. I saw someone saying that x64 apps use 32bits opengl dll. I tryied to run my compiled 64-bits app in a xp64 with drivers to my video card (radeon 4850), the same I use on xp32 and I got that typical error "bla bla bla, maybe reinstalling you application will resolve the problem"
  3. If I use video card drivers how to keep it working with another Cards, should I build a version for each? (no sense). Should I load an available library dinamicaly? (same no sense)
  4. Which is the reference implementation for x64? where do I find its libs to link against?
  1. 没有本机 x64 可安装的 OpenGL SDK,所以我链接什么?
  2. 我看到有人说 x64 应用程序使用 32 位 opengl dll。我尝试在 xp64 中运行我编译的 64 位应用程序,并在我的视频卡(radeon 4850)上运行我的驱动程序,我在 xp32 上使用的相同,我遇到了典型的错误“bla bla bla,也许重新安装您的应用程序会解决问题”
  3. 如果我使用显卡驱动程序如何让它与其他显卡一起工作,我应该为每个显卡构建一个版本吗?(没有意义)。我应该动态加载一个可用的库吗?(同样没有意义)
  4. 哪个是 x64 的参考实现?我在哪里可以找到要链接的库?

I'm really lost on that matter. I did a lot of searchs and found nothing that helped me understant till the momment.

在这件事上我真的很迷茫。我做了很多搜索,但没有发现任何可以帮助我理解的东西,直到那一刻。

So, what is the path? What I want to know to make native x64 OpenGL apps?

那么,路径是什么?我想知道什么来制作原生 x64 OpenGL 应用程序?

回答by bk1e

The 64-bit OpenGL import library is included in the Windows SDKand gets installed to %ProgramFiles%\Microsoft SDKs\Windows\<version>\Lib\x64\OpenGL32.lib. The corresponding DLL is named opengl32.dlland is located in %SystemRoot%\system32. The 32-bit version is also named opengl32.dlland is located in %SystemRoot%\syswow64on 64-bit Windows.

64 位 OpenGL 导入库包含在Windows SDK 中并安装到%ProgramFiles%\Microsoft SDKs\Windows\<version>\Lib\x64\OpenGL32.lib. 相应的 DLL 被命名opengl32.dll并位于%SystemRoot%\system32. 32 位版本也被命名opengl32.dll并位于%SystemRoot%\syswow6464 位 Windows 上。

You can't load 32-bit DLLs in a 64-bit process, so whatever you read about x64 apps using the 32-bit OpenGL DLL was incorrect. There is definitely a 64-bit OpenGL DLL, but it has "32" in its name, presumably to make porting easier.

您无法在 64 位进程中加载​​ 32 位 DLL,因此无论您阅读有关使用 32 位 OpenGL DLL 的 x64 应用程序的任何内容都是不正确的。肯定有一个 64 位 OpenGL DLL,但它的名称中有“32”,大概是为了使移植更容易。

回答by LastBlow

The OpenGL static and dynamic libraries OpenGL32.liband opengl32.dllfor 32-bit or 64-bit applications come with the OS and are now respectively in the Windows directories listed below. Just keep in mind that the 32-bit and the 64-bit OpenGL (and glew) libraries are named the same for historical reasons.

OpenGL 静态和动态库OpenGL32.lib以及opengl32.dll32 位或 64 位应用程序随操作系统一起提供,现在分别位于下面列出的 Windows 目录中。请记住,由于历史原因,32 位和 64 位 OpenGL(和 glew)库的名称相同。

If you are using Visual Studio in Windows, no need to copy the opengl32.dlllibrary in your Debugor Releasedirectories where is your .exeor the path to OpenGL32.libin Visual Studio - only add "Opengl32.lib" in Properties, Linker, Input, then Additional Dependencies.

如果您在 Windows 中使用 Visual Studio,则无需复制opengl32.dllDebug或Visual Studio 中的路径或Release目录中的库- 只需在、、、 中添加“Opengl32.lib” 。.exeOpenGL32.libPropertiesLinkerInputAdditional Dependencies

C:\Program Files (x86)\Windows Kits\Lib.0.14393.0\um\x86
C:\Windows\System32

C:\Program Files (x86)\Windows Kits\Lib.0.14393.0\um\x64
C:\Windows\SysWOW64