window pos

This commit is contained in:
Krzosa Karol
2025-05-04 09:16:34 +02:00
parent dec70c10e7
commit 101e844ac5

View File

@@ -298,12 +298,21 @@ int main(int argc, char **argv)
SDL_DisplayID primary_display_id = SDL_GetPrimaryDisplay(); SDL_DisplayID primary_display_id = SDL_GetPrimaryDisplay();
const SDL_DisplayMode *display_mode = SDL_GetCurrentDisplayMode(primary_display_id); const SDL_DisplayMode *display_mode = SDL_GetCurrentDisplayMode(primary_display_id);
int w8 = (int)(display_mode->w * 0.8);
int h8 = (int)(display_mode->h * 0.8);
int whalf = (int)(display_mode->w * 0.5) - 10;
int hhalf = (int)(display_mode->h) - 120;
int xhalf = whalf;
int yhalf = 30;
Uint32 window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN | SDL_WINDOW_HIGH_PIXEL_DENSITY; Uint32 window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN | SDL_WINDOW_HIGH_PIXEL_DENSITY;
SDLWindow = SDL_CreateWindow("Text editor", (int)(display_mode->w * 0.8), (int)(display_mode->h * 0.8), window_flags); SDLWindow = SDL_CreateWindow("Text editor", whalf, hhalf, window_flags);
if (SDLWindow == NULL) { if (SDLWindow == NULL) {
ReportErrorf("Couldn't create window! %s", SDL_GetError()); ReportErrorf("Couldn't create window! %s", SDL_GetError());
return 1; return 1;
} }
SDL_SetWindowPosition(SDLWindow, xhalf, yhalf);
SDL_GLContext gl_context = SDL_GL_CreateContext(SDLWindow); SDL_GLContext gl_context = SDL_GL_CreateContext(SDLWindow);
SDL_GL_MakeCurrent(SDLWindow, gl_context); SDL_GL_MakeCurrent(SDLWindow, gl_context);