C ++ SDL分段故障 [英] C++ SDL segmentation fault

查看:186
本文介绍了C ++ SDL分段故障的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的游戏工作,然后决定使用以下教程尝试并实施菜单。

I had my game working and then decided to try and implement a menu using the following tutorial.

我没有使用教程来创建他创建的之前的教程中的游戏。

I did not use the tutorial to create the game that was in prior tutorials that he created.

每当我编译并运行它简单加载的程序,然后关闭并说进程以代码的构建日志中的状态3(0分钟,1秒)终止 ::块

Whenever I compile and run the program it loads briefly, then closes and says Process terminated with status 3 (0 minutes, 1 seconds) in the build log of code::blocks.

更新:我已经将pastebin链接的代码更新到了现在我现在正在从调试器是

UPDATE: I have updated the code for the pastebin link to what I have now, the error I am now getting from the debugger is

Program received signal SIGSEGV, Segmentation fault.
In TTF_SizeUNICODE () (E:\game\pong\bin\Debug\SDL_ttf.dll)
At E:\game\pong\main.cpp:27

更新2:看来我没有安装字体。我已经安装了字体&现在调试器到达屏幕以开始和退出字体显示的位置,但是在执行此操作后立即冻结,在调试程序中没有任何错误,如果我正常运行程序,它在文本显示后停止响应,奇怪。在从 code :: blocks 启动程序后强制关闭窗口后,它返回:进程终止状态为-805306369(0分钟, 13秒)

UPDATE 2: Seems that I embarrasingly didn't have the font installed. I've installed the font & now the debugger gets to a point where the screen displays with the font of "Start" and "Exit", however, immediately after doing this the program freezes, no error's what so ever in the debuggger, and if I run the program normally, it just stops responding after the text is displayed, strange. Just realised after forcefully closing the window after launching the program from code::blocks, it returns this: Process terminated with status -805306369 (0 minutes, 13 seconds).

更新3:已解决

推荐答案

您不是在将屏幕(第220行)初始化之前,将其传递给 showMenu (行224)。 AFAIK SDL_SetVideoMode 返回可用于屏幕的曲面

You're not initializing screen (line 220) before you're passing it to showMenu (line 224). AFAIK SDL_SetVideoMode returns a surface you could use for your screen.

这篇关于C ++ SDL分段故障的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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