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(); }

基本的步骤

  1. 初始化
  1. 创建Window
  1. 监听输入事件
  1. 监听到关闭事件的时候销毁Window并离开

源码

用SDL展示一张JPG图片初识SDL
姜康
姜康
一个软件工程师
公告
type
status
date
slug
summary
tags
category
icon
password
🎉博客网站重新制作了🎉
👏欢迎更新体验👏