fixed window width and height not being set correctly

This commit is contained in:
Maciej Samborski 2025-09-04 08:55:15 +02:00
parent 5d6503e804
commit d95594629e
2 changed files with 12 additions and 4 deletions

10
main.c
View File

@ -20,6 +20,8 @@ int main(void)
{ {
Window * window = openWindow("Window", 800, 600); Window * window = openWindow("Window", 800, 600);
printf("%d %d\n", window->width, window->height);
windowSetFps(window, 300); windowSetFps(window, 300);
while (!windowKeyPressed(window, WINDOW_KEY_ESC)) { while (!windowKeyPressed(window, WINDOW_KEY_ESC)) {
@ -34,10 +36,10 @@ int main(void)
//windowGetMousePosition(window, &x, &y); //windowGetMousePosition(window, &x, &y);
//printf("x: %d, y: %d\n", x, y); //printf("x: %d, y: %d\n", x, y);
int w = 0; //int w = 0;
int h = 0; //int h = 0;
windowGetSize(window, &w, &h); //windowGetSize(window, &w, &h);
printf("%dx%d\n", w, h); //printf("%dx%d\n", w, h);
glClearColor(0.1, 0.2, 0.3, 1); glClearColor(0.1, 0.2, 0.3, 1);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);

View File

@ -206,6 +206,9 @@ Window * openWindow(const char * name, size_t width, size_t height) {
w->dt.t1 = calloc(1, sizeof(struct timespec)); w->dt.t1 = calloc(1, sizeof(struct timespec));
w->dt.t2 = calloc(1, sizeof(struct timespec)); w->dt.t2 = calloc(1, sizeof(struct timespec));
w->width = width;
w->height = height;
if (init(w, name, width, height) < 0) { if (init(w, name, width, height) < 0) {
fprintf(stderr, "Failed to initialize window: X11 error!\n"); fprintf(stderr, "Failed to initialize window: X11 error!\n");
exit(1); exit(1);
@ -489,6 +492,9 @@ Window * openWindow(const char * name, size_t width, size_t height) {
Window * w = calloc(1, sizeof(Window)); Window * w = calloc(1, sizeof(Window));
w->fps = WINDOW_DEFAULT_FPS; w->fps = WINDOW_DEFAULT_FPS;
w->width = width;
w->height = height;
if (init(w, name, width, height) < 0) { if (init(w, name, width, height) < 0) {
fprintf(stderr, "Failed to initialize wgl!\n"); fprintf(stderr, "Failed to initialize wgl!\n");
exit(1); exit(1);