简体   繁体   English

c++ 在 Visual Studio 2019 游戏 window 中显示空白屏幕 Windows 10

[英]c++ in visual studio 2019 game window showing blank screen Windows 10

I'm working through beginning C++ Game Programming by John Horton and it has been going well.我正在通过 John Horton 的 C++ 游戏编程开始工作,并且进展顺利。 Recently though when running the Local Windows Debugger the game window pops up but doesn't show anything, just a blank window.最近虽然在运行本地 Windows 调试器时,游戏 window 会弹出但没有显示任何内容,只是一个空白的 window。

It runs, it never showed it ran into any errors while running, I scavenged over my code and can't find anything wrong with it.它运行,它从未显示它在运行时遇到任何错误,我清理了我的代码并且找不到任何问题。 I went back and ran one of the games I had made from earlier in the book and worked, and now that just shows a blank screen in the game window too.我回去运行了我在本书前面制作的一个游戏并运行了,现在它也只是在游戏 window 中显示了一个空白屏幕。 I've tried googling and stackoverflow and even looking through the similar questions while making this but no dice.我试过谷歌搜索和stackoverflow,甚至在做这个但没有骰子的时候查看类似的问题。

You can see the code I'm using at the book's github repo ( Beginning C++ Game Programming github repo ), and the issue started in chapter 9, but my hunch is it's not the code since the game that originally worked before is also only showing a blank game window now. You can see the code I'm using at the book's github repo ( Beginning C++ Game Programming github repo ), and the issue started in chapter 9, but my hunch is it's not the code since the game that originally worked before is also only showing现在是一个空白游戏 window。 Running on Windows 10. Alienware Aurora R7.在 Windows 10 上运行。Alienware Aurora R7。 Any assistance would be greatly appreciated!任何帮助将不胜感激! Thanks!谢谢!

According to the official SFML document:根据SFML官方文档:

The loadFromFile function can sometimes fail with no obvious reason. loadFromFile function 有时会在没有明显原因的情况下失败。 First, check the error message that SFML prints to the standard output (check the console).首先,检查 SFML 打印到标准 output 的错误消息(检查控制台)。 If the message is unable to open file, make sure that the working directory (which is the directory that any file path will be interpreted relative to) is what you think it is: When you run the application from your desktop environment, the working directory is the executable folder.如果消息无法打开文件,请确保工作目录(任何文件路径都将被解释为相对的目录)是您认为的:当您从桌面环境运行应用程序时,工作目录是可执行文件夹。 However, when you launch your program from your IDE (Visual Studio, Code::Blocks, ...) the working directory might sometimes be set to the project directory instead.但是,当您从 IDE(Visual Studio,Code::Blocks,...)启动程序时,有时可能会将工作目录设置为项目目录。 This can usually be changed quite easily in the project settings.这通常可以在项目设置中很容易地更改。

Therefore ensure your image is firstly named correctly and secondendly make sure it is in the correct folder ie in your working directory.因此,请确保您的图像首先正确命名,其次确保它位于正确的文件夹中,即在您的工作目录中。

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

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