From ad4aa3b16a9fc333a9ee9c8b35a1f40cf47822bf Mon Sep 17 00:00:00 2001 From: tcsullivan Date: Sun, 25 Aug 2019 14:57:16 -0400 Subject: created a window --- src/main.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 8528f0a..9b88994 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,10 +21,17 @@ #include #include +#include + +constexpr const char *title = "gamedev2"; +constexpr int width = 640; +constexpr int height = 480; int main([[maybe_unused]] int argc, [[maybe_unused]] char *argv[]) { - if (SDL_Init(0) != 0) { + std::cout << "Hello, world!" << std::endl; + + if (SDL_Init(SDL_INIT_VIDEO) != 0) { std::cerr << "SDL failed to initialize: " << SDL_GetError() << std::endl; return -1; @@ -32,7 +39,16 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] char *argv[]) atexit(SDL_Quit); } - std::cout << "Hello, world!" << std::endl; + std::unique_ptr window + (SDL_CreateWindow(title, SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, width, height, 0), SDL_DestroyWindow); + + if (window.get() == nullptr) { + std::cerr << "SDL window creation failed: " << SDL_GetError() << + std::endl; + } + + SDL_Delay(1000); return 0; } -- cgit v1.2.3