diff --git a/assets/resources/CURSOR/CURSOR_IKA.png b/assets/resources/CURSOR/CURSOR_IKA.png index 0e559544..c3892986 100644 Binary files a/assets/resources/CURSOR/CURSOR_IKA.png and b/assets/resources/CURSOR/CURSOR_IKA.png differ diff --git a/assets/resources/CURSOR/CURSOR_NORMAL.png b/assets/resources/CURSOR/CURSOR_NORMAL.png index 600fb001..83e6d54a 100644 Binary files a/assets/resources/CURSOR/CURSOR_NORMAL.png and b/assets/resources/CURSOR/CURSOR_NORMAL.png differ diff --git a/src/Backends/Misc.h b/src/Backends/Misc.h index f12db458..c94d3471 100644 --- a/src/Backends/Misc.h +++ b/src/Backends/Misc.h @@ -92,7 +92,7 @@ void Backend_PostWindowCreation(void); bool Backend_GetBasePath(std::string *string_buffer); void Backend_HideMouse(void); void Backend_SetWindowIcon(const unsigned char *rgb_pixels, size_t width, size_t height); -void Backend_SetCursor(const unsigned char *rgb_pixels, size_t width, size_t height); +void Backend_SetCursor(const unsigned char *rgba_pixels, size_t width, size_t height); void PlaybackBackend_EnableDragAndDrop(void); bool Backend_SystemTask(bool active); void Backend_GetKeyboardState(bool *keyboard_state); diff --git a/src/Backends/Platform/GLFW3.cpp b/src/Backends/Platform/GLFW3.cpp index 717b7838..f96a0904 100644 --- a/src/Backends/Platform/GLFW3.cpp +++ b/src/Backends/Platform/GLFW3.cpp @@ -229,45 +229,13 @@ void Backend_SetWindowIcon(const unsigned char *rgb_pixels, size_t width, size_t } } -void Backend_SetCursor(const unsigned char *rgb_pixels, size_t width, size_t height) +void Backend_SetCursor(const unsigned char *rgba_pixels, size_t width, size_t height) { - // Convert to RGBA, since that's the only thing GLFW3 accepts - unsigned char *rgba_pixels = (unsigned char*)malloc(width * height * 4); + GLFWimage glfw_image = {(int)width, (int)height, rgba_pixels}; + cursor = glfwCreateCursor(&glfw_image, 0, 0); - const unsigned char *rgb_pointer = rgb_pixels; - unsigned char *rgba_pointer = rgba_pixels; - - if (rgba_pixels != NULL) - { - for (size_t y = 0; y < height; ++y) - { - for (size_t x = 0; x < width; ++x) - { - if (rgb_pointer[0] == 0xFF && rgb_pointer[1] == 0 && rgb_pointer[2] == 0xFF) // Colour-key - { - *rgba_pointer++ = *rgb_pointer++; - *rgba_pointer++ = *rgb_pointer++; - *rgba_pointer++ = *rgb_pointer++; - *rgba_pointer++ = 0; - } - else - { - *rgba_pointer++ = *rgb_pointer++; - *rgba_pointer++ = *rgb_pointer++; - *rgba_pointer++ = *rgb_pointer++; - *rgba_pointer++ = 0xFF; - } - } - } - - GLFWimage glfw_image = {(int)width, (int)height, rgba_pixels}; - cursor = glfwCreateCursor(&glfw_image, 0, 0); - - if (cursor != NULL) - glfwSetCursor(window, cursor); - - free(rgba_pixels); - } + if (cursor != NULL) + glfwSetCursor(window, cursor); } void Backend_EnableDragAndDrop(void) diff --git a/src/Backends/Platform/Null.cpp b/src/Backends/Platform/Null.cpp index e8757a0d..6d45e82d 100644 --- a/src/Backends/Platform/Null.cpp +++ b/src/Backends/Platform/Null.cpp @@ -41,9 +41,9 @@ void Backend_SetWindowIcon(const unsigned char *rgb_pixels, size_t width, size_t (void)height; } -void Backend_SetCursor(const unsigned char *rgb_pixels, size_t width, size_t height) +void Backend_SetCursor(const unsigned char *rgba_pixels, size_t width, size_t height) { - (void)rgb_pixels; + (void)rgba_pixels; (void)width; (void)height; } diff --git a/src/Backends/Platform/SDL2.cpp b/src/Backends/Platform/SDL2.cpp index 05099962..fac0d1fc 100644 --- a/src/Backends/Platform/SDL2.cpp +++ b/src/Backends/Platform/SDL2.cpp @@ -134,25 +134,22 @@ void Backend_SetWindowIcon(const unsigned char *rgb_pixels, size_t width, size_t } } -void Backend_SetCursor(const unsigned char *rgb_pixels, size_t width, size_t height) +void Backend_SetCursor(const unsigned char *rgba_pixels, size_t width, size_t height) { - cursor_surface_pixels = (unsigned char*)malloc(width * height * 3); + cursor_surface_pixels = (unsigned char*)malloc(width * height * 4); if (cursor_surface_pixels != NULL) { - memcpy(cursor_surface_pixels, rgb_pixels, width * height * 3); + memcpy(cursor_surface_pixels, rgba_pixels, width * height * 4); - cursor_surface = SDL_CreateRGBSurfaceWithFormatFrom(cursor_surface_pixels, width, height, 0, width * 3, SDL_PIXELFORMAT_RGB24); + cursor_surface = SDL_CreateRGBSurfaceWithFormatFrom(cursor_surface_pixels, width, height, 0, width * 4, SDL_PIXELFORMAT_RGBA32); if (cursor_surface != NULL) { - if (SDL_SetColorKey(cursor_surface, SDL_TRUE, SDL_MapRGB(cursor_surface->format, 0xFF, 0, 0xFF)) == 0) - { - cursor = SDL_CreateColorCursor(cursor_surface, 0, 0); + cursor = SDL_CreateColorCursor(cursor_surface, 0, 0); - if (cursor != NULL) - SDL_SetCursor(cursor); - } + if (cursor != NULL) + SDL_SetCursor(cursor); } } else diff --git a/src/Backends/Platform/WiiU.cpp b/src/Backends/Platform/WiiU.cpp index c358ed4f..f876aed8 100644 --- a/src/Backends/Platform/WiiU.cpp +++ b/src/Backends/Platform/WiiU.cpp @@ -83,9 +83,9 @@ void Backend_SetWindowIcon(const unsigned char *rgb_pixels, size_t width, size_t (void)height; } -void Backend_SetCursor(const unsigned char *rgb_pixels, size_t width, size_t height) +void Backend_SetCursor(const unsigned char *rgba_pixels, size_t width, size_t height) { - (void)rgb_pixels; + (void)rgba_pixels; (void)width; (void)height; } diff --git a/src/Main.cpp b/src/Main.cpp index b9839408..b8b4aa17 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -312,12 +312,12 @@ int main(int argc, char *argv[]) if (cursor_resource_data != NULL) { size_t cursor_width, cursor_height; - unsigned char *cursor_rgb_pixels = DecodeBitmap(cursor_resource_data, cursor_resource_size, &cursor_width, &cursor_height, 3); + unsigned char *cursor_rgba_pixels = DecodeBitmap(cursor_resource_data, cursor_resource_size, &cursor_width, &cursor_height, 4); - if (cursor_rgb_pixels != NULL) + if (cursor_rgba_pixels != NULL) { - Backend_SetCursor(cursor_rgb_pixels, cursor_width, cursor_height); - FreeBitmap(cursor_rgb_pixels); + Backend_SetCursor(cursor_rgba_pixels, cursor_width, cursor_height); + FreeBitmap(cursor_rgba_pixels); } }