No, SDL does not allow you to change a window's ID after it has been created. When you create a window using SDL_CreateWindow()
, SDL assigns it a unique, immutable integer ID. This ID is used internally by SDL to track and manage windows and is referenced in events like SDL_WINDOWEVENT
and SDL_MOUSEBUTTONDOWN
.
If you need to associate custom data with a window, consider using SDL_SetWindowData()
and SDL_GetWindowData()
. These functions let you attach and retrieve custom pointers from a window without interfering with its ID:
SDL_SetWindowData(window, "customKey",
myCustomPointer);
void* data = SDL_GetWindowData(
window, "customKey");
This way, you can manage your own references without needing to modify the ID.
In short, while you can’t change a window’s ID, SDL provides other mechanisms to achieve flexibility in managing window data.
Answers to questions are automatically generated and may not have been reviewed.
Discover how to monitor and respond to window state changes in SDL applications