<pre name="code" class="cpp">#include <stdio.h>
#include <stdlib.h>
#include <SDL.h>
int SDL_main(int argc, char * argv[])
{
SDL_Window *window = NULL;
if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO)==-1)
{
fprintf(stderr, "SDL_Init() failed\n");
exit(-1);
}
atexit(SDL_Quit);
window = SDL_CreateWindow("Window Title",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
640,480, SDL_WINDOW_OPENGL);
if(NULL==window){
fprintf(stderr, "SDL_CreateWindow() failed\n");
exit(-1);
}
SDL_ShowWindow(window);
SDL_DestroyWindow(window);
window = NULL;
return 0;
}SDL窗口的创建、显示和销毁
最新推荐文章于 2025-03-11 23:15:44 发布
本文介绍了一个使用Simple DirectMedia Layer (SDL)创建基本窗口的应用程序示例。通过初始化SDL、创建窗口并显示它,展示了如何使用SDL库进行基本的图形应用程序开发。
1690





