mirror of
https://github.com/love2d/megasource.git
synced 2026-08-17 19:24:09 +02:00
update SDL3 to latest commit
This commit is contained in:
@@ -35,7 +35,7 @@ typedef struct
|
||||
|
||||
static DrawState *drawstates;
|
||||
static int done;
|
||||
static SDL_bool test_composite = SDL_FALSE;
|
||||
static bool test_composite = false;
|
||||
|
||||
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
|
||||
static void
|
||||
@@ -48,7 +48,7 @@ quit(int rc)
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
static bool
|
||||
DrawComposite(DrawState *s)
|
||||
{
|
||||
SDL_Rect viewport;
|
||||
@@ -56,7 +56,7 @@ DrawComposite(DrawState *s)
|
||||
SDL_Texture *target;
|
||||
SDL_Surface *surface;
|
||||
|
||||
static SDL_bool blend_tested = SDL_FALSE;
|
||||
static bool blend_tested = false;
|
||||
if (!blend_tested) {
|
||||
SDL_Texture *A, *B;
|
||||
|
||||
@@ -78,7 +78,7 @@ DrawComposite(DrawState *s)
|
||||
surface = SDL_RenderReadPixels(s->renderer, NULL);
|
||||
if (surface) {
|
||||
Uint8 r, g, b, a;
|
||||
if (SDL_ReadSurfacePixel(surface, 0, 0, &r, &g, &b, &a) == 0) {
|
||||
if (SDL_ReadSurfacePixel(surface, 0, 0, &r, &g, &b, &a)) {
|
||||
SDL_Log("Blended pixel: 0x%.2x%.2x%.2x%.2x\n", r, g, b, a);
|
||||
}
|
||||
SDL_DestroySurface(surface);
|
||||
@@ -86,7 +86,7 @@ DrawComposite(DrawState *s)
|
||||
|
||||
SDL_DestroyTexture(A);
|
||||
SDL_DestroyTexture(B);
|
||||
blend_tested = SDL_TRUE;
|
||||
blend_tested = true;
|
||||
}
|
||||
|
||||
SDL_GetRenderViewport(s->renderer, &viewport);
|
||||
@@ -135,10 +135,10 @@ DrawComposite(DrawState *s)
|
||||
|
||||
/* Update the screen! */
|
||||
SDL_RenderPresent(s->renderer);
|
||||
return SDL_TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
static bool
|
||||
Draw(DrawState *s)
|
||||
{
|
||||
SDL_Rect viewport;
|
||||
@@ -149,7 +149,7 @@ Draw(DrawState *s)
|
||||
target = SDL_CreateTexture(s->renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, viewport.w, viewport.h);
|
||||
if (!target) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create render target texture: %s\n", SDL_GetError());
|
||||
return SDL_FALSE;
|
||||
return false;
|
||||
}
|
||||
SDL_SetRenderTarget(s->renderer, target);
|
||||
|
||||
@@ -179,7 +179,7 @@ Draw(DrawState *s)
|
||||
|
||||
/* Update the screen! */
|
||||
SDL_RenderPresent(s->renderer);
|
||||
return SDL_TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void loop(void)
|
||||
@@ -218,14 +218,12 @@ int main(int argc, char *argv[])
|
||||
int frames;
|
||||
Uint64 then, now;
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
|
||||
if (!state) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 1; i < argc;) {
|
||||
int consumed;
|
||||
|
||||
@@ -233,7 +231,7 @@ int main(int argc, char *argv[])
|
||||
if (consumed == 0) {
|
||||
consumed = -1;
|
||||
if (SDL_strcasecmp(argv[i], "--composite") == 0) {
|
||||
test_composite = SDL_TRUE;
|
||||
test_composite = true;
|
||||
consumed = 1;
|
||||
}
|
||||
}
|
||||
@@ -251,22 +249,19 @@ int main(int argc, char *argv[])
|
||||
drawstates = SDL_stack_alloc(DrawState, state->num_windows);
|
||||
for (i = 0; i < state->num_windows; ++i) {
|
||||
DrawState *drawstate = &drawstates[i];
|
||||
int w, h;
|
||||
|
||||
drawstate->window = state->windows[i];
|
||||
drawstate->renderer = state->renderers[i];
|
||||
if (test_composite) {
|
||||
drawstate->sprite = LoadTexture(drawstate->renderer, "icon-alpha.bmp", SDL_TRUE, NULL, NULL);
|
||||
drawstate->sprite = LoadTexture(drawstate->renderer, "icon-alpha.bmp", true, NULL, NULL);
|
||||
} else {
|
||||
drawstate->sprite = LoadTexture(drawstate->renderer, "icon.bmp", SDL_TRUE, NULL, NULL);
|
||||
drawstate->sprite = LoadTexture(drawstate->renderer, "icon.bmp", true, NULL, NULL);
|
||||
}
|
||||
drawstate->background = LoadTexture(drawstate->renderer, "sample.bmp", SDL_FALSE, NULL, NULL);
|
||||
drawstate->background = LoadTexture(drawstate->renderer, "sample.bmp", false, NULL, NULL);
|
||||
if (!drawstate->sprite || !drawstate->background) {
|
||||
quit(2);
|
||||
}
|
||||
SDL_QueryTexture(drawstate->sprite, NULL, NULL, &w, &h);
|
||||
drawstate->sprite_rect.w = (float)w;
|
||||
drawstate->sprite_rect.h = (float)h;
|
||||
SDL_GetTextureSize(drawstate->sprite, &drawstate->sprite_rect.w, &drawstate->sprite_rect.h);
|
||||
drawstate->scale_direction = 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user