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 分段错误
基础教程推荐
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 从 std::cin 读取密码 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01