FLAGS_LINUX = -lGL -lSDL_image
FLAGS_WIN32 = -lopengl32 -lmingw32 -lSDL2_Image
-FLAGS = -Wall -Werror -lSDL2main -lSDL2
+FLAGS = -m32 -Wall -Werror -lSDL2main -lSDL2
all:
@g++ src/main.cpp -o main $(FLAGS_LINUX) $(FLAGS)
#include <iostream>
+#include <cstdlib>
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
if(SDL_Init(SDL_INIT_VIDEO) < 0){
std::cout << "SDL was not able to initialize! Error: " << SDL_GetError() << std::endl;
}else{
+ atexit(SDL_Quit);
//Turn on double Buffering
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
//create the window
//set renderer
gRenderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
if(gRenderer == NULL){
- std::cout << "The variable 'gRenderer' was not able to initialize! Error: " << SDL_GetError() << std::endl;\
+ std::cout << "The variable 'gRenderer' was not able to initialize! Error: " << SDL_GetError() << std::endl;
}
//background white
SDL_FillRect(renderSurface, NULL, SDL_MapRGB(renderSurface->format, 0xFF, 0xFF, 0xFF));
//closes the window and frees resources
SDL_GL_DeleteContext(mainGLContext);
SDL_DestroyWindow(window);
- SDL_Quit();
return 0;
}