From: Matthew Owens Date: Fri, 2 Oct 2020 11:06:50 +0000 (+0100) Subject: renderer size X-Git-Url: https://git.owens.tech/assets/lich_lifts_title_slice.png/assets/lich_lifts_title_slice.png/git?a=commitdiff_plain;h=b10c3ea4a9b68f421cd060a94bb4865372efb065;p=pong.git renderer size --- diff --git a/src/main.c b/src/main.c index 5a2d9a8..f1ab276 100644 --- a/src/main.c +++ b/src/main.c @@ -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();