]> code.bitgloo.com Git - clyne/gamedev2.git/commitdiff
SDL_Init and SDL_Quit
authortcsullivan <tullivan99@gmail.com>
Sun, 25 Aug 2019 18:35:47 +0000 (14:35 -0400)
committertcsullivan <tullivan99@gmail.com>
Sun, 25 Aug 2019 18:35:47 +0000 (14:35 -0400)
Makefile
src/main.cpp

index 60019f6d02cdfb71f73fbe0bced434fa3d9405d7..9d2f336b7beb40a6fd5ac1a872a9684605f7236b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -21,7 +21,7 @@
 CC  = gcc
 CXX = g++
 
-LIBS =
+LIBS = -lSDL2
 
 CXXFLAGS = -ggdb -std=c++17 \
        -Wall -Wextra -Werror -pedantic \
index a8b46c087396e1f865a2938cd07e76ab54d366d8..8528f0ad5850f62da41532192a91681c54382734 100644 (file)
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
+#include <SDL2/SDL.h>
+
 #include <iostream>
 
 int main([[maybe_unused]] int argc, [[maybe_unused]] char *argv[])
 {
+       if (SDL_Init(0) != 0) {
+               std::cerr << "SDL failed to initialize: " << SDL_GetError() <<
+                       std::endl;
+               return -1;
+       } else {
+               atexit(SDL_Quit);
+       }
+
        std::cout << "Hello, world!" << std::endl;
+
        return 0;
 }