go to index

SDL2学习笔记-1

read time 1 min read
SDL2

SDL2学习笔记-1

  1. int main() 一定要写为 int main(int argc,char* argv[]) 的形式。

    c
    SDL_window* window
    
    SDL_Surface* surface
    
    SDL_Init(SDL_INIT_VIDEO) //如果出错返回-1
    
    SDL_GetError()
    
    window = SDL_CreateWindow("title",SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WIDTH, HEIGHT, SDL_WINDOW_SHOWN)
    
    surface = SDL_GetWindowSurface(window)
    
    SDL_Event e; //防止窗口关闭
    bool quit = false;
    while (quit == false) { 
    	while (SDL_PollEvent(&e)) {
    		if (e.type == SDL_QUIT) {
    			quit = true;
    		}
    	}
    }