Hey guys. I have a 1080p monitor. My window is 960x540 (1080p / 4), and my renderer is 1920x1080 (1080p). In my window creation function, I have the SDL_WINDOWPOS_CENTERED flags correctly, but for some reason upon creation, the window is locked to the top left corner of my screen until you try to resize it. Then it snaps out of place. Any idea what I may be doing wrong?
//initializing the window
bool windowManager::initWindow() {
//success flag
bool success = true;
//creating the window in the center of the screen.
window = SDL_CreateWindow(windowName, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, w, h, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
//if the window fails to load
if (window == NULL) {
//SDL error debug message
std::cout << "Window could not be created! SDL_Error: %s\n" << SDL_GetError();
//success flag to false because of failure to load window
success = false;
}
//if the window is created successfully
else {
//creating the renderer for the window
windowRenderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if (windowRenderer == NULL) {
std::cout << "Renderer could not be created! SDL Error: %s\n" << SDL_GetError();
success = false;
}
//if the renderer is created successfully
else {
//background color of the window to black by default
SDL_SetRenderDrawColor(windowRenderer, 0, 0, 0, 255);
}
}
//window init flag
return success;
}