From: Daniel Karbach Date: Thu, 12 Feb 2015 12:51:51 +0000 (+0100) Subject: add SDL2_image library X-Git-Url: http://git.localhorst.tv/?a=commitdiff_plain;ds=inline;h=e1e349bb6035463529bc341c472987d229e1cdca;p=blank.git add SDL2_image library --- diff --git a/Makefile b/Makefile index a3855ad..346b849 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ CXX = g++ --std=c++11 LDXX = g++ -LIBS = sdl2 glew +LIBS = sdl2 SDL2_image glew PKGFLAGS := $(shell pkg-config --cflags $(LIBS)) PKGLIBS := $(shell pkg-config --libs $(LIBS)) diff --git a/src/app.cpp b/src/app.cpp index de7a39e..7ecbb74 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -18,6 +18,7 @@ namespace blank { Application::Application() : init_sdl() +, init_img() , init_gl() , window() , ctx(window.CreateContext()) diff --git a/src/app.hpp b/src/app.hpp index 5148a7a..e525ec6 100644 --- a/src/app.hpp +++ b/src/app.hpp @@ -28,6 +28,7 @@ public: private: InitSDL init_sdl; + InitIMG init_img; InitGL init_gl; Window window; GLContext ctx; diff --git a/src/init.cpp b/src/init.cpp index 9010e00..20f4fe4 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -34,6 +35,17 @@ InitSDL::~InitSDL() { } +InitIMG::InitIMG() { + if (IMG_Init(IMG_INIT_PNG) == 0) { + sdl_error("IMG_Init(IMG_INIT_PNG)"); + } +} + +InitIMG::~InitIMG() { + IMG_Quit(); +} + + InitGL::InitGL() { if (SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3) != 0) { sdl_error("SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3)"); diff --git a/src/init.hpp b/src/init.hpp index 0256d40..bf6191b 100644 --- a/src/init.hpp +++ b/src/init.hpp @@ -21,6 +21,18 @@ public: }; +class InitIMG { + +public: + InitIMG(); + ~InitIMG(); + + InitIMG(const InitIMG &) = delete; + InitIMG &operator =(const InitIMG &) = delete; + +}; + + class InitGL { public: