renderer size
authorMatthew Owens <matthew@owens.tech>
Fri, 2 Oct 2020 11:06:50 +0000 (12:06 +0100)
committerMatthew Owens <matthew@owens.tech>
Fri, 2 Oct 2020 11:06:50 +0000 (12:06 +0100)
src/main.c

index 5a2d9a8..f1ab276 100644 (file)
@@ -35,7 +35,7 @@ typedef struct Vbox {
 
 static SDL_Window *window = NULL;
 static SDL_Renderer *renderer = NULL;
-static const Vec2di windowSize = { 1920, 1080 };
+static Vec2di windowSize;// = { 1920, 1080 };
 static bool quit = false;
 static const float speed = 20.f;
 static const Colour bgClr = { 0x1c, 0x1c, 0x1c, 0xff };
@@ -157,6 +157,12 @@ static bool init()
                return false;
        }
 
+       // getting window size
+       SDL_DisplayMode dm;
+       SDL_GetCurrentDisplayMode(0, &dm);
+       windowSize.x = dm.w;
+       windowSize.y = dm.h;
+
        window = SDL_CreateWindow("pong",
                         SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
                         windowSize.x, windowSize.y,
@@ -175,6 +181,7 @@ static bool init()
                return false;
        }
 
+
        ts_init(60.f);
        paddle_init();
        ball_init();
@@ -224,13 +231,6 @@ int main()
        //TODO: run on primary display
        if(!init()) { return 1; }
 
-       int w, h;
-       SDL_DisplayMode dm;
-       SDL_GetCurrentDisplayMode(0, &dm);
-       SDL_GetRendererOutputSize(renderer, &w, &h);
-       COUT("renderer output size: (%d, %d)", w, h);
-       COUT("dm output size: (%d, %d)", dm.w, dm.h);
-       return 0;
        while(!quit) {
                update();
                render();