I apologize for the confusion. You are correct that there is no specific SDL_WINDOWEVENT_FULLSCREEN event in SDL2. To check if the window has been fullscreened, you can instead listen for the SDL_WINDOWEVENT event with the SDL_WINDOWEVENT_SIZE_CHANGED subtype, and then compare the window size with the display size.
Here's an updated example of how you can check if the window has been fullscreened in SDL_Event:
#include <SDL2/SDL.h>
int main() {
SDL_Init(SDL_INIT_VIDEO);
SDL_Window* window = SDL_CreateWindow("Fullscreen Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_SHOWN);
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
bool isFullscreen = false;
SDL_Event event;
bool quit = false;
while (!quit) {
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
quit = true;
}
else if (event.type == SDL_KEYDOWN) {
if (event.key.keysym.sym == SDLK_f) {
if (!isFullscreen) {
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN); // Enable fullscreen mode
}
else {
SDL_SetWindowFullscreen(window, 0); // Disable fullscreen mode
}
isFullscreen = !isFullscreen;
}
}
else if (event.type == SDL_WINDOWEVENT) {
if (event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED && event.window.windowID == SDL_GetWindowID(window)) {
int windowWidth, windowHeight;
SDL_GetWindowSize(window, &windowWidth, &windowHeight);
SDL_DisplayMode dm;
SDL_GetDesktopDisplayMode(0, &dm);
if (windowWidth == dm.w && windowHeight == dm.h) {
printf("Window fullscreened\n");
}
else {
printf("Window unfullscreened\n");
}
}
}
}
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
}
SDL_DestroyWindow(window);
SDL_DestroyRenderer(renderer);
SDL_Quit();
return 0;
}
In this updated version, we listen for the SDL_WINDOWEVENT_SIZE_CHANGED event to detect when the window size changes. Then, we compare the window size with the size of the current display using SDL_GetDesktopDisplayMode. If the window size matches the display size, we consider the window to be fullscreened.
Again, I apologize for the confusion caused by my previous response. Please modify and adjust this code as needed for your specific application.