Godzil 3 роки тому
батько
коміт
97ee337d22
2 змінених файлів з 14 додано та 1 видалено
  1. 10 1
      source/Game.cpp
  2. 4 0
      source/include/Game.h

+ 10 - 1
source/Game.cpp

@@ -13,6 +13,8 @@
 Game::Game()
 {
     this->isRunning = false;
+    this->windowsHeight = 0;
+    this->windowsWidth = 0;
 }
 
 Game::~Game()
@@ -23,6 +25,7 @@ Game::~Game()
 void Game::Initialize()
 {
     int ret;
+    SDL_DisplayMode displayMode;
 
     ret = SDL_Init(SDL_INIT_EVERYTHING);
     if (ret)
@@ -31,8 +34,12 @@ void Game::Initialize()
         return;
     }
 
+    SDL_GetCurrentDisplayMode(0, &displayMode);
+    this->windowsHeight = displayMode.h;
+    this->windowsWidth = displayMode.w;
+    printf("%d:%d\n", displayMode.w, displayMode.h);
     this->window = SDL_CreateWindow(NULL, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
-                                          800, 600, SDL_WINDOW_BORDERLESS);
+                                    this->windowsWidth, this->windowsHeight, SDL_WINDOW_BORDERLESS);
     if (!window)
     {
         fprintf(stderr, "SDL window creation error.\n");
@@ -46,6 +53,8 @@ void Game::Initialize()
         return;
     }
 
+    SDL_SetWindowFullscreen(this->window, SDL_WINDOW_FULLSCREEN);
+
     this->isRunning = true;
 }
 

+ 4 - 0
source/include/Game.h

@@ -10,6 +10,7 @@
 #define GAMEENGINE_GAME_H
 
 #include <SDL.h>
+#include <stdint.h>
 
 class Game
 {
@@ -28,6 +29,9 @@ public:
     void ProcessInput();
     void Render();
     void Update();
+
+    uint32_t windowsWidth;
+    uint32_t windowsHeight;
 };
 
 #endif /* GAMEENGINE_GAME_H */