SDL/OpenGL 结果不一致?
我正在制作这个小型 SDL/OpenGL 游戏。它运行得很好,但只能在一台计算机上运行。如果我编译它并在桌面上运行它,它只会弹出一个空白屏幕。如果我在上网本上运行它,它工作得很好,并且我能够看到我正在尝试渲染的内容。我的问题是:什么可能导致这些不一致的渲染结果?为什么一个程序运行得很好,而另一个程序却出问题了?
I have this little SDL/OpenGL game that I am working on. It runs great, but only on one computer. If I compile it and run it on my desktop, it just pops up a blank screen. If I run it on my netbook, it works just fine and I am able to see what I am trying to render. My question is: What could be causing these inconsistent rendering results? Why is one program running perfectly while the other suffers?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为当您使用
SDL_Init
初始化 SDL 并通过 API 请求其他资源时,您实际上是在检查您的请求是否成功?如果没有,并且您无论如何都继续努力,那么这可能可以解释为什么您会看到空白屏幕。I take it that when you initialise SDL with
SDL_Init
and ask for other resources through the API that you are actually checking that your requests were successful? If not and you plough on regardless then this may explain why you are getting a blank screen.根据您使用的系统,如果您请求硬件表面,SDL 可能会也可能不会返回硬件表面,并且您可能需要也可能不需要调用
SDL_Flip(screen)
来交换视频缓冲区。在 Mac OS X 上尤其如此,其中窗口应用程序只能使用软件界面。如果您想在 OpenGL 中使用 SDL 来启用双缓冲,请调用SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1)
,而不是在SDL_SetVideoMode()SDL_DOUBLEBUF
代码>.Depending on the systems you're using, SDL may or may not be returning a hardware surface if you request one, and you may or may not have to call
SDL_Flip(screen)
to swap video buffers. This is especially true on, say, Mac OS X, where windowed applications can only use software surfaces. If you want to enable double-buffering using SDL with OpenGL, callSDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1)
instead of passingSDL_DOUBLEBUF
in the flags ofSDL_SetVideoMode()
.感谢您的所有回复,但事实证明这是硬件/窗口管理器怪异的某种组合。我添加了更多配置客户端的功能,并使其在窗口中运行,现在至少我得到了一些东西。如果您想查看代码,请在此处浏览。
Thanks for all the replies, but it turned out to be some combination of hardware/window manager bizarreness. I added the ability to configure the client a bit more and made it run in a window, and now at least I am getting something. If you want to take a look at the code, feel to browse it here.