From: Ben Beltran Date: Tue, 13 Aug 2013 20:57:08 +0000 (-0500) Subject: Add image loading. X-Git-Url: https://git.r.bdr.sh/rbdr/super-polarity/commitdiff_plain/2a85937c26e28a825636989b4dfde52f546f8567?ds=inline;hp=7407ac7ff7e7b43ce35771f386e7b259a9c1ba58 Add image loading. --- diff --git a/data/img/static/ben.png b/data/img/static/ben.png new file mode 100644 index 0000000..b2204ae Binary files /dev/null and b/data/img/static/ben.png differ diff --git a/src/main.c b/src/main.c index 97d1e38..602dff3 100644 --- a/src/main.c +++ b/src/main.c @@ -10,32 +10,52 @@ #include #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 -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); } - 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); + // 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. @@ -48,6 +68,8 @@ int main(int argc, const char * argv[]) } } + render(renderer); + endFrame = SDL_GetTicks(); /* see if we have time to sleep */