2016-07-13 17:34:06 +03:00
|
|
|
/*
|
2024-01-02 00:15:26 +03:00
|
|
|
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
2016-07-13 17:34:06 +03:00
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
warranty. In no event will the authors be held liable for any damages
|
|
|
|
arising from the use of this software.
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
including commercial applications, and to alter it and redistribute it
|
|
|
|
freely.
|
|
|
|
*/
|
|
|
|
|
2024-01-24 04:40:51 +03:00
|
|
|
#include <SDL3/SDL_test_common.h>
|
|
|
|
#include <SDL3/SDL_main.h>
|
|
|
|
|
|
|
|
#ifdef SDL_PLATFORM_EMSCRIPTEN
|
2016-07-13 17:34:06 +03:00
|
|
|
#include <emscripten/emscripten.h>
|
|
|
|
#endif
|
|
|
|
|
2024-01-24 04:40:51 +03:00
|
|
|
#include <stdlib.h>
|
2016-07-13 17:34:06 +03:00
|
|
|
|
|
|
|
/* Stolen from the mailing list */
|
|
|
|
/* Creates a new mouse cursor from an XPM */
|
|
|
|
|
|
|
|
/* XPM */
|
|
|
|
static const char *arrow[] = {
|
2022-11-30 23:51:59 +03:00
|
|
|
/* width height num_colors chars_per_pixel */
|
|
|
|
" 32 32 3 1",
|
|
|
|
/* colors */
|
|
|
|
"X c #000000",
|
|
|
|
". c #ffffff",
|
|
|
|
" c None",
|
|
|
|
/* pixels */
|
|
|
|
"X ",
|
|
|
|
"XX ",
|
|
|
|
"X.X ",
|
|
|
|
"X..X ",
|
|
|
|
"X...X ",
|
|
|
|
"X....X ",
|
|
|
|
"X.....X ",
|
|
|
|
"X......X ",
|
|
|
|
"X.......X ",
|
|
|
|
"X........X ",
|
|
|
|
"X.....XXXXX ",
|
|
|
|
"X..X..X ",
|
|
|
|
"X.X X..X ",
|
|
|
|
"XX X..X ",
|
|
|
|
"X X..X ",
|
|
|
|
" X..X ",
|
|
|
|
" X..X ",
|
|
|
|
" X..X ",
|
|
|
|
" XX ",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
"0,0"
|
|
|
|
};
|
|
|
|
|
2023-12-15 20:59:50 +03:00
|
|
|
static const char *cross[] = {
|
|
|
|
/* width height num_colors chars_per_pixel */
|
|
|
|
" 32 32 3 1",
|
|
|
|
/* colors */
|
|
|
|
"o c #000000",
|
|
|
|
". c #ffffff",
|
|
|
|
" c None",
|
|
|
|
/* pixels */
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
" oo ",
|
|
|
|
" oo ",
|
|
|
|
" oo ",
|
|
|
|
" oo ",
|
|
|
|
" oo ",
|
|
|
|
" oo ",
|
|
|
|
" oo ",
|
|
|
|
" oo ",
|
|
|
|
" oo ",
|
|
|
|
" oo ",
|
|
|
|
" oo ",
|
|
|
|
" oooooooooooooooooooooooo ",
|
|
|
|
" oooooooooooooooooooooooo ",
|
|
|
|
" oo ",
|
|
|
|
" oo ",
|
|
|
|
" oo ",
|
|
|
|
" oo ",
|
|
|
|
" oo ",
|
|
|
|
" oo ",
|
|
|
|
" oo ",
|
|
|
|
" oo ",
|
|
|
|
" oo ",
|
|
|
|
" oo ",
|
|
|
|
" oo ",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
"0,0"
|
|
|
|
};
|
|
|
|
|
2024-08-01 21:38:17 +03:00
|
|
|
static SDL_Surface *load_image_file(const char *file)
|
2016-10-04 14:08:02 +03:00
|
|
|
{
|
|
|
|
SDL_Surface *surface = SDL_LoadBMP(file);
|
|
|
|
if (surface) {
|
2024-07-09 00:59:18 +03:00
|
|
|
if (SDL_GetSurfacePalette(surface)) {
|
|
|
|
const Uint8 bpp = SDL_BITSPERPIXEL(surface->format);
|
2023-11-17 17:10:32 +03:00
|
|
|
const Uint8 mask = (1 << bpp) - 1;
|
2024-07-09 00:59:18 +03:00
|
|
|
if (SDL_PIXELORDER(surface->format) == SDL_BITMAPORDER_4321)
|
2023-11-17 17:10:32 +03:00
|
|
|
SDL_SetSurfaceColorKey(surface, 1, (*(Uint8 *)surface->pixels) & mask);
|
|
|
|
else
|
|
|
|
SDL_SetSurfaceColorKey(surface, 1, ((*(Uint8 *)surface->pixels) >> (8 - bpp)) & mask);
|
2018-03-16 04:22:48 +03:00
|
|
|
} else {
|
2024-07-09 00:59:18 +03:00
|
|
|
switch (SDL_BITSPERPIXEL(surface->format)) {
|
2018-03-16 04:22:48 +03:00
|
|
|
case 15:
|
2022-12-27 17:36:39 +03:00
|
|
|
SDL_SetSurfaceColorKey(surface, 1, (*(Uint16 *)surface->pixels) & 0x00007FFF);
|
2018-03-16 04:22:48 +03:00
|
|
|
break;
|
|
|
|
case 16:
|
2022-12-27 17:36:39 +03:00
|
|
|
SDL_SetSurfaceColorKey(surface, 1, *(Uint16 *)surface->pixels);
|
2018-03-16 04:22:48 +03:00
|
|
|
break;
|
|
|
|
case 24:
|
2022-12-27 17:36:39 +03:00
|
|
|
SDL_SetSurfaceColorKey(surface, 1, (*(Uint32 *)surface->pixels) & 0x00FFFFFF);
|
2018-03-16 04:22:48 +03:00
|
|
|
break;
|
|
|
|
case 32:
|
2022-12-27 17:36:39 +03:00
|
|
|
SDL_SetSurfaceColorKey(surface, 1, *(Uint32 *)surface->pixels);
|
2018-03-16 04:22:48 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2024-08-01 21:38:17 +03:00
|
|
|
}
|
|
|
|
return surface;
|
|
|
|
}
|
|
|
|
|
|
|
|
static SDL_Surface *load_image(const char *file)
|
|
|
|
{
|
|
|
|
SDL_Surface *surface = load_image_file(file);
|
|
|
|
if (surface) {
|
|
|
|
/* Add a 2x version of this image, if available */
|
|
|
|
SDL_Surface *surface2x = NULL;
|
|
|
|
const char *ext = SDL_strrchr(file, '.');
|
|
|
|
size_t len = SDL_strlen(file) + 2 + 1;
|
|
|
|
char *file2x = (char *)SDL_malloc(len);
|
|
|
|
if (file2x) {
|
|
|
|
SDL_strlcpy(file2x, file, len);
|
|
|
|
if (ext) {
|
|
|
|
SDL_memcpy(file2x + (ext - file), "2x", 3);
|
|
|
|
SDL_strlcat(file2x, ext, len);
|
|
|
|
} else {
|
|
|
|
SDL_strlcat(file2x, "2x", len);
|
|
|
|
}
|
|
|
|
surface2x = load_image_file(file2x);
|
|
|
|
SDL_free(file2x);
|
|
|
|
}
|
|
|
|
if (surface2x) {
|
|
|
|
SDL_AddSurfaceAlternateImage(surface, surface2x);
|
|
|
|
SDL_DestroySurface(surface2x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return surface;
|
|
|
|
}
|
|
|
|
|
|
|
|
static SDL_Cursor *init_color_cursor(const char *file)
|
|
|
|
{
|
|
|
|
SDL_Cursor *cursor = NULL;
|
|
|
|
SDL_Surface *surface = load_image(file);
|
|
|
|
if (surface) {
|
2016-10-04 14:08:02 +03:00
|
|
|
cursor = SDL_CreateColorCursor(surface, 0, 0);
|
2022-12-27 17:36:39 +03:00
|
|
|
SDL_DestroySurface(surface);
|
2016-10-04 14:08:02 +03:00
|
|
|
}
|
|
|
|
return cursor;
|
|
|
|
}
|
|
|
|
|
2024-08-01 21:38:17 +03:00
|
|
|
static SDL_Cursor *init_system_cursor(const char *image[])
|
2016-07-13 17:34:06 +03:00
|
|
|
{
|
2022-11-30 23:51:59 +03:00
|
|
|
int i, row, col;
|
|
|
|
Uint8 data[4 * 32];
|
|
|
|
Uint8 mask[4 * 32];
|
2022-12-02 00:07:03 +03:00
|
|
|
int hot_x = 0;
|
|
|
|
int hot_y = 0;
|
2022-11-30 23:51:59 +03:00
|
|
|
|
|
|
|
i = -1;
|
|
|
|
for (row = 0; row < 32; ++row) {
|
|
|
|
for (col = 0; col < 32; ++col) {
|
|
|
|
if (col % 8) {
|
|
|
|
data[i] <<= 1;
|
|
|
|
mask[i] <<= 1;
|
|
|
|
} else {
|
|
|
|
++i;
|
|
|
|
data[i] = mask[i] = 0;
|
|
|
|
}
|
|
|
|
switch (image[4 + row][col]) {
|
|
|
|
case 'X':
|
|
|
|
data[i] |= 0x01;
|
|
|
|
mask[i] |= 0x01;
|
|
|
|
break;
|
|
|
|
case '.':
|
|
|
|
mask[i] |= 0x01;
|
|
|
|
break;
|
2023-12-15 20:59:50 +03:00
|
|
|
case 'o':
|
|
|
|
data[i] |= 0x01;
|
|
|
|
break;
|
2022-11-30 23:51:59 +03:00
|
|
|
case ' ':
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-07-13 17:34:06 +03:00
|
|
|
}
|
2022-12-02 00:07:03 +03:00
|
|
|
(void)SDL_sscanf(image[4 + row], "%d,%d", &hot_x, &hot_y);
|
2022-11-30 23:51:59 +03:00
|
|
|
return SDL_CreateCursor(data, mask, 32, 32, hot_x, hot_y);
|
2016-07-13 17:34:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static SDLTest_CommonState *state;
|
2023-03-08 13:40:07 +03:00
|
|
|
static int done;
|
2023-12-15 20:59:50 +03:00
|
|
|
static SDL_Cursor *cursors[3 + SDL_NUM_SYSTEM_CURSORS];
|
|
|
|
static SDL_SystemCursor cursor_types[3 + SDL_NUM_SYSTEM_CURSORS];
|
2022-05-26 00:12:25 +03:00
|
|
|
static int num_cursors;
|
2018-03-16 04:22:48 +03:00
|
|
|
static int current_cursor;
|
2022-12-29 04:06:38 +03:00
|
|
|
static SDL_bool show_cursor;
|
2016-07-13 17:34:06 +03:00
|
|
|
|
|
|
|
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
|
|
|
|
static void
|
|
|
|
quit(int rc)
|
|
|
|
{
|
|
|
|
SDLTest_CommonQuit(state);
|
2023-04-12 12:07:28 +03:00
|
|
|
/* Let 'main()' return normally */
|
|
|
|
if (rc != 0) {
|
|
|
|
exit(rc);
|
|
|
|
}
|
2016-07-13 17:34:06 +03:00
|
|
|
}
|
|
|
|
|
2023-03-08 13:40:07 +03:00
|
|
|
static void loop(void)
|
2016-07-13 17:34:06 +03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
SDL_Event event;
|
|
|
|
/* Check for events */
|
|
|
|
while (SDL_PollEvent(&event)) {
|
|
|
|
SDLTest_CommonEvent(state, &event, &done);
|
2023-01-30 06:06:08 +03:00
|
|
|
if (event.type == SDL_EVENT_MOUSE_BUTTON_DOWN) {
|
2018-03-16 04:22:48 +03:00
|
|
|
if (event.button.button == SDL_BUTTON_LEFT) {
|
2022-05-26 00:12:25 +03:00
|
|
|
if (num_cursors == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-03-16 04:22:48 +03:00
|
|
|
++current_cursor;
|
2022-05-26 00:12:25 +03:00
|
|
|
if (current_cursor == num_cursors) {
|
2018-03-16 04:22:48 +03:00
|
|
|
current_cursor = 0;
|
|
|
|
}
|
2022-05-17 19:49:36 +03:00
|
|
|
|
2018-03-16 04:22:48 +03:00
|
|
|
SDL_SetCursor(cursors[current_cursor]);
|
2022-05-17 19:49:36 +03:00
|
|
|
|
2022-10-06 00:59:01 +03:00
|
|
|
switch ((int)cursor_types[current_cursor]) {
|
2022-11-30 23:51:59 +03:00
|
|
|
case (SDL_SystemCursor)-1:
|
|
|
|
SDL_Log("Custom cursor");
|
|
|
|
break;
|
2024-05-26 07:28:17 +03:00
|
|
|
case SDL_SYSTEM_CURSOR_DEFAULT:
|
|
|
|
SDL_Log("Default");
|
2022-11-30 23:51:59 +03:00
|
|
|
break;
|
2024-05-26 07:28:17 +03:00
|
|
|
case SDL_SYSTEM_CURSOR_TEXT:
|
|
|
|
SDL_Log("Text");
|
2022-11-30 23:51:59 +03:00
|
|
|
break;
|
|
|
|
case SDL_SYSTEM_CURSOR_WAIT:
|
|
|
|
SDL_Log("Wait");
|
|
|
|
break;
|
|
|
|
case SDL_SYSTEM_CURSOR_CROSSHAIR:
|
|
|
|
SDL_Log("Crosshair");
|
|
|
|
break;
|
2024-05-26 07:28:17 +03:00
|
|
|
case SDL_SYSTEM_CURSOR_PROGRESS:
|
|
|
|
SDL_Log("Progress: Small wait cursor (or Wait if not available)");
|
2022-11-30 23:51:59 +03:00
|
|
|
break;
|
2024-05-26 07:28:17 +03:00
|
|
|
case SDL_SYSTEM_CURSOR_NWSE_RESIZE:
|
2022-11-30 23:51:59 +03:00
|
|
|
SDL_Log("Double arrow pointing northwest and southeast");
|
|
|
|
break;
|
2024-05-26 07:28:17 +03:00
|
|
|
case SDL_SYSTEM_CURSOR_NESW_RESIZE:
|
2022-11-30 23:51:59 +03:00
|
|
|
SDL_Log("Double arrow pointing northeast and southwest");
|
|
|
|
break;
|
2024-05-26 07:28:17 +03:00
|
|
|
case SDL_SYSTEM_CURSOR_EW_RESIZE:
|
2022-11-30 23:51:59 +03:00
|
|
|
SDL_Log("Double arrow pointing west and east");
|
|
|
|
break;
|
2024-05-26 07:28:17 +03:00
|
|
|
case SDL_SYSTEM_CURSOR_NS_RESIZE:
|
2022-11-30 23:51:59 +03:00
|
|
|
SDL_Log("Double arrow pointing north and south");
|
|
|
|
break;
|
2024-05-26 07:28:17 +03:00
|
|
|
case SDL_SYSTEM_CURSOR_MOVE:
|
|
|
|
SDL_Log("Move: Four pointed arrow pointing north, south, east, and west");
|
2022-11-30 23:51:59 +03:00
|
|
|
break;
|
2024-05-26 07:28:17 +03:00
|
|
|
case SDL_SYSTEM_CURSOR_NOT_ALLOWED:
|
|
|
|
SDL_Log("Not Allowed: Slashed circle or crossbones");
|
2022-11-30 23:51:59 +03:00
|
|
|
break;
|
2024-05-26 07:28:17 +03:00
|
|
|
case SDL_SYSTEM_CURSOR_POINTER:
|
|
|
|
SDL_Log("Pointer: Hand");
|
2022-11-30 23:51:59 +03:00
|
|
|
break;
|
2024-05-26 07:28:17 +03:00
|
|
|
case SDL_SYSTEM_CURSOR_NW_RESIZE:
|
2023-11-21 06:41:18 +03:00
|
|
|
SDL_Log("Window resize top-left");
|
|
|
|
break;
|
2024-05-26 07:28:17 +03:00
|
|
|
case SDL_SYSTEM_CURSOR_N_RESIZE:
|
2023-11-21 06:41:18 +03:00
|
|
|
SDL_Log("Window resize top");
|
|
|
|
break;
|
2024-05-26 07:28:17 +03:00
|
|
|
case SDL_SYSTEM_CURSOR_NE_RESIZE:
|
2023-11-21 06:41:18 +03:00
|
|
|
SDL_Log("Window resize top-right");
|
|
|
|
break;
|
2024-05-26 07:28:17 +03:00
|
|
|
case SDL_SYSTEM_CURSOR_E_RESIZE:
|
2023-11-21 06:41:18 +03:00
|
|
|
SDL_Log("Window resize right");
|
|
|
|
break;
|
2024-05-26 07:28:17 +03:00
|
|
|
case SDL_SYSTEM_CURSOR_SE_RESIZE:
|
2023-11-21 06:41:18 +03:00
|
|
|
SDL_Log("Window resize bottom-right");
|
|
|
|
break;
|
2024-05-26 07:28:17 +03:00
|
|
|
case SDL_SYSTEM_CURSOR_S_RESIZE:
|
2023-11-21 06:41:18 +03:00
|
|
|
SDL_Log("Window resize bottom");
|
|
|
|
break;
|
2024-05-26 07:28:17 +03:00
|
|
|
case SDL_SYSTEM_CURSOR_SW_RESIZE:
|
2023-11-21 06:41:18 +03:00
|
|
|
SDL_Log("Window resize bottom-left");
|
|
|
|
break;
|
2024-05-26 07:28:17 +03:00
|
|
|
case SDL_SYSTEM_CURSOR_W_RESIZE:
|
2023-11-21 06:41:18 +03:00
|
|
|
SDL_Log("Window resize left");
|
|
|
|
break;
|
2022-11-30 23:51:59 +03:00
|
|
|
default:
|
|
|
|
SDL_Log("UNKNOWN CURSOR TYPE, FIX THIS PROGRAM.");
|
|
|
|
break;
|
2022-05-17 19:49:36 +03:00
|
|
|
}
|
2022-05-26 00:12:25 +03:00
|
|
|
|
2018-03-16 04:22:48 +03:00
|
|
|
} else {
|
|
|
|
show_cursor = !show_cursor;
|
2022-12-29 04:06:38 +03:00
|
|
|
if (show_cursor) {
|
|
|
|
SDL_ShowCursor();
|
|
|
|
} else {
|
|
|
|
SDL_HideCursor();
|
|
|
|
}
|
2018-03-16 04:22:48 +03:00
|
|
|
}
|
|
|
|
}
|
2016-07-13 17:34:06 +03:00
|
|
|
}
|
2022-11-30 23:51:59 +03:00
|
|
|
|
2016-07-13 17:34:06 +03:00
|
|
|
for (i = 0; i < state->num_windows; ++i) {
|
|
|
|
SDL_Renderer *renderer = state->renderers[i];
|
2023-12-15 20:59:50 +03:00
|
|
|
SDL_FRect rect;
|
|
|
|
int x, y, row;
|
|
|
|
int window_w = 0, window_h = 0;
|
|
|
|
|
|
|
|
SDL_GetWindowSize(state->windows[i], &window_w, &window_h);
|
|
|
|
rect.w = 128.0f;
|
|
|
|
rect.h = 128.0f;
|
|
|
|
for (y = 0, row = 0; y < window_h; y += (int)rect.h, ++row) {
|
|
|
|
SDL_bool black = ((row % 2) == 0) ? SDL_TRUE : SDL_FALSE;
|
|
|
|
for (x = 0; x < window_w; x += (int)rect.w) {
|
|
|
|
rect.x = (float)x;
|
|
|
|
rect.y = (float)y;
|
|
|
|
|
|
|
|
if (black) {
|
|
|
|
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
|
|
|
|
} else {
|
|
|
|
SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
|
|
|
|
}
|
|
|
|
SDL_RenderFillRect(renderer, &rect);
|
|
|
|
|
|
|
|
black = !black;
|
|
|
|
}
|
|
|
|
}
|
2016-07-13 17:34:06 +03:00
|
|
|
SDL_RenderPresent(renderer);
|
|
|
|
}
|
2024-01-24 04:40:51 +03:00
|
|
|
#ifdef SDL_PLATFORM_EMSCRIPTEN
|
2016-07-13 17:34:06 +03:00
|
|
|
if (done) {
|
|
|
|
emscripten_cancel_main_loop();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-11-30 23:51:59 +03:00
|
|
|
int main(int argc, char *argv[])
|
2016-07-13 17:34:06 +03:00
|
|
|
{
|
|
|
|
int i;
|
2016-10-04 14:08:02 +03:00
|
|
|
const char *color_cursor = NULL;
|
2023-12-15 20:59:50 +03:00
|
|
|
SDL_Cursor *cursor;
|
2016-07-13 17:34:06 +03:00
|
|
|
|
|
|
|
/* Initialize test framework */
|
|
|
|
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
|
2023-11-10 00:29:15 +03:00
|
|
|
if (!state) {
|
2016-07-13 17:34:06 +03:00
|
|
|
return 1;
|
|
|
|
}
|
2024-07-27 14:44:04 +03:00
|
|
|
|
|
|
|
/* Enable standard application logging */
|
|
|
|
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
|
|
|
|
2016-07-13 17:34:06 +03:00
|
|
|
for (i = 1; i < argc;) {
|
|
|
|
int consumed;
|
|
|
|
|
|
|
|
consumed = SDLTest_CommonArg(state, i);
|
|
|
|
if (consumed == 0) {
|
2016-10-04 14:08:02 +03:00
|
|
|
color_cursor = argv[i];
|
|
|
|
break;
|
2016-07-13 17:34:06 +03:00
|
|
|
}
|
|
|
|
if (consumed < 0) {
|
2019-05-29 00:39:13 +03:00
|
|
|
SDLTest_CommonLogUsage(state, argv[0], NULL);
|
2016-07-13 17:34:06 +03:00
|
|
|
quit(1);
|
|
|
|
}
|
|
|
|
i += consumed;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!SDLTest_CommonInit(state)) {
|
|
|
|
quit(2);
|
|
|
|
}
|
|
|
|
|
2022-05-26 00:12:25 +03:00
|
|
|
num_cursors = 0;
|
|
|
|
|
2016-10-04 14:08:02 +03:00
|
|
|
if (color_cursor) {
|
2024-08-01 21:38:17 +03:00
|
|
|
SDL_Surface *icon = load_image(color_cursor);
|
|
|
|
if (icon) {
|
|
|
|
for (i = 0; i < state->num_windows; ++i) {
|
|
|
|
SDL_SetWindowIcon(state->windows[i], icon);
|
|
|
|
}
|
|
|
|
SDL_DestroySurface(icon);
|
|
|
|
}
|
|
|
|
|
2023-12-15 20:59:50 +03:00
|
|
|
cursor = init_color_cursor(color_cursor);
|
2022-05-26 00:12:25 +03:00
|
|
|
if (cursor) {
|
|
|
|
cursors[num_cursors] = cursor;
|
|
|
|
cursor_types[num_cursors] = (SDL_SystemCursor)-1;
|
|
|
|
num_cursors++;
|
|
|
|
}
|
2016-10-04 14:08:02 +03:00
|
|
|
}
|
2022-05-26 00:12:25 +03:00
|
|
|
|
2023-12-15 20:59:50 +03:00
|
|
|
cursor = init_system_cursor(arrow);
|
|
|
|
if (cursor) {
|
|
|
|
cursors[num_cursors] = cursor;
|
|
|
|
cursor_types[num_cursors] = (SDL_SystemCursor)-1;
|
|
|
|
num_cursors++;
|
|
|
|
}
|
|
|
|
|
|
|
|
cursor = init_system_cursor(cross);
|
|
|
|
if (cursor) {
|
|
|
|
cursors[num_cursors] = cursor;
|
|
|
|
cursor_types[num_cursors] = (SDL_SystemCursor)-1;
|
|
|
|
num_cursors++;
|
|
|
|
}
|
|
|
|
|
2018-03-16 04:22:48 +03:00
|
|
|
for (i = 0; i < SDL_NUM_SYSTEM_CURSORS; ++i) {
|
2023-12-15 21:03:11 +03:00
|
|
|
cursor = SDL_CreateSystemCursor((SDL_SystemCursor)i);
|
2022-05-26 00:12:25 +03:00
|
|
|
if (cursor) {
|
|
|
|
cursors[num_cursors] = cursor;
|
|
|
|
cursor_types[num_cursors] = i;
|
|
|
|
num_cursors++;
|
2018-03-16 04:22:48 +03:00
|
|
|
}
|
|
|
|
}
|
2022-05-26 00:12:25 +03:00
|
|
|
|
|
|
|
if (num_cursors > 0) {
|
|
|
|
SDL_SetCursor(cursors[0]);
|
|
|
|
}
|
|
|
|
|
2022-12-29 04:06:38 +03:00
|
|
|
show_cursor = SDL_CursorVisible();
|
2016-07-13 17:34:06 +03:00
|
|
|
|
|
|
|
/* Main render loop */
|
|
|
|
done = 0;
|
2024-01-24 04:40:51 +03:00
|
|
|
#ifdef SDL_PLATFORM_EMSCRIPTEN
|
2016-07-13 17:34:06 +03:00
|
|
|
emscripten_set_main_loop(loop, 0, 1);
|
|
|
|
#else
|
|
|
|
while (!done) {
|
|
|
|
loop();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-05-26 00:12:25 +03:00
|
|
|
for (i = 0; i < num_cursors; ++i) {
|
2022-12-30 02:07:59 +03:00
|
|
|
SDL_DestroyCursor(cursors[i]);
|
2018-03-16 04:22:48 +03:00
|
|
|
}
|
2016-07-13 17:34:06 +03:00
|
|
|
quit(0);
|
|
|
|
|
|
|
|
/* keep the compiler happy ... */
|
2022-11-27 19:38:43 +03:00
|
|
|
return 0;
|
2016-07-13 17:34:06 +03:00
|
|
|
}
|