aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarry Jeffery <harry@exec64.co.uk>2015-11-05 23:16:46 +0000
committerHarry Jeffery <harry@exec64.co.uk>2015-11-05 23:16:46 +0000
commitc1d493cf76852759469f21046e5eb68b88b8ad1c (patch)
tree170016bf7066bc41321024f0fedf8b65198e7ef4
parent54d323b5b66d766b636561317d4e139c79ad3fc9 (diff)
downloadimv-c1d493cf76852759469f21046e5eb68b88b8ad1c.tar.gz
Clean up loader.c
-rw-r--r--loader.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/loader.c b/loader.c
index 8d3015f..99d2838 100644
--- a/loader.c
+++ b/loader.c
@@ -1,8 +1,8 @@
#include <SDL2/SDL.h>
#include <string.h>
-extern SDL_Texture* imv_load_png(SDL_Renderer *r, const char* path);
-extern SDL_Texture* imv_load_jpeg(SDL_Renderer *r, const char* path);
+SDL_Texture* imv_load_png(SDL_Renderer *r, const char* path);
+SDL_Texture* imv_load_jpeg(SDL_Renderer *r, const char* path);
SDL_Texture* imv_load_image(SDL_Renderer *r, const char* path)
{
@@ -10,27 +10,15 @@ SDL_Texture* imv_load_image(SDL_Renderer *r, const char* path)
return NULL;
const char* ext = strrchr(path, '.');
- if(ext == NULL) {
- fprintf(stderr,
- "Could not determine filetype of '%s' from its extension.\n",
- path);
- } else if(strcasecmp(ext, ".test") == 0) {
- const int width = 1280;
- const int height = 720;
- SDL_Texture *img = SDL_CreateTexture(r,
- SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STATIC,
- width, height);
- void *pixels = malloc(width*height*3);
- memset(pixels, 255, width*height*3);
- SDL_Rect area = {0,0,width,height};
- SDL_UpdateTexture(img, &area, pixels, width * 3);
- free(pixels);
- return img;
- } else if(strcasecmp(ext, ".png") == 0) {
+
+ if(strcasecmp(ext, ".png") == 0) {
return imv_load_png(r, path);
} else if(strcasecmp(ext, ".jpeg") == 0 || strcasecmp(ext, ".jpg") == 0) {
return imv_load_jpeg(r, path);
}
+ fprintf(stderr,
+ "Could not determine filetype of '%s' from its extension.\n",
+ path);
return NULL;
}