]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Init'd SDL_image
authorClyne Sullivan <tullivan99@gmail.com>
Tue, 8 Sep 2015 23:25:17 +0000 (19:25 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Tue, 8 Sep 2015 23:25:17 +0000 (19:25 -0400)
src/main.cpp

index 27cc080ad713f973cfac57b4969e4dac32e020d0..71b6595f09dc783e80cc0230174a9c18ece675af 100644 (file)
@@ -11,11 +11,13 @@ Window win;
 
 int main(int argc,char **argv){
     //runs start-up procedures
-    if(SDL_Init(SDL_INIT_VIDEO) < 0){
-               std::cout << "SDL was not able to initialize! Error: " << SDL_GetError() << std::endl;
-               return -1;
-       }else{
-               atexit(SDL_Quit);
+    if(!SDL_Init(SDL_INIT_VIDEO)){
+       atexit(SDL_Quit);
+       if(!(IMG_Init(IMG_INIT_PNG)&IMG_INIT_PNG)){
+                       std::cout<<"Could not init image libraries!\n"<<std::endl;
+                       return -1;
+               }
+               atexit(IMG_Quit);
                //Turn on double Buffering
         SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
         //create the window
@@ -24,17 +26,20 @@ int main(int argc,char **argv){
                                   | SDL_WINDOW_FULLSCREEN
                                   #endif // FULLSCREEN
                                   );
-        if(window == NULL){
-               std::cout << "The window failed to generate! Error: " << SDL_GetError() << std::endl;
-               return -1;
-        }else{
-            //set OpenGL context
+        if(window){
+               //set OpenGL context
             mainGLContext = SDL_GL_CreateContext(window);
             if(mainGLContext == NULL){
                std::cout << "The OpenGL context failed to initialize! Error: " << SDL_GetError() << std::endl;
             }
-               }
-    }
+               }else{
+                       std::cout << "The window failed to generate! Error: " << SDL_GetError() << std::endl;
+               return -1;
+        }
+    }else{
+               std::cout << "SDL was not able to initialize! Error: " << SDL_GetError() << std::endl;
+               return -1;
+       }
        
        
        /**************************