aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorHarry Jeffery <harry@exec64.co.uk>2015-11-05 20:34:05 +0000
committerHarry Jeffery <harry@exec64.co.uk>2015-11-05 20:43:31 +0000
commit0e1a6d0a7ae5053a70c2e35e18ac3713528f0870 (patch)
treefcbc8bd839416ef28e8350f4ccf90b36f711bcf9 /main.c
parent0639d83b2d79e2c03c43cdc85e1cb28630ed14bb (diff)
downloadimv-0e1a6d0a7ae5053a70c2e35e18ac3713528f0870.tar.gz
Add image loading stub
Diffstat (limited to 'main.c')
-rw-r--r--main.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/main.c b/main.c
index 55dce77..b4fae06 100644
--- a/main.c
+++ b/main.c
@@ -1,6 +1,8 @@
#include <stdio.h>
#include <SDL2/SDL.h>
+SDL_Texture* imv_load_image(SDL_Renderer *r, const char* path);
+
int main(int argc, char** argv)
{
if(argc < 2) {
@@ -30,6 +32,7 @@ int main(int argc, char** argv)
const int num_paths = argc - 1;
int cur_path = -1;
int next_path = 0;
+ SDL_Texture *img = NULL;
int quit = 0;
int redraw = 1;
@@ -69,12 +72,21 @@ int main(int argc, char** argv)
if(next_path != cur_path) {
cur_path = next_path;
fprintf(stdout, "current image: %s\n", paths[cur_path]);
+ if(img) {
+ SDL_DestroyTexture(img);
+ img = NULL;
+ }
+ img = imv_load_image(renderer, paths[cur_path]);
redraw = 1;
}
if(redraw) {
SDL_RenderClear(renderer);
- //SDL_RenderCopy(renderer, tex, srcrect, dstrect);
+
+ if(img) {
+ SDL_Rect area = {0,0,width,height};
+ SDL_RenderCopy(renderer, img, &area, &area);
+ }
SDL_RenderPresent(renderer);
redraw = 0;
@@ -82,6 +94,10 @@ int main(int argc, char** argv)
SDL_Delay(10);
}
+ if(img) {
+ SDL_DestroyTexture(img);
+ img = NULL;
+ }
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();