type
status
date
slug
summary
tags
category
icon
password
const int WIDTH = 600; const int HEIGHT = 600; void SDLExample() { if (SDL_Init(SDL_INIT_EVERYTHING) < 0) { std::cout << "初始化失败" << std::endl; } SDL_Window *window = SDL_CreateWindow("Skia + SDL", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WIDTH, HEIGHT, SDL_WINDOW_ALLOW_HIGHDPI); if (window == nullptr) { std::cout << "创建Window失败" << std::endl; } SDL_Event windowEvent; while (true) { if (SDL_PollEvent(&windowEvent)) { if (windowEvent.type == SDL_QUIT) { std::cout << "终止程序" << std::endl; break; } } } SDL_DestroyWindow(window); SDL_Quit(); }
基本的步骤
- 初始化
- 创建Window
- 监听输入事件
- 监听到关闭事件的时候销毁Window并离开
源码
- 作者:姜康
- 链接:https://jiangkang.tech/article/1f71b97d-54f2-42a0-9410-d58196685ac9
- 声明:本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。
相关文章