C++ SDL segmentation fault(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.
每当我编译并运行程序时,它会短暂加载,然后关闭并在 code::blocks代码>.
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:gameponginDebugSDL_ttf.dll)
At E:gamepongmain.cpp:27
更新 2:似乎我很尴尬地没有安装字体.我已经安装了字体 &现在调试器到达屏幕显示开始"和退出"字体的位置,但是,在执行此操作后程序立即冻结,调试器中没有错误,如果我正常运行程序,它只是在显示文本后停止响应,奇怪.刚从code::blocks
启动程序后强行关闭窗口后发现,返回:Process terminate with status -805306369 (0 minutes,13 seconds)
.
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:已解决.
推荐答案
在将 screen
(第 220 行)传递给 showMenu
(第 224 行).AFAIK SDL_SetVideoMode
返回可用于 screen
的表面.
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 分段错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C++ SDL 分段错误


- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- C++ 协变模板 2021-01-01
- 从python回调到c++的选项 2022-11-16
- 如何对自定义类的向量使用std::find()? 2022-11-07
- 静态初始化顺序失败 2022-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- Stroustrup 的 Simple_window.h 2022-01-01
- 近似搜索的工作原理 2021-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01