一般而言,初始化和退出 SDL 应该是在程序的入口和出口处完成的。 错误处理:在初始化失败时,SDL_Init将返回一个负数,并且你可以使用SDL_GetError函数获取错误信息进行调试。 只初始化需要的子系统:如果你的应用程序只需要使用特定的子系统,最好只初始化你需要的那些子系统,以减少不必要的开销。 退出时清理资源:在...
常见的子系统和对应的flag如下: 成功时为0,失败时为负错误代码;有关详细信息,请调用SDL_GetError() 示例代码 以一个播放器的初始化为例: #include"SDL.h"intmain(intargc,char*argv[]){if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO)!=0){SDL_Log("Unable to initialize SDL: %s",SDL_GetError());r...
func LaunchGame(title string, width, height int) error { // Convert the title to a c-string ctitle := C.CString(title) defer C.free(unsafe.Pointer(ctitle)) // Initialize SDL if C.SDL_Init(C.SDL_INIT_VIDEO) < 0 { return errors.New("SDL_Init") } defer C.SDL_Quit() // ...
SDL_SetError("Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?"); return -1; } /* Clear the error message */ SDL_ClearError(); #if SDL_VIDEO_DRIVER_WINDOWS if ((flags & (SDL_INIT_HAPTIC|SDL_INIT_JOYSTICK))) { if (...
On macos, if SDL_Init(SDL_INIT_VIDEO) is called on a thread other than the main thread, it'll throw an objective C exception and pop up a macos crash dialog. I'd expect SDL_Init to return false and set an error message instead. I ran int...
intSDL_InitSubSystem(Uint32 flags){if(!SDL_MainIsReady){SDL_SetError("Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?");return-1;}/* Clear the error message */SDL_ClearError();#ifSDL_VIDEO_DRIVER_WINDOWSif((flags&(SDL_I...
mame_printf_error("sdlmame: -debug not supported on X11-less builds\n\n"); osd_exit(machine);exit(-1); }//...这里部分代码省略... 开发者ID:felipesanches,项目名称:ume,代码行数:101,代码来源:sdlmain.c 示例2: main ▲点赞 7▼ intmain...
返回值:int 成功时返回0,失败时返回负数错误码; 调用SDL_GetError()可以获得本次异常信息。 ©著作权归作者所有,转载或内容合作请联系作者 0人点赞 SDL 更多精彩内容,就在简书APP "小礼物走一走,来简书关注我" 赞赏支持还没有人赞赏,支持一下
(operate=operate@entry=0x7ffff7aa43e0 <dlopen_doit>, args=args@entry=0x7fffffffe5b0) at ./dlfcn/dlerror.c:138 #10 0x00007ffff7aa44e9 in dlopen_implementation (dl_caller=<optimized out>, mode=<optimized out>, file=<optimized out>) at ./dlfcn/dlopen.c:71 #11 ___dlopen (file=<...
error = C.GoString(C.SDL_GetError())return}return""} 开发者ID:gasperko,项目名称:pokemon-universe,代码行数:8,代码来源:sdl.go 示例7: New ▲点赞 1▼ // New returns a newly created ScreenfuncNew(widthint, heightint, fullscreenbool, FSAAint, namestring)*Screen{ ...