I am pretty sure i am doing something wrong, but here is the deal.
I modified the examples to show the Window in Fullscreen by setting the SDL_WINDOW_FULLSCREEN flag and it works flawless. I could run every single application in fullscreen.
I also used SDL_SetRenderLogicalPresentation to make the Renderer scale up and its flawless. I tested it with every single example and it just works. Good =) Now i am trying to write my own Application and it suddenly just no longer works.
This is my AppInit
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
{
///////////////////////
// All the SDL stuff //
///////////////////////
SDL_SetLogPriorities(SDL_LOG_PRIORITY_VERBOSE);
if (!SDL_SetAppMetadata("IGE", "0.8.15", "space.ikaros.ige")) {
SDL_Log("SDL_SetAppMetadata: %s", SDL_GetError());
return SDL_APP_FAILURE;
}
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_Log("SDL_Init: %s", SDL_GetError());
return SDL_APP_FAILURE;
}
AppState *state = (AppState*)SDL_calloc(1, sizeof(AppState));
if (!state) { return SDL_APP_FAILURE; }
*appstate = state;
if (!SDL_CreateWindowAndRenderer("IGE", 320, 240, SDL_WINDOW_FULLSCREEN, &state->window, &state->renderer)) {
SDL_Log("SDL_CreateWindowAndRenderer: %s", SDL_GetError());
return SDL_APP_FAILURE;
}
if (!SDL_SetWindowFullscreenMode(state->window, NULL)) {
SDL_Log("SDL_SetWindowFullscreenMode: %s", SDL_GetError());
return SDL_APP_FAILURE;
}
uint32_t window_flags = SDL_GetWindowFlags(state->window);
if (window_flags & SDL_WINDOW_FULLSCREEN) {
SDL_Log("Window is in fullscreen mode.");
} else {
SDL_Log("Window is NOT in fullscreen mode. Flags: %u", window_flags);
}
if (!SDL_SetRenderLogicalPresentation(state->renderer, 320, 240, SDL_LOGICAL_PRESENTATION_LETTERBOX)) {
SDL_Log("SDL_SetRenderLogicalPresentation: %s", SDL_GetError());
return SDL_APP_FAILURE;
}
///////////////////////
// All the IGE stuff //
///////////////////////
state->intro = true;
return SDL_APP_CONTINUE;
}
And this is the output when running it
App name: IGE
App version: 0.8.15
App ID: space.ikaros.ige
SDL revision: release-3.2.16-0-gc9a6709bd
OpenGL shaders: ENABLED
Created renderer: opengl
Window is NOT in fullscreen mode. Flags: 2
I tried what feels like a 100 things, even asked the AI out of desparation but nothing, the AI says my code is fine and its a bug in SDL (which i doubt as it works in the examples).
Pretty sure i am just doing something wrong but i have no idea what.
The AppIterate just checks for the defined bool. If its true, it shows an image (That works fine by the way, its in window mode but it works), sets it to false and then uses SDL_Delay to not waste CPU/GPU Cycles. Thats it.
I have no idea what i am doing wrong and why it is only shown in Window mode. Please feel free to point out where i am doing things wrong^^
For reference, this is the modified AppInit from the Snake Demo where Fullscreen works fine and as expected (i am using 320x240 there too)
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
{
size_t i;
if (!SDL_SetAppMetadata("Example Snake game", "1.0", "com.example.Snake")) {
return SDL_APP_FAILURE;
}
for (i = 0; i < SDL_arraysize(extended_metadata); i++) {
if (!SDL_SetAppMetadataProperty(extended_metadata[i].key, extended_metadata[i].value)) {
return SDL_APP_FAILURE;
}
}
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK)) {
SDL_Log("Couldn't initialize SDL: %s", SDL_GetError());
return SDL_APP_FAILURE;
}
AppState *as = (AppState *)SDL_calloc(1, sizeof(AppState));
if (!as) {
return SDL_APP_FAILURE;
}
*appstate = as;
if (!SDL_CreateWindowAndRenderer("examples/demo/snake", SDL_WINDOW_WIDTH, SDL_WINDOW_HEIGHT, SDL_WINDOW_FULLSCREEN, &as->window, &as->renderer)) {
return SDL_APP_FAILURE;
}
SDL_SetRenderLogicalPresentation(as->renderer, SDL_WINDOW_WIDTH, SDL_WINDOW_HEIGHT, SDL_LOGICAL_PRESENTATION_LETTERBOX);
snake_initialize(&as->snake_ctx);
as->last_step = SDL_GetTicks();
return SDL_APP_CONTINUE;
}