您尚未登录。

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

super
会员
注册时间: 2019-11-22
已发帖子: 1
积分: 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`

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn