]> git.r.bdr.sh - rbdr/super-polarity/commitdiff
Add image loading.
authorBen Beltran <redacted>
Tue, 13 Aug 2013 20:57:08 +0000 (15:57 -0500)
committerBen Beltran <redacted>
Tue, 13 Aug 2013 20:57:08 +0000 (15:57 -0500)
data/img/static/ben.png [new file with mode: 0644]
src/main.c

diff --git a/data/img/static/ben.png b/data/img/static/ben.png
new file mode 100644 (file)
index 0000000..b2204ae
Binary files /dev/null and b/data/img/static/ben.png differ
index 97d1e38facb0e054e792dff023ba7ce5f343f534..602dff33c942b2a89952eb13ee5890e8413c8458 100644 (file)
 #include <time.h>
 
 #include "SDL2/SDL.h"
 #include <time.h>
 
 #include "SDL2/SDL.h"
+#include "SDL2_image/SDL_image.h"
 
 // TODO: Move these guys to a config header file
 #define SCREEN_WIDTH 640
 #define SCREEN_HEIGHT 480
 #define FPS 30
 
 
 // TODO: Move these guys to a config header file
 #define SCREEN_WIDTH 640
 #define SCREEN_HEIGHT 480
 #define FPS 30
 
-int main(int argc, const char * argv[])
-{
-    
-    // SDL Initialization. TODO: Should have an initializer.
-    SDL_Window *window;
-    SDL_Renderer *renderer;
-    Uint32 startFrame;
-    Uint32 endFrame;
-    Uint32 delay;
-    int done;
-    
+SDL_Window *window;
+SDL_Renderer *renderer;
+SDL_Surface *benHead;
+
+void init () {
     if (SDL_Init(SDL_INIT_VIDEO) < 0) {
         printf("Could not initialize SDL");
         exit(1);
     }
     
     if (SDL_Init(SDL_INIT_VIDEO) < 0) {
         printf("Could not initialize SDL");
         exit(1);
     }
     
-    window = SDL_CreateWindow("Super Polarity", 50, 50, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS);
+    // Load the window and renderer
+    window = SDL_CreateWindow("Super Polarity", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 0, 0, SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN_DESKTOP);
     
     renderer = SDL_CreateRenderer(window, -1, 0);
     
     
     renderer = SDL_CreateRenderer(window, -1, 0);
     
+    // Set linear quality for scaling, and the "logical" window size.
+    SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
+    SDL_RenderSetLogicalSize(renderer, SCREEN_WIDTH, SCREEN_HEIGHT);
+    
+    // Load the surface.
+    // benHead = IMG_Load("data/img/static/ben.png");
+}
+
+void render (SDL_Renderer *renderer) {
+    SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
+    SDL_RenderClear(renderer);
+    SDL_RenderPresent(renderer);
+}
+
+int mainC(int argc, const char * argv[])
+{
+    
+    // SDL Initialization. TODO: Should have an initializer.
+    Uint32 startFrame;
+    Uint32 endFrame;
+    Uint32 delay;
+    int done;
+   
+    
     done = 0;
     
     // Event Loop.
     done = 0;
     
     // Event Loop.
@@ -48,6 +68,8 @@ int main(int argc, const char * argv[])
             }
         }
         
             }
         }
         
+        render(renderer);
+        
         endFrame = SDL_GetTicks();
         
         /* see if we have time to sleep */
         endFrame = SDL_GetTicks();
         
         /* see if we have time to sleep */