forked from Green-Sky/tomato
Merge commit '852f2a6343518919e5ca8d3c1bbcab9f493e3cd8'
This commit is contained in:
23
external/sdl/SDL/test/testgeometry.c
vendored
23
external/sdl/SDL/test/testgeometry.c
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 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
|
||||
@ -29,6 +29,8 @@ static SDL_Texture **sprites;
|
||||
static SDL_BlendMode blendMode = SDL_BLENDMODE_NONE;
|
||||
static float angle = 0.0f;
|
||||
static int sprite_w, sprite_h;
|
||||
static int translate_cx = 0;
|
||||
static int translate_cy = 0;
|
||||
|
||||
static int done;
|
||||
|
||||
@ -92,6 +94,18 @@ static void loop(void)
|
||||
angle += yrel;
|
||||
}
|
||||
}
|
||||
} else if (event.type == SDL_EVENT_KEY_DOWN) {
|
||||
if (event.key.keysym.sym == SDLK_LEFT) {
|
||||
translate_cx -= 1;
|
||||
} else if (event.key.keysym.sym == SDLK_RIGHT) {
|
||||
translate_cx += 1;
|
||||
} else if (event.key.keysym.sym == SDLK_UP) {
|
||||
translate_cy -= 1;
|
||||
} else if (event.key.keysym.sym == SDLK_DOWN) {
|
||||
translate_cy += 1;
|
||||
} else {
|
||||
SDLTest_CommonEvent(state, &event, &done);
|
||||
}
|
||||
} else {
|
||||
SDLTest_CommonEvent(state, &event, &done);
|
||||
}
|
||||
@ -119,6 +133,9 @@ static void loop(void)
|
||||
cy = viewport.y + viewport.h / 2;
|
||||
d = (viewport.w + viewport.h) / 5.f;
|
||||
|
||||
cx += translate_cx;
|
||||
cy += translate_cy;
|
||||
|
||||
a = (angle * 3.1415f) / 180.0f;
|
||||
verts[0].position.x = cx + d * SDL_cosf(a);
|
||||
verts[0].position.y = cy + d * SDL_sinf(a);
|
||||
@ -173,7 +190,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
|
||||
if (state == NULL) {
|
||||
if (!state) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -224,7 +241,7 @@ int main(int argc, char *argv[])
|
||||
/* Create the windows, initialize the renderers, and load the textures */
|
||||
sprites =
|
||||
(SDL_Texture **)SDL_malloc(state->num_windows * sizeof(*sprites));
|
||||
if (sprites == NULL) {
|
||||
if (!sprites) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
|
||||
quit(2);
|
||||
}
|
||||
|
Reference in New Issue
Block a user