bracing style and attribute unused to void cast in libSDL display driver

pull/46/head
tarxvf 2021-08-25 02:02:31 -04:00 zatwierdzone przez Silvano Seva
rodzic 588265fa3d
commit 2ec8a3c264
1 zmienionych plików z 28 dodań i 15 usunięć

Wyświetl plik

@ -83,14 +83,16 @@ int screenshot_display(const char *filename)
/* Get information about texture we want to save */
st = SDL_QueryTexture(tex, NULL, NULL, &w, &h);
if (st != 0) {
if (st != 0)
{
SDL_Log("Failed querying texture: %s\n", SDL_GetError());
err++;
goto cleanup;
}
ren_tex = SDL_CreateTexture(ren, format, SDL_TEXTUREACCESS_TARGET, w, h);
if (!ren_tex) {
if (!ren_tex)
{
SDL_Log("Failed creating render texture: %s\n", SDL_GetError());
err++;
goto cleanup;
@ -101,7 +103,8 @@ int screenshot_display(const char *filename)
* can access
*/
st = SDL_SetRenderTarget(ren, ren_tex);
if (st != 0) {
if (st != 0)
{
SDL_Log("Failed setting render target: %s\n", SDL_GetError());
err++;
goto cleanup;
@ -109,34 +112,39 @@ int screenshot_display(const char *filename)
SDL_SetRenderDrawColor(ren, 0x00, 0x00, 0x00, 0x00);
SDL_RenderClear(ren);
st = SDL_RenderCopy(ren, tex, NULL, NULL);
if (st != 0) {
if (st != 0)
{
SDL_Log("Failed copying texture data: %s\n", SDL_GetError());
err++;
goto cleanup;
}
/* Create buffer to hold texture data and load it */
pixels = malloc(w * h * SDL_BYTESPERPIXEL(format));
if (!pixels) {
if (!pixels)
{
SDL_Log("Failed allocating memory\n");
err++;
goto cleanup;
}
st = SDL_RenderReadPixels(ren, NULL, format, pixels, w * SDL_BYTESPERPIXEL(format));
if (st != 0) {
if (st != 0)
{
SDL_Log("Failed reading pixel data: %s\n", SDL_GetError());
err++;
goto cleanup;
}
/* Copy pixel data over to surface */
surf = SDL_CreateRGBSurfaceWithFormatFrom(pixels, w, h, SDL_BITSPERPIXEL(format), w * SDL_BYTESPERPIXEL(format), format);
if (!surf) {
if (!surf)
{
SDL_Log("Failed creating new surface: %s\n", SDL_GetError());
err++;
goto cleanup;
}
/* Save result to an image */
st = SDL_SaveBMP(surf, filename);
if (st != 0) {
if (st != 0)
{
SDL_Log("Failed saving image: %s\n", SDL_GetError());
err++;
goto cleanup;
@ -156,9 +164,10 @@ cleanup:
* Internal helper function which fetches pixel at position (x, y) from framebuffer
* and returns it in SDL-compatible format, which is ARGB8888.
*/
uint32_t fetchPixelFromFb(__attribute__((unused)) unsigned int x,
__attribute__((unused)) unsigned int y)
uint32_t fetchPixelFromFb(unsigned int x, unsigned int y)
{
(void) x;
(void) y;
uint32_t pixel = 0;
#ifdef PIX_FMT_BW
@ -192,7 +201,8 @@ void display_init()
{
printf("SDL video init error!!\n");
} else
}
else
{
window = SDL_CreateWindow("OpenRTX",
@ -253,9 +263,10 @@ void display_terminate()
SDL_Quit();
}
void display_renderRows(__attribute__((unused)) uint8_t startRow,
__attribute__((unused)) uint8_t endRow)
void display_renderRows(uint8_t startRow, uint8_t endRow)
{
(void) startRow;
(void) endRow;
PIXEL_SIZE *pixels;
int pitch = 0;
if (SDL_LockTexture(displayTexture, NULL, (void **) &pixels, &pitch) < 0)
@ -267,8 +278,10 @@ void display_renderRows(__attribute__((unused)) uint8_t startRow,
uint16_t *fb = (uint16_t *) (frameBuffer);
memcpy(pixels, fb, sizeof(uint16_t) * SCREEN_HEIGHT * SCREEN_WIDTH);
#else
for (unsigned int x = 0; x < SCREEN_WIDTH; x++) {
for (unsigned int y = startRow; y < endRow; y++) {
for (unsigned int x = 0; x < SCREEN_WIDTH; x++)
{
for (unsigned int y = startRow; y < endRow; y++)
{
pixels[x + y * SCREEN_WIDTH] = fetchPixelFromFb(x, y);
}
}