c_cpp SDL测试代码

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp SDL测试代码相关的知识,希望对你有一定的参考价值。

// Example program:
// Using SDL2 to create an application window

#include <SDL.h>
#include <stdio.h>

int main(int argc, char* argv[]) {

	SDL_Window *window;                    // Declare a pointer

	SDL_Init(SDL_INIT_VIDEO);              // Initialize SDL2

										   // Create an application window with the following settings:
	window = SDL_CreateWindow(
		"An SDL2 window",                  // window title
		SDL_WINDOWPOS_UNDEFINED,           // initial x position
		SDL_WINDOWPOS_UNDEFINED,           // initial y position
		640,                               // width, in pixels
		480,                               // height, in pixels
		SDL_WINDOW_OPENGL                  // flags - see below
	);

	// Check that the window was successfully created
	if (window == NULL) {
		// In the case that the window could not be made...
		printf("Could not create window: %s\n", SDL_GetError());
		return 1;
	}

	// The window is open: could enter program loop here (see SDL_PollEvent())

	SDL_Delay(3000);  // Pause execution for 3000 milliseconds, for example

					  // Close and destroy the window
	SDL_DestroyWindow(window);

	// Clean up
	SDL_Quit();
	return 0;
}

以上是关于c_cpp SDL测试代码的主要内容,如果未能解决你的问题,请参考以下文章

c_cpp SDL_v3d2.c

无法在 SDL2 中运行 OpenGL 示例

SDL图解

SDL 基准声音

golang调用sdl2,键盘和鼠标事件

c_cpp 用于轴上矢量测试的慢速SSE代码