Update for SDL3 coding style (#6717)

I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base.

In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted.

The script I ran for the src directory is added as build-scripts/clang-format-src.sh

This fixes:
#6592
#6593
#6594
This commit is contained in:
Sam Lantinga
2022-11-30 12:51:59 -08:00
committed by GitHub
parent 14b902faca
commit 5750bcb174
781 changed files with 51659 additions and 55763 deletions

View File

@@ -30,8 +30,7 @@ static int width = 640;
static int height = 480;
static unsigned int max_frames = 200;
void
draw()
void draw()
{
SDL_Rect Rect;
@@ -49,10 +48,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];
@@ -62,7 +60,7 @@ save_surface_to_bmp()
SDL_PixelFormatEnumToMasks(pixel_format, &bbp, &r_mask, &g_mask, &b_mask, &a_mask);
surface = SDL_CreateRGBSurface(width, height, bbp, r_mask, g_mask, b_mask, a_mask);
SDL_RenderReadPixels(renderer, NULL, pixel_format, (void*)surface->pixels, surface->pitch);
SDL_RenderReadPixels(renderer, NULL, pixel_format, (void *)surface->pixels, surface->pitch);
SDL_snprintf(file, sizeof(file), "SDL_window%" SDL_PRIs32 "-%8.8d.bmp",
SDL_GetWindowID(window), ++frame_number);
@@ -71,15 +69,14 @@ save_surface_to_bmp()
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;
}
@@ -95,8 +92,7 @@ loop()
#endif
}
int
main(int argc, char *argv[])
int main(int argc, char *argv[])
{
#ifndef __EMSCRIPTEN__
Uint32 then, now, frames;
@@ -108,18 +104,18 @@ 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 == NULL) {
SDL_Log("Couldn't create window: %s\n",
SDL_GetError());
SDL_GetError());
return SDL_FALSE;
}
@@ -127,7 +123,7 @@ main(int argc, char *argv[])
if (renderer == NULL) {
SDL_Log("Couldn't create renderer: %s\n",
SDL_GetError());
SDL_GetError());
return SDL_FALSE;
}
@@ -155,7 +151,7 @@ main(int argc, char *argv[])
if (frames % (max_frames / 10) == 0) {
now = SDL_GetTicks();
if (now > then) {
double fps = ((double) frames * 1000) / (now - then);
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);
}
}