33 lines
751 B
C
33 lines
751 B
C
#include <SDL2/SDL_error.h>
|
|
#include <SDL2/SDL_timer.h>
|
|
#include <SDL2/SDL_video.h>
|
|
#include <stdio.h>
|
|
#include <SDL2/SDL.h>
|
|
|
|
#undef main
|
|
int main()
|
|
{
|
|
SDL_Window *window = NULL; // SDL窗口指针
|
|
SDL_Init(SDL_INIT_VIDEO);
|
|
|
|
window = SDL_CreateWindow("Hello SDL Window",
|
|
SDL_WINDOWPOS_UNDEFINED, // 不定义,让系统决定
|
|
SDL_WINDOWPOS_UNDEFINED,
|
|
640, // 宽
|
|
480, // 高
|
|
SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
|
|
|
|
if (!window) {
|
|
printf("SDL_CreateWindow() failed, err: %s\n", SDL_GetError());
|
|
return -1;
|
|
}
|
|
|
|
SDL_Delay(10000); // 延迟10000ms
|
|
|
|
SDL_DestroyWindow(window); // 销毁窗口
|
|
|
|
SDL_Quit(); // 释放资源
|
|
|
|
return 0;
|
|
}
|