diff options
author | Ludovic Pouzenc <lpouzenc@gmail.com> | 2013-07-20 12:22:01 +0200 |
---|---|---|
committer | Ludovic Pouzenc <lpouzenc@gmail.com> | 2013-07-20 12:22:01 +0200 |
commit | 5d0b6e197f11004753484ad383d66fe0c3588857 (patch) | |
tree | 352680b8d6cc9e3ecf5fa93df8465af22b3ca36d /src/graphic.c | |
parent | 2dc612b3115e7391582a526be524971e19078425 (diff) | |
download | mplemmings-5d0b6e197f11004753484ad383d66fe0c3588857.tar.gz mplemmings-5d0b6e197f11004753484ad383d66fe0c3588857.tar.bz2 mplemmings-5d0b6e197f11004753484ad383d66fe0c3588857.zip |
Correction uint32_t -> Uint32. Debut conversion paint_terrain, ya du
taff...
Diffstat (limited to 'src/graphic.c')
-rw-r--r-- | src/graphic.c | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/src/graphic.c b/src/graphic.c index 1a3fa1f..934e87b 100644 --- a/src/graphic.c +++ b/src/graphic.c @@ -84,51 +84,52 @@ void my_SDL_init_or_die(char title[], SDL_Rect win_pos, Uint32 init_flags, Uint3 //FIXME : to be implmented int paint_terrain(gameIni_t *gIni, gameRess_t *gRess) { - int res, res2, i, modifier; - int x,y,xmin,xmax,ymin,ymax,y2,xdst,ydst; - Uint32 dstPixel, dstStencil, rmask, gmask, bmask, amask; - SDL_Surface *tile; -/* Is necessary ? -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - rmask = 0xff000000; - gmask = 0x00ff0000; - bmask = 0x0000ff00; - amask = 0x000000ff; -#else - rmask = 0x000000ff; - gmask = 0x0000ff00; - bmask = 0x00ff0000; - amask = 0xff000000; -#endif -*/ - rmask = gmask = bmask = amask = 0; // Use default masks - gRess->terrain=SDL_CreateRGBSurface(0, LEVEL_WIDTH, LEVEL_HEIGHT, 32, rmask, gmask, bmask, amask); - gRess->stencil=SDL_CreateRGBSurface(0, LEVEL_WIDTH, LEVEL_HEIGHT, 32, rmask, gmask, bmask, amask); + int res, res2, bpp; +// int i, modifier; +// int x,y,xmin,xmax,ymin,ymax,y2,xdst,ydst; +// Uint32 dstPixel, dstStencil; + Uint32 format, cc_nothing, rmask, gmask, bmask, amask; +// SDL_Surface *tile; + + format=SDL_PIXELFORMAT_ARGB8888; + cc_nothing=0xFF000000; /* Make it portable (big endian) */ + + res=SDL_PixelFormatEnumToMasks(format, &bpp, &rmask, &gmask, &bmask, &amask); + MPL_CHECK( + res==SDL_TRUE, + { return 1; }, + SDL_LOG_PRIORITY_CRITICAL, + "paintTerrain(), SDL_PixelFormatEnumToMasks(SDL_PIXELFORMAT_ARGB8888, ...) failed" + ); + gRess->terrain=SDL_CreateRGBSurface(0, LEVEL_WIDTH, LEVEL_HEIGHT, bpp, rmask, gmask, bmask, amask); + gRess->stencil=SDL_CreateRGBSurface(0, LEVEL_WIDTH, LEVEL_HEIGHT, bpp, rmask, gmask, bmask, amask); MPL_CHECK( gRess->terrain && gRess->stencil, - { return 1; }, + { return 2; }, SDL_LOG_PRIORITY_CRITICAL, "paintTerrain(), SDL_CreateRGBSurface() failed" ); + /* Fill the entire surfaces with default color */ res=SDL_FillRect(gRess->terrain, NULL, gIni->style.bgColor); - res2=SDL_FillRect(gRess->stencil, NULL, ccc_nothing); + res2=SDL_FillRect(gRess->stencil, NULL, cc_nothing); MPL_CHECK( res==0 && res2==0, - { return 2; }, + { return 3; }, SDL_LOG_PRIORITY_CRITICAL, "paintTerrain(), SDL_FillRect() failed" ); - SDL_LockSurface(gRess->terrain); +#if 0 + SDL_LockSurface(gRess->terrain); /*XXX Only if RLE encoded. To be removed ? */ SDL_LockSurface(gRess->stencil); for(i=0 ; i < gIni->level.terrainCount ; i++) { int tid=gIni->level.terrains[i].id; MPL_CHECK( tid > 0 && tid < MAX_TILES_COUNT, - { return 3; }, + { return 4; }, SDL_LOG_PRIORITY_CRITICAL, "paintTerrain(), gIni->level.terrains[%].id == %i and it's out of range", i, tid ); @@ -136,7 +137,7 @@ int paint_terrain(gameIni_t *gIni, gameRess_t *gRess) { tile=gRess->tiles[tid]; MPL_CHECK( tile, - { return 4; }, + { return 5; }, SDL_LOG_PRIORITY_CRITICAL, "paintTerrain(), tile %i was not loaded", tid ); @@ -184,14 +185,14 @@ int paint_terrain(gameIni_t *gIni, gameRess_t *gRess) { // Always paint pixel, except in one case: // If we are in NO_OVERRIDE mode and there is already a terrain on the current (source) pixel if ( !( (modifier & 8) == 8 && - getPixel(gRess->stencil, xdst, ydst) == ccc_terrain ) ) { + getPixel(gRess->stencil, xdst, ydst) == cc_terrain ) ) { // If we have REMOVE modifier, dstPixel will be rolled back to bgColor, else, it will be identical to the source pixel. We have to update stencil consistenly. if ( (modifier & 2) == 2 ) { dstPixel=gIni->style.bgColor; - dstStencil=ccc_nothing; + dstStencil=cc_nothing; } else { dstPixel=getPixel8BitPalette(tile, x, y2); - dstStencil=ccc_terrain; + dstStencil=cc_terrain; } putPixel(gRess->terrain,xdst,ydst,dstPixel); putPixel(gRess->stencil,xdst,ydst,dstStencil); @@ -203,7 +204,7 @@ int paint_terrain(gameIni_t *gIni, gameRess_t *gRess) { } SDL_UnlockSurface(gRess->stencil); SDL_UnlockSurface(gRess->terrain); - +#endif return 0; } |