WhyCan Forum

人过留名,雁过留声,感谢各位朋友不离不弃地支持。 QQ: 516333132, 微信: whycan_cn (哇酷网/挖坑网/填坑网) admin@whycan.cn

您尚未登录。

#1 2019-11-22 12:00:06

super
会员
注册时间: 2019-11-22
累计积分: 1

正在学习 SDL2 编程, 随便记录一下

#include <stdio.h>
#include <stdlib.h>
#include <SDL2/SDL.h>

int main(int argc, char* argv[])
{
	SDL_Init(SDL_INIT_VIDEO);
	SDL_Window* window = SDL_CreateWindow("SDL Turtor 2", 100, 100, 800, 600, SDL_WINDOW_SHOWN);

	SDL_Surface* surface_window = SDL_GetWindowSurface(window);
	
	SDL_Surface* surface_test = SDL_LoadBMP("1.bmp");
	SDL_BlitSurface(surface_test, NULL, surface_window, NULL);

	SDL_UpdateWindowSurface(window);

	SDL_Delay(3000);

	SDL_FreeSurface(surface_test);
	SDL_FreeSurface(surface_window);

	SDL_DestroyWindow(window);
	SDL_Quit();
	return 0;
}

编译:

gcc -o test2 test2.c `pkg-config --libs --cflags sdl2`

离线

页脚