这篇文章实际和学习笔记3和4差不多,未来需要深入理解window, render, texture, surface等概念。
#include "SDL.h"
struct
{
Uint32 pixformat;
int w, h;
Uint8 *data;
}frame;
int screen_width = 0;
int screen_height = 0;
int status = 0; // 1: request to stop; 2: stop
SDL_Texture *p_texture = NULL;
SDL_Renderer *p_render = NULL;
static void quit(int rc)
{
SDL_Quit();
exit(rc);
}
void fill_color_rgba8888()
{
static Uint8 r = 0, g = 0, b = 0, a = 0;
r += 10, g += 15, b += 20, a += 5;
Uint32 *pdst = (Uint32 *)frame.data;
Uint32 color = (r << 24) | (g << 16) | (b << 8) | a;
for (int i = 0; i < frame.w*frame.h; i++)
{
*pdst++ = color;
}
}
int SDLCALL video_process(void * data)
{
int ret;
while (1)
{
if (1 == status) // request to stop
{