Mercurial > hg > dmlib
changeset 7:d427763f113a
Fix "efu" test, use dmImage instead of SDL_image.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 28 Sep 2012 04:37:57 +0300 |
parents | 187f50f02f17 |
children | fc097f7717df |
files | Makefile.gen efu.c |
diffstat | 2 files changed, 12 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile.gen Fri Sep 28 04:34:41 2012 +0300 +++ b/Makefile.gen Fri Sep 28 04:37:57 2012 +0300 @@ -249,7 +249,7 @@ $(BINPATH)efu$(EXEEXT): $(OBJPATH)efu.o $(DMLIB_A) @echo " LINK $+" - @$(CC) -o $@ $+ $(DM_LDFLAGS) -lSDL_ttf -lSDL_image + @$(CC) -o $@ $+ $(DM_LDFLAGS) -lSDL_ttf $(BINPATH)vptest$(EXEEXT): $(OBJPATH)vptest.o $(DMLIB_A) @echo " LINK $+"
--- a/efu.c Fri Sep 28 04:34:41 2012 +0300 +++ b/efu.c Fri Sep 28 04:37:57 2012 +0300 @@ -1,17 +1,13 @@ -#define USE_IMG - #include "dmlib.h" #include "dmargs.h" #include "dmvecmat.h" +#include "dmimage.h" #include <math.h> -#ifdef USE_IMG -#include <SDL_image.h> -#endif #define DM_COLORS (256) char *optFontFile = "font.ttf", - *optBitmapFilename = "tnsp.pcx"; + *optBitmapFilename = "tnsp.png"; BOOL optBenchmark = FALSE; int optVFlags = SDL_SWSURFACE | SDL_HWPALETTE; int optScrWidth = 640, optScrHeight = 480, optFontSize = 20, optScrDepth = 32; @@ -309,7 +305,7 @@ Uint32 lcol; SDL_Event event; int mouseX, mouseY; - BOOL initSDL = FALSE, initTTF = FALSE, exitFlag, showMap = FALSE, initImage = FALSE; + BOOL initSDL = FALSE, initTTF = FALSE, exitFlag, showMap = FALSE; if (!dmArgsProcess(argc, argv, optList, optListN, argHandleOpt, NULL, FALSE)) @@ -339,29 +335,22 @@ } TTF_SetFontStyle(font, TTF_STYLE_NORMAL); -#ifdef USE_IMG - if (IMG_Init(IMG_INIT_PNG) < 0) + + DMResource *res = dmf_create_stdio(optBitmapFilename); + if (res == NULL) { - dmError("Could not initialize SDL_image: %s\n", SDL_GetError()); + dmError("Could not open resource file '%s'.\n", optBitmapFilename); goto error_exit; } - initImage = TRUE; - - SDL_RWops *rwop = SDL_RWFromFile(optBitmapFilename, "rb"); - if (rwop == NULL) - { - dmError("Could not open file '%s'.\n", optBitmapFilename); - goto error_exit; - } - logo = IMG_LoadPCX_RW(rwop); - SDL_RWclose(rwop); + logo = dmLoadImage(res); + dmf_close(res); if (logo == NULL) { dmError("Could not load image file '%s'.\n", optBitmapFilename); goto error_exit; } -#endif - + + if (optBenchmark) { screen = SDL_CreateRGBSurface(SDL_SWSURFACE, optScrWidth, optScrHeight, optScrDepth, 0, 0, 0, 0); @@ -514,11 +503,6 @@ if (initSDL) SDL_Quit(); -#ifdef USE_IMG - if (initImage) - IMG_Quit(); -#endif - if (initTTF) TTF_Quit();