Update SDL2 to version 2.28.1.

This commit is contained in:
Sasha Szpakowski
2023-08-31 22:21:03 -03:00
parent 99b2757fc5
commit a82fcdd079
1394 changed files with 313046 additions and 190617 deletions
+25 -26
View File
@@ -1,5 +1,5 @@
/*
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -30,10 +30,9 @@ static int done = SDL_FALSE;
static int frame_number = 0;
static int width = 640;
static int height = 480;
static int max_frames = 200;
static unsigned int max_frames = 200;
void
draw()
void draw()
{
SDL_Rect Rect;
@@ -51,10 +50,9 @@ draw()
SDL_RenderPresent(renderer);
}
void
save_surface_to_bmp()
void save_surface_to_bmp()
{
SDL_Surface* surface;
SDL_Surface *surface;
Uint32 r_mask, g_mask, b_mask, a_mask;
Uint32 pixel_format;
char file[128];
@@ -66,22 +64,21 @@ save_surface_to_bmp()
surface = SDL_CreateRGBSurface(0, width, height, bbp, r_mask, g_mask, b_mask, a_mask);
SDL_RenderReadPixels(renderer, NULL, pixel_format, (void*)surface->pixels, surface->pitch);
SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp",
SDL_GetWindowID(window), ++frame_number);
SDL_snprintf(file, sizeof(file), "SDL_window%" SDL_PRIs32 "-%8.8d.bmp",
SDL_GetWindowID(window), ++frame_number);
SDL_SaveBMP(surface, file);
SDL_FreeSurface(surface);
}
void
loop()
void loop()
{
SDL_Event event;
/* Check for events */
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
case SDL_QUIT:
done = SDL_TRUE;
break;
}
@@ -97,10 +94,11 @@ loop()
#endif
}
int
main(int argc, char *argv[])
int main(int argc, char *argv[])
{
#ifndef __EMSCRIPTEN__
Uint32 then, now, frames;
#endif
/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
@@ -108,26 +106,25 @@ main(int argc, char *argv[])
/* Force the offscreen renderer, if it cannot be created then fail out */
if (SDL_VideoInit("offscreen") < 0) {
SDL_Log("Couldn't initialize the offscreen video driver: %s\n",
SDL_GetError());
SDL_GetError());
return SDL_FALSE;
}
/* If OPENGL fails to init it will fallback to using a framebuffer for rendering */
/* If OPENGL fails to init it will fallback to using a framebuffer for rendering */
window = SDL_CreateWindow("Offscreen Test",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
width, height, 0);
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
width, height, 0);
if (!window) {
SDL_Log("Couldn't create window: %s\n",
SDL_GetError());
if (window == NULL) {
SDL_Log("Couldn't create window: %s\n", SDL_GetError());
return SDL_FALSE;
}
renderer = SDL_CreateRenderer(window, -1, 0);
if (!renderer) {
if (renderer == NULL) {
SDL_Log("Couldn't create renderer: %s\n",
SDL_GetError());
SDL_GetError());
return SDL_FALSE;
}
@@ -135,12 +132,14 @@ main(int argc, char *argv[])
srand((unsigned int)time(NULL));
#ifndef __EMSCRIPTEN__
/* Main render loop */
frames = 0;
then = SDL_GetTicks();
done = 0;
#endif
SDL_Log("Rendering %i frames offscreen\n", max_frames);
SDL_Log("Rendering %u frames offscreen\n", max_frames);
#ifdef __EMSCRIPTEN__
emscripten_set_main_loop(loop, 0, 1);
@@ -153,8 +152,8 @@ main(int argc, char *argv[])
if (frames % (max_frames / 10) == 0) {
now = SDL_GetTicks();
if (now > then) {
double fps = ((double) frames * 1000) / (now - then);
SDL_Log("Frames remaining: %i rendering at %2.2f frames per second\n", max_frames - frames, fps);
double fps = ((double)frames * 1000) / (now - then);
SDL_Log("Frames remaining: %" SDL_PRIu32 " rendering at %2.2f frames per second\n", max_frames - frames, fps);
}
}
}