简体   繁体   English

如何在OpenGL Superbible 6th Edition中构建和运行示例?

[英]How to build and run examples in OpenGL Superbible 6th edition?

My system is Win 8.1 64-bit and using VS2013 Express. 我的系统是Win 8.1 64位并使用VS2013 Express。 I can verify my video cards support the latest OpenGL and OpenCL. 我可以验证我的视频卡支持最新的OpenGL和OpenCL。 I used the latest code and media files from authors github and site: https://github.com/openglsuperbible/sb6code and http://www.openglsuperbible.com/example-code/ respectively. 我分别使用了来自作者github和站点的最新代码和媒体文件: https : //github.com/openglsuperbible/sb6codehttp://www.openglsuperbible.com/example-code/

I am able to make debug and release builds of the project(s) successfully but cannot correctly run it either via debug mode or the .exe in the bin folder. 我能够成功调试并发布项目的版本,但无法通过调试模式或bin文件夹中的.exe正确运行它。 A white window will show up and then exit. 将显示一个白色窗口,然后退出。 I was able to step through and found that glfwOpenWindow will return false causing the exit but I cannot step further and see why it is returning so. 我能够逐步执行,发现glfwOpenWindow将返回false导致退出,但我无法进一步执行并查看为什么返回。 I found some solutions that suggested changing 我发现了一些建议改变的解决方案

glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

to

glfwOpenWindowHint(GLFW_OPENGL_PROFILE, 0);

but this does not change my results. 但这不会改变我的结果。 I can verify also that major version is 4 and minor is 3 for the book code. 我还可以验证书籍代码的主要版本是4,次要版本是3。 I have found a few other people having the same problem but no resolution. 我发现其他一些人也有同样的问题,但没有解决方案。 Another possible solution (but to a different problem it seems) was changing the project subsystem to Console from Windows but this throws an error regarding main and so it may not be what I'm looking for. 另一个可能的解决方案(但似乎是一个不同的问题)是将项目子系统从Windows更改为Console,但这会引发关于main的错误,因此可能不是我想要的。

For reference, this book is using glfw version 2.7.6 when (currently) the latest is 3.0.4. 作为参考,本书使用的是glfw版本2.7.6,当前(最新)版本是3.0.4。 I tried swapping this too but it understandably blew up due to all of the changes. 我也尝试过交换它,但是由于所有更改,它被炸掉了,这是可以理解的。

Any further ideas would be great and very helpful! 任何进一步的想法将是伟大的,非常有帮助的!

I have discovered that while my GPU does support the latest OpenGL, my computer was instead using the integrated Intel HD 4600! 我发现,尽管我的GPU确实支持最新的OpenGL,但我的计算机却使用集成的Intel HD 4600! By switching my computer to use the dedicated GPU by default, I am able to run the latest OpenGL. 通过默认情况下将计算机切换为使用专用GPU,我可以运行最新的OpenGL。

If it successfully compiled, then please do following: 如果编译成功,请执行以下操作:

  1. Ensure that you do have the latest graphic card drivers installed (eg. if you have nVIDIA card, go to www.nvidia.com and get newest drivers). 确保您确实安装了最新的图形卡驱动程序(例如,如果您具有nVIDIA卡,请访问www.nvidia.com并获取最新的驱动程序)。

  2. Ensure that files which these examples are trying to load (I guess jpg/tga/png files, maybe some obj/fbx/3ds files for geometry, whatever else these examples need) are present at expected path (relative path to exe). 确保这些示例尝试加载的文件(我猜是jpg / tga / png文件,也许还有一些用于几何图形的obj / fbx / 3ds文件,无论这些示例需要其他什么)都位于预期路径(exe的相对路径)上。

  3. Run it as a debug, place breakpoints in app initialization, see that OpenGL is initialized correctly and that required files are loaded. 将其作为调试运行,在应用程序初始化中放置断点,查看OpenGL是否已正确初始化以及已加载所需文件。 I think you will find that required files are not in expected path(s). 我认为您会发现所需的文件不在预期的路径中。

PS PS

I think the best practice for learning OpenGL is not to rely on some library to open window and initalize OpenGL for you - it's better you learn it all step by step - how to open an application window, how to initialize gl render context associated with device context etc. You'd also avoid things like this when you don't know where the problem could be. 我认为学习OpenGL的最佳做法是不要依赖某些库来打开窗口并为您初始化OpenGL-最好逐步学习所有内容-如何打开应用程序窗口,如何初始化与设备关联的gl渲染上下文上下文等。当您不知道问题可能在哪里时,您还应该避免这样的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM