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))
Application::Application()
: init_sdl()
+, init_img()
, init_gl()
, window()
, ctx(window.CreateContext())
private:
InitSDL init_sdl;
+ InitIMG init_img;
InitGL init_gl;
Window window;
GLContext ctx;
#include <algorithm>
#include <SDL.h>
+#include <SDL_image.h>
#include <stdexcept>
#include <string>
#include <GL/glew.h>
}
+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)");
};
+class InitIMG {
+
+public:
+ InitIMG();
+ ~InitIMG();
+
+ InitIMG(const InitIMG &) = delete;
+ InitIMG &operator =(const InitIMG &) = delete;
+
+};
+
+
class InitGL {
public: