Compare commits

...

9 Commits

Author SHA1 Message Date
Arias800 36a3959bde
Merge d8d91934c6 into 88a01fbc96 2024-09-19 15:42:06 -03:00
Ozkan Sezer 88a01fbc96 testautomation_stdlib.c: fix -Wformat warnings from mingw with %lld/%llu
i.e.:  unknown conversion type character 'l' in format
See https://github.com/libsdl-org/SDL/pull/10789#issuecomment-2354011906
2024-09-19 20:37:11 +03:00
Ryan C. Gordon b4e2777820
examples/renderer/03-lines: Fix compiler warning on Visual Studio. 2024-09-19 13:31:24 -04:00
Ryan C. Gordon 2e3e5abd7d
examples/renderer/03-lines: use a gray background. 2024-09-19 12:58:37 -04:00
Frank Praznik fd0ce75e2e tests: Fix tests when run with the --high-pixel-density flag
Scales pointer coordinates where needed to fix the following tests when run with the --high-pixel-density flag:

- testaudio
- testaudiostreamdynamicresample
- testhittesting
- testintersections
- testmanymouse
- testoverlay
- testwm
2024-09-19 12:54:13 -04:00
Ryan C. Gordon 745d5e4991
examples/renderer/03-lines: Make this less obnoxious to look at. 2024-09-19 12:52:04 -04:00
Ryan C. Gordon 1b266ec13d
examples: added renderer/03-lines 2024-09-19 12:16:12 -04:00
Arias800 d8d91934c6
Update SDL_gamepad_db.h 2024-09-10 09:36:48 +02:00
Arias800 a00861d846
Add two more mapping for Nvidia controller (2019)
0500b30c550900001472000001000000 is the ID when the controller is connected via Bluetooth and 0300b30c550900001472000011010000 is for USB mode.

Tested by setting "SDL_GAMECONTROLLERCONFIG" in some games.
2024-07-22 18:18:09 +02:00
12 changed files with 164 additions and 29 deletions

View File

@ -122,6 +122,7 @@ endmacro()
add_sdl_example_executable(renderer-clear SOURCES renderer/01-clear/renderer-clear.c) add_sdl_example_executable(renderer-clear SOURCES renderer/01-clear/renderer-clear.c)
add_sdl_example_executable(renderer-primitives SOURCES renderer/02-primitives/renderer-primitives.c) add_sdl_example_executable(renderer-primitives SOURCES renderer/02-primitives/renderer-primitives.c)
add_sdl_example_executable(renderer-lines SOURCES renderer/03-lines/renderer-lines.c)
add_sdl_example_executable(audio-simple-playback SOURCES audio/01-simple-playback/simple-playback.c) add_sdl_example_executable(audio-simple-playback SOURCES audio/01-simple-playback/simple-playback.c)
add_sdl_example_executable(audio-simple-playback-callback SOURCES audio/02-simple-playback-callback/simple-playback-callback.c) add_sdl_example_executable(audio-simple-playback-callback SOURCES audio/02-simple-playback-callback/simple-playback-callback.c)
add_sdl_example_executable(audio-load-wav SOURCES audio/03-load-wav/load-wav.c DATAFILES ${CMAKE_CURRENT_SOURCE_DIR}/../test/sample.wav) add_sdl_example_executable(audio-load-wav SOURCES audio/03-load-wav/load-wav.c DATAFILES ${CMAKE_CURRENT_SOURCE_DIR}/../test/sample.wav)

View File

@ -0,0 +1,3 @@
This example creates an SDL window and renderer, and then draws a something
roughly like a Christmas tree with nothing but lines, every frame.

View File

@ -0,0 +1,93 @@
/*
* This example creates an SDL window and renderer, and then draws some lines
* to it every frame.
*
* This code is public domain. Feel free to use it for any purpose!
*/
#define SDL_MAIN_USE_CALLBACKS 1 /* use the callbacks instead of main() */
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
/* We will use this renderer to draw into this window every frame. */
static SDL_Window *window = NULL;
static SDL_Renderer *renderer = NULL;
/* This function runs once at startup. */
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
{
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't initialize SDL!", SDL_GetError(), NULL);
return SDL_APP_FAILURE;
}
if (!SDL_CreateWindowAndRenderer("examples/renderer/lines", 640, 480, 0, &window, &renderer)) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't create window/renderer!", SDL_GetError(), NULL);
return SDL_APP_FAILURE;
}
SDL_srand(0); /* seed the random number generator */
return SDL_APP_CONTINUE; /* carry on with the program! */
}
/* This function runs when a new event (mouse input, keypresses, etc) occurs. */
SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
{
if (event->type == SDL_EVENT_QUIT) {
return SDL_APP_SUCCESS; /* end the program, reporting success to the OS. */
}
return SDL_APP_CONTINUE; /* carry on with the program! */
}
/* This function runs once per frame, and is the heart of the program. */
SDL_AppResult SDL_AppIterate(void *appstate)
{
int i;
/* Lines (line segments, really) are drawn in terms of points: a set of
X and Y coordinates, one set for each end of the line.
(0, 0) is the top left of the window, and larger numbers go down
and to the right. This isn't how geometry works, but this is pretty
standard in 2D graphics. */
static const SDL_FPoint line_points[] = {
{ 100, 354 }, { 220, 230 }, { 140, 230 }, { 320, 100 }, { 500, 230 },
{ 420, 230 }, { 540, 354 }, { 400, 354 }, { 100, 354 }
};
/* as you can see from this, rendering draws over whatever was drawn before it. */
SDL_SetRenderDrawColor(renderer, 100, 100, 100, 255); /* black, full alpha */
SDL_RenderClear(renderer); /* start with a blank canvas. */
/* You can draw lines, one at a time, like these brown ones... */
SDL_SetRenderDrawColor(renderer, 127, 49, 32, 255);
SDL_RenderLine(renderer, 240, 450, 400, 450);
SDL_RenderLine(renderer, 240, 356, 400, 356);
SDL_RenderLine(renderer, 240, 356, 240, 450);
SDL_RenderLine(renderer, 400, 356, 400, 450);
/* You can also draw a series of connected lines in a single batch... */
SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
SDL_RenderLines(renderer, line_points, SDL_arraysize(line_points));
/* here's a bunch of lines drawn out from a center point in a circle. */
/* we randomize the color of each line, so it functions as animation. */
for (i = 0; i < 360; i++) {
const float size = 30.0f;
const float x = 320.0f;
const float y = 95.0f - (size / 2.0f);
SDL_SetRenderDrawColor(renderer, SDL_rand(256), SDL_rand(256), SDL_rand(256), 255);
SDL_RenderLine(renderer, x, y, x + SDL_sinf((float) i) * size, y + SDL_cosf((float) i) * size);
}
SDL_RenderPresent(renderer); /* put it all on the screen! */
return SDL_APP_CONTINUE; /* carry on with the program! */
}
/* This function runs once at shutdown. */
void SDL_AppQuit(void *appstate)
{
/* SDL will clean up the window/renderer for us. */
}

View File

@ -621,7 +621,8 @@ static const char *s_GamepadMappings[] = {
"05000000d6200000ad0d000001000000,Moga Pro,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "05000000d6200000ad0d000001000000,Moga Pro,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,",
"030000006b140000010c000010010000,NACON GC-400ES,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "030000006b140000010c000010010000,NACON GC-400ES,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,",
"030000001008000001e5000010010000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,", "030000001008000001e5000010010000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,",
"03000000550900001472000011010000,NVIDIA Controller v01.04,a:b0,b:b1,back:b14,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b17,leftshoulder:b4,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,", "03000000550900001472000011010000,NVIDIA Controller v01.04,a:b0,b:b1,x:b2,y:b3,dpleft:h0.8,dpright:h0.2,dpup:h0.1,dpdown:h0.4,leftx:a0,lefty:a1,leftstick:b10,rightx:a2,righty:a5,rightstick:b11,leftshoulder:b5,lefttrigger:a3,rightshoulder:b6,righttrigger:a4,back:b7,start:b9,guide:b4,misc1:b8,",
"05000000550900001472000001000000,NVIDIA Controller v01.04,a:b0,b:b1,x:b2,y:b3,dpleft:h0.8,dpright:h0.2,dpup:h0.1,dpdown:h0.4,leftx:a0,lefty:a1,leftstick:b10,rightx:a2,righty:a5,rightstick:b11,leftshoulder:b5,lefttrigger:a3,rightshoulder:b6,righttrigger:a4,back:b7,start:b9,guide:b4,misc1:b8,",
"03000000550900001072000011010000,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b13,leftshoulder:b4,leftstick:b8,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,", "03000000550900001072000011010000,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b13,leftshoulder:b4,leftstick:b8,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,",
"030000004b120000014d000000010000,NYKO AIRFLO EX,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,", "030000004b120000014d000000010000,NYKO AIRFLO EX,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,",
"03000000451300000830000010010000,NYKO CORE,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "03000000451300000830000010010000,NYKO CORE,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",

View File

@ -1119,6 +1119,7 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
Thing *thing = NULL; Thing *thing = NULL;
saw_event = true; saw_event = true;
SDL_ConvertEventToRenderCoordinates(SDL_GetRenderer(SDL_GetWindowFromEvent(event)), event);
switch (event->type) { switch (event->type) {
case SDL_EVENT_MOUSE_MOTION: case SDL_EVENT_MOUSE_MOTION:

View File

@ -184,6 +184,20 @@ static const char *AudioChansToStr(const int channels)
return "?"; return "?";
} }
static void scale_mouse_coords(SDL_FPoint *p)
{
SDL_Window *window = SDL_GetMouseFocus();
if (window) {
int w, p_w;
float scale;
SDL_GetWindowSize(window, &w, NULL);
SDL_GetWindowSizeInPixels(window, &p_w, NULL);
scale = (float)p_w / (float)w;
p->x *= scale;
p->y *= scale;
}
}
static void loop(void) static void loop(void)
{ {
int i, j; int i, j;
@ -228,6 +242,7 @@ static void loop(void)
} }
if (SDL_GetMouseState(&p.x, &p.y) & SDL_BUTTON_LMASK) { if (SDL_GetMouseState(&p.x, &p.y) & SDL_BUTTON_LMASK) {
scale_mouse_coords(&p);
if (active_slider == -1) { if (active_slider == -1) {
for (i = 0; i < NUM_SLIDERS; ++i) { for (i = 0; i < NUM_SLIDERS; ++i) {
if (SDL_PointInRectFloat(&p, &sliders[i].area)) { if (SDL_PointInRectFloat(&p, &sliders[i].area)) {

View File

@ -714,6 +714,16 @@ static int SDLCALL stdlib_getsetenv(void *arg)
#endif #endif
#endif #endif
#ifndef SDL_PLATFORM_WINDOWS
#define FMT_PRILLd "%lld"
#define FMT_PRILLu "%llu"
#else
/* make sure long long is 64 bits */
SDL_COMPILE_TIME_ASSERT(longlong_size64, sizeof(long long) == 8);
#define FMT_PRILLd "%I64d"
#define FMT_PRILLu "%I64u"
#endif
/** /**
* Call to SDL_sscanf * Call to SDL_sscanf
*/ */
@ -781,7 +791,7 @@ static int SDLCALL stdlib_sscanf(void *arg)
SIZED_TEST_CASE(short, short, "%hd") SIZED_TEST_CASE(short, short, "%hd")
SIZED_TEST_CASE(long, long, "%ld") SIZED_TEST_CASE(long, long, "%ld")
SIZED_TEST_CASE(long long, long_long, "%lld") SIZED_TEST_CASE(long long, long_long, FMT_PRILLd)
size_output = 123; size_output = 123;
expected_size_output = ~((size_t)0); expected_size_output = ~((size_t)0);
@ -1301,26 +1311,26 @@ static int SDLCALL stdlib_strtox(void *arg)
} while (0) } while (0)
// infer decimal // infer decimal
STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, "%llu", "\t 123abcxyz", 0, 123, 6); // skip leading space STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, FMT_PRILLu, "\t 123abcxyz", 0, 123, 6); // skip leading space
STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, "%llu", "+123abcxyz", 0, 123, 4); STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, FMT_PRILLu, "+123abcxyz", 0, 123, 4);
STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, "%llu", "+123abcxyz", 0, 123, 4); STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, FMT_PRILLu, "+123abcxyz", 0, 123, 4);
STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, "%llu", "-123abcxyz", 0, -123, 4); STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, FMT_PRILLu, "-123abcxyz", 0, -123, 4);
STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, "%llu", "9999999999999999999999999999999999999999abcxyz", 0, ullong_max, 40); STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, FMT_PRILLu, "9999999999999999999999999999999999999999abcxyz", 0, ullong_max, 40);
// infer hexadecimal // infer hexadecimal
STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, "%llu", "0x123abcxyz", 0, 0x123abc, 8); STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, FMT_PRILLu, "0x123abcxyz", 0, 0x123abc, 8);
STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, "%llu", "0X123ABCXYZ", 0, 0x123abc, 8); // uppercase X STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, FMT_PRILLu, "0X123ABCXYZ", 0, 0x123abc, 8); // uppercase X
// infer octal // infer octal
STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, "%llu", "0123abcxyz", 0, 0123, 4); STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, FMT_PRILLu, "0123abcxyz", 0, 0123, 4);
// arbitrary bases // arbitrary bases
STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, "%llu", "00110011", 2, 51, 8); STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, FMT_PRILLu, "00110011", 2, 51, 8);
STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, "%llu", "-uvwxyz", 32, -991, 3); STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, FMT_PRILLu, "-uvwxyz", 32, -991, 3);
STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, "%llu", "ZzZzZzZzZzZzZzZzZzZzZzZzZ", 36, ullong_max, 25); STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, FMT_PRILLu, "ZzZzZzZzZzZzZzZzZzZzZzZzZ", 36, ullong_max, 25);
STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, "%llu", "-0", 10, 0, 2); STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, FMT_PRILLu, "-0", 10, 0, 2);
STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, "%llu", " - 1", 0, 0, 0); // invalid input STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, FMT_PRILLu, " - 1", 0, 0, 0); // invalid input
// We know that SDL_strtol, SDL_strtoul and SDL_strtoll share the same code path as SDL_strtoull under the hood, // We know that SDL_strtol, SDL_strtoul and SDL_strtoll share the same code path as SDL_strtoull under the hood,
// so the most interesting test cases are those close to the bounds of the integer type. // so the most interesting test cases are those close to the bounds of the integer type.
@ -1342,15 +1352,15 @@ static int SDLCALL stdlib_strtox(void *arg)
} }
if (sizeof(long long) == 8) { if (sizeof(long long) == 8) {
STRTOX_TEST_CASE(SDL_strtoll, long long, "%lld", "9223372036854775807", 10, 9223372036854775807LL, 19); STRTOX_TEST_CASE(SDL_strtoll, long long, FMT_PRILLd, "9223372036854775807", 10, 9223372036854775807LL, 19);
STRTOX_TEST_CASE(SDL_strtoll, long long, "%lld", "9223372036854775808", 10, 9223372036854775807LL, 19); STRTOX_TEST_CASE(SDL_strtoll, long long, FMT_PRILLd, "9223372036854775808", 10, 9223372036854775807LL, 19);
STRTOX_TEST_CASE(SDL_strtoll, long long, "%lld", "-9223372036854775808", 10, -9223372036854775807LL - 1, 20); STRTOX_TEST_CASE(SDL_strtoll, long long, FMT_PRILLd, "-9223372036854775808", 10, -9223372036854775807LL - 1, 20);
STRTOX_TEST_CASE(SDL_strtoll, long long, "%lld", "-9223372036854775809", 10, -9223372036854775807LL - 1, 20); STRTOX_TEST_CASE(SDL_strtoll, long long, FMT_PRILLd, "-9223372036854775809", 10, -9223372036854775807LL - 1, 20);
STRTOX_TEST_CASE(SDL_strtoll, long long, "%lld", "-9999999999999999999999999999999999999999", 10, -9223372036854775807LL - 1, 41); STRTOX_TEST_CASE(SDL_strtoll, long long, FMT_PRILLd, "-9999999999999999999999999999999999999999", 10, -9223372036854775807LL - 1, 41);
STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, "%llu", "18446744073709551615", 10, 18446744073709551615ULL, 20); STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, FMT_PRILLd, "18446744073709551615", 10, 18446744073709551615ULL, 20);
STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, "%llu", "18446744073709551616", 10, 18446744073709551615ULL, 20); STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, FMT_PRILLd, "18446744073709551616", 10, 18446744073709551615ULL, 20);
STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, "%llu", "-18446744073709551615", 10, 1, 21); STRTOX_TEST_CASE(SDL_strtoull, unsigned long long, FMT_PRILLd, "-18446744073709551615", 10, 1, 21);
} }
#undef STRTOX_TEST_CASE #undef STRTOX_TEST_CASE

View File

@ -33,17 +33,25 @@ static SDL_HitTestResult SDLCALL
hitTest(SDL_Window *window, const SDL_Point *pt, void *data) hitTest(SDL_Window *window, const SDL_Point *pt, void *data)
{ {
int i; int i;
int w, h; int w, h, p_w;
SDL_Point adj_pt;
float scale;
SDL_GetWindowSize(window, &w, &h);
SDL_GetWindowSizeInPixels(window, &p_w, NULL);
scale = (float)p_w / (float)w;
adj_pt.x = (int)SDL_floorf(pt->x * scale);
adj_pt.y = (int)SDL_floorf(pt->y * scale);
for (i = 0; i < numareas; i++) { for (i = 0; i < numareas; i++) {
if (SDL_PointInRect(pt, &areas[i])) { if (SDL_PointInRect(&adj_pt, &areas[i])) {
SDL_Log("HIT-TEST: DRAGGABLE\n"); SDL_Log("HIT-TEST: DRAGGABLE\n");
return SDL_HITTEST_DRAGGABLE; return SDL_HITTEST_DRAGGABLE;
} }
} }
SDL_GetWindowSize(window, &w, &h);
#define REPORT_RESIZE_HIT(name) \ #define REPORT_RESIZE_HIT(name) \
{ \ { \
SDL_Log("HIT-TEST: RESIZE_" #name "\n"); \ SDL_Log("HIT-TEST: RESIZE_" #name "\n"); \

View File

@ -211,6 +211,7 @@ static void loop(void *arg)
/* Check for events */ /* Check for events */
while (SDL_PollEvent(&event)) { while (SDL_PollEvent(&event)) {
SDLTest_CommonEvent(state, &event, done); SDLTest_CommonEvent(state, &event, done);
SDL_ConvertEventToRenderCoordinates(SDL_GetRenderer(SDL_GetWindowFromEvent(&event)), &event);
switch (event.type) { switch (event.type) {
case SDL_EVENT_MOUSE_BUTTON_DOWN: case SDL_EVENT_MOUSE_BUTTON_DOWN:
mouse_begin_x = event.button.x; mouse_begin_x = event.button.x;

View File

@ -184,7 +184,7 @@ static void HandleMouseAdded(SDL_MouseID instance_id)
SDL_Window *window = state->windows[0]; SDL_Window *window = state->windows[0];
int i, w = 0, h = 0; int i, w = 0, h = 0;
SDL_GetWindowSize(window, &w, &h); SDL_GetWindowSizeInPixels(window, &w, &h);
for (i = 0; i < SDL_arraysize(mice); ++i) { for (i = 0; i < SDL_arraysize(mice); ++i) {
MouseState *mouse_state = &mice[i]; MouseState *mouse_state = &mice[i];
@ -237,7 +237,7 @@ static void HandleMouseMotion(SDL_MouseMotionEvent *event)
ActivateMouse(event->which); ActivateMouse(event->which);
SDL_GetWindowSize(window, &w, &h); SDL_GetWindowSizeInPixels(window, &w, &h);
for (i = 0; i < SDL_arraysize(mice); ++i) { for (i = 0; i < SDL_arraysize(mice); ++i) {
MouseState *mouse_state = &mice[i]; MouseState *mouse_state = &mice[i];

View File

@ -255,6 +255,7 @@ static void loop(void)
/* Check for events */ /* Check for events */
while (SDL_PollEvent(&event)) { while (SDL_PollEvent(&event)) {
SDLTest_CommonEvent(state, &event, &done); SDLTest_CommonEvent(state, &event, &done);
SDL_ConvertEventToRenderCoordinates(SDL_GetRenderer(SDL_GetWindowFromEvent(&event)), &event);
switch (event.type) { switch (event.type) {
case SDL_EVENT_WINDOW_RESIZED: case SDL_EVENT_WINDOW_RESIZED:

View File

@ -165,6 +165,7 @@ static void loop(void)
while (SDL_PollEvent(&event)) { while (SDL_PollEvent(&event)) {
SDLTest_CommonEvent(state, &event, &done); SDLTest_CommonEvent(state, &event, &done);
SDL_ConvertEventToRenderCoordinates(SDL_GetRenderer(SDL_GetWindowFromEvent(&event)), &event);
if (event.type == SDL_EVENT_WINDOW_RESIZED) { if (event.type == SDL_EVENT_WINDOW_RESIZED) {
SDL_Window *window = SDL_GetWindowFromEvent(&event); SDL_Window *window = SDL_GetWindowFromEvent(&event);