diff options
Diffstat (limited to 'src/graphic.c')
-rw-r--r-- | src/graphic.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/graphic.c b/src/graphic.c index b9990f6..b596be8 100644 --- a/src/graphic.c +++ b/src/graphic.c @@ -76,31 +76,31 @@ int paintTerrain(gameIni_t *gIni, gameRess_t *gRess, gameGraphics_t *gGraph) { Uint32 dstPixel, dstStencil; SDL_Surface *tile; - gGraph->terrain=createSurface(LEVEL_WIDTH, LEVEL_HEIGHT); - if (gGraph->terrain==NULL) { + gGraph->surfaces.terrain=createSurface(LEVEL_WIDTH, LEVEL_HEIGHT); + if (gGraph->surfaces.terrain==NULL) { logs(LOG_ERROR, "paintTerrain(), SDL_CreateRGBSurface() returns NULL"); return 1; } - gGraph->stencil=createSurface(LEVEL_WIDTH, LEVEL_HEIGHT); - if (gGraph->stencil==NULL) { + gGraph->surfaces.stencil=createSurface(LEVEL_WIDTH, LEVEL_HEIGHT); + if (gGraph->surfaces.stencil==NULL) { logs(LOG_ERROR, "paintTerrain(), SDL_CreateRGBSurface() returns NULL"); return 2; } - res=SDL_FillRect(gGraph->terrain, &(gGraph->terrain->clip_rect), gIni->style.bgColor); + res=SDL_FillRect(gGraph->surfaces.terrain, &(gGraph->surfaces.terrain->clip_rect), gIni->style.bgColor); if (res!=0) { logs(LOG_WARN, "paintTerrain(), SDL_FillRect() failed"); return 3; } - res=SDL_FillRect(gGraph->stencil, &(gGraph->stencil->clip_rect), ccc_nothing); + res=SDL_FillRect(gGraph->surfaces.stencil, &(gGraph->surfaces.stencil->clip_rect), ccc_nothing); if (res!=0) { logs(LOG_WARN, "paintTerrain(), SDL_FillRect() failed"); return 4; } - SDL_LockSurface(gGraph->terrain); - SDL_LockSurface(gGraph->stencil); + SDL_LockSurface(gGraph->surfaces.terrain); + SDL_LockSurface(gGraph->surfaces.stencil); for(i=0 ; i < gIni->level.terrainCount ; i++) { //FIXME : check sanity for id value tile=gRess->style.tiles[gIni->level.terrains[i].id]; @@ -131,9 +131,9 @@ int paintTerrain(gameIni_t *gIni, gameRess_t *gRess, gameGraphics_t *gGraph) { // For each tile pixel, without going outside of the terrain ymin=(gIni->level.terrains[i].ypos>=0)?0:-gIni->level.terrains[i].ypos; - ymax=min(tile->clip_rect.h, gGraph->terrain->clip_rect.h - gIni->level.terrains[i].ypos); + ymax=min(tile->clip_rect.h, gGraph->surfaces.terrain->clip_rect.h - gIni->level.terrains[i].ypos); xmin=(gIni->level.terrains[i].xpos>=0)?0:-gIni->level.terrains[i].xpos; - xmax=min(tile->clip_rect.w, gGraph->terrain->clip_rect.w - gIni->level.terrains[i].xpos); + xmax=min(tile->clip_rect.w, gGraph->surfaces.terrain->clip_rect.w - gIni->level.terrains[i].xpos); SDL_LockSurface(tile); for (y=ymin; y<ymax; y+=2) { @@ -152,7 +152,7 @@ int paintTerrain(gameIni_t *gIni, gameRess_t *gRess, gameGraphics_t *gGraph) { // 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(gGraph->stencil, xdst, ydst) == ccc_terrain ) ) { + getPixel(gGraph->surfaces.stencil, xdst, ydst) == ccc_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; @@ -163,22 +163,22 @@ int paintTerrain(gameIni_t *gIni, gameRess_t *gRess, gameGraphics_t *gGraph) { } //FIXME : optimiser le nombre d'appels ici ! - putPixel(gGraph->terrain, xdst, ydst, dstPixel); - putPixel(gGraph->terrain, xdst+1, ydst, dstPixel); - putPixel(gGraph->terrain, xdst, ydst+1, dstPixel); - putPixel(gGraph->terrain, xdst+1, ydst+1, dstPixel); - putPixel(gGraph->stencil, xdst, ydst, dstStencil); - putPixel(gGraph->stencil, xdst+1, ydst, dstStencil); - putPixel(gGraph->stencil, xdst, ydst+1, dstStencil); - putPixel(gGraph->stencil, xdst+1, ydst+1, dstStencil); + putPixel(gGraph->surfaces.terrain, xdst, ydst, dstPixel); + putPixel(gGraph->surfaces.terrain, xdst+1, ydst, dstPixel); + putPixel(gGraph->surfaces.terrain, xdst, ydst+1, dstPixel); + putPixel(gGraph->surfaces.terrain, xdst+1, ydst+1, dstPixel); + putPixel(gGraph->surfaces.stencil, xdst, ydst, dstStencil); + putPixel(gGraph->surfaces.stencil, xdst+1, ydst, dstStencil); + putPixel(gGraph->surfaces.stencil, xdst, ydst+1, dstStencil); + putPixel(gGraph->surfaces.stencil, xdst+1, ydst+1, dstStencil); } } } } SDL_UnlockSurface(tile); } - SDL_UnlockSurface(gGraph->stencil); - SDL_UnlockSurface(gGraph->terrain); + SDL_UnlockSurface(gGraph->surfaces.stencil); + SDL_UnlockSurface(gGraph->surfaces.terrain); return 0; } |