summaryrefslogtreecommitdiff
path: root/src/graphic.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphic.c')
-rw-r--r--src/graphic.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/graphic.c b/src/graphic.c
index a444819..fbe1ae7 100644
--- a/src/graphic.c
+++ b/src/graphic.c
@@ -89,6 +89,9 @@ int init(char *winCaption, gameConfig_t *conf, gameGraphics_t *gGraph) {
return 2;
}
+ gGraph->viewport.w = gGraph->screen->clip_rect.w;
+ gGraph->viewport.h = LEVEL_HEIGHT;
+
// SDL main window caption
SDL_WM_SetCaption(winCaption, NULL);
@@ -113,6 +116,7 @@ int init(char *winCaption, gameConfig_t *conf, gameGraphics_t *gGraph) {
logs2(LOG_ERROR, "init(), SDL_createSurface()", SDL_GetError());
return 3;
}
+ SDL_FillRect(gGraph->surfaces.tmpSurf, &(gGraph->surfaces.tmpSurf->clip_rect), 0xcccccccc);
return 0;
}
@@ -221,34 +225,36 @@ int paintTerrain(gameIni_t *gIni, gameRess_t *gRess, gameGraphics_t *gGraph) {
return 0;
}
-int repaint(gameObjectsState_t *objStates, gameGraphSurfaces_t *srcSurfs, SDL_Rect *srcRect, SDL_Surface *dstSurf, SDL_Rect dstRect) {
+int repaint(gameObjectsState_t *objStates, gameGraphSurfaces_t *srcSurfs, SDL_Rect *srcRect, SDL_Surface *dstSurf) {
int res;
gameObjectsState_t objToRepaint;
-// int i;
+ int i;
+
+ ///findAndZSortObjects(objStates, srcRect, &objToRepaint);
+ objToRepaint=*objStates;
- findAndZSortObjects(objStates, srcRect, &objToRepaint);
-/*
for(i=0;i<objToRepaint.objCount;++i) {
if(objToRepaint.allObj[i].zOrder>0) break;
- res=paintObject(objToRepaint.allObj+i, srcRect, dstSurf, &dstRect);
+ res=paintObject(objToRepaint.allObj+i, dstSurf, *srcRect);
if ( res!=0 ) {
logs(LOG_DEBUG, "repaint(), paintObject() failed");
}
}
-*/
- res=SDL_BlitSurface(srcSurfs->terrain, srcRect, dstSurf, &dstRect);
+ printf("res=SDL_BlitSurface(%p, %p, %p, %p);\n", (void*)srcSurfs->terrain, (void*)srcRect, (void*)dstSurf, (void*)srcRect);
+
+ res=SDL_BlitSurface(srcSurfs->terrain, srcRect, dstSurf, srcRect);
if ( res!=0 ) {
logs2(LOG_DEBUG, "repaint(), SDL_BlitSurface()", SDL_GetError());
}
-/*
+
for(;i<objToRepaint.objCount;++i) {
- res=paintObject(objToRepaint.allObj+i, srcRect, dstSurf, &dstRect);
+ res=paintObject(objToRepaint.allObj+i, dstSurf, *srcRect);
if ( res!=0 ) {
logs(LOG_DEBUG, "repaint(), paintObject() failed");
}
}
-*/
+
return res;
}
@@ -259,10 +265,10 @@ int findAndZSortObjects(gameObjectsState_t *objectsStat, SDL_Rect *offsetRect, g
return 0;
}
-int paintObject(struct gameObjectState *obj, SDL_Rect *srcRect, SDL_Surface *dstSurf, SDL_Rect *dstRect) {
- //TODO
- fprintf(stderr, "TODO paintObject(%p, %p, %p, %p)\n", (void *)obj,(void *)srcRect,(void *)dstSurf, (void *)dstRect);
- return 0;
+int paintObject(struct gameObjectState *obj, SDL_Surface *dstSurf, SDL_Rect dstRect) {
+
+// TODO : blitter tous les objets dans le zOrder, pas que l'objet a rafraichir
+ return SDL_BlitSurface(obj->s, NULL, dstSurf, &dstRect);
}
int refresh(SDL_Surface *tmpSurf, SDL_Rect *srcRect, SDL_Surface *screen, SDL_Rect dstRect) {