mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-03-20 15:51:07 +01:00
Add SDL Pinch events (#9445)
This commit is contained in:
@@ -30,6 +30,7 @@ static SDL_BlendMode blendMode = SDL_BLENDMODE_NONE;
|
||||
static float angle = 0.0f;
|
||||
static int translate_cx = 0;
|
||||
static int translate_cy = 0;
|
||||
static float pinch_scale = 1.0f;
|
||||
|
||||
static int done;
|
||||
|
||||
@@ -103,11 +104,14 @@ static void loop(void)
|
||||
} else if (event.key.key == SDLK_DOWN) {
|
||||
translate_cy += 1;
|
||||
} else {
|
||||
SDLTest_CommonEvent(state, &event, &done);
|
||||
|
||||
}
|
||||
} else {
|
||||
SDLTest_CommonEvent(state, &event, &done);
|
||||
} else if (event.type == SDL_EVENT_PINCH_BEGIN) {
|
||||
} else if (event.type == SDL_EVENT_PINCH_UPDATE) {
|
||||
pinch_scale *= event.pinch.scale;
|
||||
} else if (event.type == SDL_EVENT_PINCH_END) {
|
||||
}
|
||||
SDLTest_CommonEvent(state, &event, &done);
|
||||
}
|
||||
|
||||
for (i = 0; i < state->num_windows; ++i) {
|
||||
@@ -136,24 +140,24 @@ static void loop(void)
|
||||
cy += translate_cy;
|
||||
|
||||
a = (angle * SDL_PI_F) / 180.0f;
|
||||
verts[0].position.x = cx + d * SDL_cosf(a);
|
||||
verts[0].position.y = cy + d * SDL_sinf(a);
|
||||
verts[0].position.x = cx + (d * SDL_cosf(a)) * pinch_scale;
|
||||
verts[0].position.y = cy + (d * SDL_sinf(a)) * pinch_scale;
|
||||
verts[0].color.r = 1.0f;
|
||||
verts[0].color.g = 0;
|
||||
verts[0].color.b = 0;
|
||||
verts[0].color.a = 1.0f;
|
||||
|
||||
a = ((angle + 120) * SDL_PI_F) / 180.0f;
|
||||
verts[1].position.x = cx + d * SDL_cosf(a);
|
||||
verts[1].position.y = cy + d * SDL_sinf(a);
|
||||
verts[1].position.x = cx + (d * SDL_cosf(a)) * pinch_scale;
|
||||
verts[1].position.y = cy + (d * SDL_sinf(a)) * pinch_scale;
|
||||
verts[1].color.r = 0;
|
||||
verts[1].color.g = 1.0f;
|
||||
verts[1].color.b = 0;
|
||||
verts[1].color.a = 1.0f;
|
||||
|
||||
a = ((angle + 240) * SDL_PI_F) / 180.0f;
|
||||
verts[2].position.x = cx + d * SDL_cosf(a);
|
||||
verts[2].position.y = cy + d * SDL_sinf(a);
|
||||
verts[2].position.x = cx + (d * SDL_cosf(a)) * pinch_scale;
|
||||
verts[2].position.y = cy + (d * SDL_sinf(a)) * pinch_scale;
|
||||
verts[2].color.r = 0;
|
||||
verts[2].color.g = 0;
|
||||
verts[2].color.b = 1.0f;
|
||||
|
||||
Reference in New Issue
Block a user