summaryrefslogtreecommitdiff
path: root/src/netlem.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/netlem.c')
-rw-r--r--src/netlem.c85
1 files changed, 43 insertions, 42 deletions
diff --git a/src/netlem.c b/src/netlem.c
index a6d6c38..630bae9 100644
--- a/src/netlem.c
+++ b/src/netlem.c
@@ -116,6 +116,14 @@ int main(int argc, char **argv) {
atexit(SDL_Quit);
signal(2,signals);
+//TODO TESTS
+ gObjStates.cursor.s = createSurface(32, 32);
+ SDL_FillRect(gObjStates.cursor.s, &(gObjStates.cursor.s->clip_rect), 0x11223344);
+ gObjStates.cursor.zOrder=999;
+
+ gObjStates.allObj=&gObjStates.cursor;
+ gObjStates.objCount=1;
+
// Synchronization tools intialization
semGameStart=SDL_CreateSemaphore(0);
semLoadLevel=SDL_CreateSemaphore(0);
@@ -462,9 +470,10 @@ void processLocalEvents(SDL_Rect *terrain, SDL_Rect *viewport, gameObjectsState_
case SDL_MOUSEMOTION:
mouseX = event.motion.x;
mouseY = event.motion.y;
- objStates->cursor.pos.x = mouseX;
- objStates->cursor.pos.y = mouseY;
+ objStates->cursor.pos.x = mouseX - objStates->cursor.s->w/2;
+ objStates->cursor.pos.y = mouseY - objStates->cursor.s->h/2;
objStates->cursor.dirty=1;
+
break;
case SDL_MOUSEBUTTONDOWN:
//err=mouse_action(&gInit, mouseX, mouseY,camera.x,camera.y );
@@ -505,6 +514,7 @@ int updateGraphics(gameObjectsState_t *objStates, localParams_t *params, gameGra
SDL_Rect srcRect, dstRect;
SDL_Surface *tmpSurf;
struct gameObjectState *o;
+//static Uint32 tmpColor=0;
//TODO : modifier les calques
switch(getState()) {
@@ -514,69 +524,60 @@ int updateGraphics(gameObjectsState_t *objStates, localParams_t *params, gameGra
case eMultiGame:
// If we had a camera movement, we have to refesh all the screen
tmpSurf=gGraph->surfaces.tmpSurf;
- SDL_FillRect(tmpSurf, &(tmpSurf->clip_rect), 0xcccccccc);
- if ( lastViewport.x != gGraph->viewport.x ) {
- lastViewport.x=gGraph->viewport.x;
- dstRect.x=0;
- dstRect.y=0;
- // dstRect.w=0;
- // dstRect.h=0;
- srcRect.x=lastViewport.x;
- srcRect.y=lastViewport.y;
- srcRect.w=gGraph->screen->clip_rect.w;
- srcRect.h=gGraph->screen->clip_rect.h;
- res=repaint(objStates, &gGraph->surfaces, &srcRect, tmpSurf, dstRect);
- if ( res != 0 ) {
- logs(LOG_WARN, "updateGraphics(), repaint() failed");
- }
- refresh(tmpSurf, &srcRect, gGraph->screen, dstRect);
- } else {
+// SDL_FillRect(tmpSurf, &(tmpSurf->clip_rect), tmpColor);
+// tmpColor+=0x11223344;
+ if ( lastViewport.x == gGraph->viewport.x && (params->debugFlags & DEBUG_DIRTYRECTANGLES) == 0 ) {
// We use a dirty rectangle method for performance
for(i=0; i<objStates->objCount; i++) {
o=objStates->allObj+i;
-
- dstRect.x=o->pos.x;
- dstRect.y=o->pos.y;
- dstRect.w=o->s->clip_rect.w;
- dstRect.h=o->s->clip_rect.h;
if ( /*TODO intersect(viewport, dstRect) &&*/ o->dirty == 1 ) {
+ dstRect.x=o->pos.x;
+ dstRect.y=o->pos.y;
+//TODO : pas cencé setter w et h ici
+ dstRect.w=o->s->clip_rect.w;
+ dstRect.h=o->s->clip_rect.h;
+
srcRect.x=o->pos.x+lastViewport.x;
srcRect.y=o->pos.y+lastViewport.y;
srcRect.w=o->s->clip_rect.w;
srcRect.h=o->s->clip_rect.h;
- res=repaint(objStates, &gGraph->surfaces, &srcRect, tmpSurf, srcRect);
+ res=repaint(objStates, &gGraph->surfaces, &srcRect, tmpSurf);
if ( res != 0 ) {
logs(LOG_WARN, "updateGraphics(), repaint() failed");
}
- if ( (params->debugFlags & DEBUG_DIRTYRECTANGLES) == 0 ) {
- res=SDL_BlitSurface(tmpSurf, &srcRect, gGraph->screen, &dstRect);
- if ( res!=0 ) {
- logs2(LOG_DEBUG, "repaint(), SDL_BlitSurface()", SDL_GetError());
- }
- SDL_UpdateRect(gGraph->screen, dstRect.x, dstRect.y, dstRect.w, dstRect.h);
+ if ( (params->debugFlags & DEBUG_DIRTYRECTANGLES) == 0 ) {
+ refresh(tmpSurf, &srcRect, gGraph->screen, dstRect);
}
+ o->dirty=0;
}
}
- }
-
- if ( (params->debugFlags & DEBUG_DIRTYRECTANGLES) == DEBUG_DIRTYRECTANGLES ) {
+ } else {
+ dstRect.x=0;
+ dstRect.y=0;
srcRect.x=lastViewport.x;
srcRect.y=lastViewport.y;
srcRect.w=gGraph->screen->clip_rect.w;
srcRect.h=gGraph->screen->clip_rect.h;
- res=SDL_BlitSurface(tmpSurf, &srcRect, gGraph->screen, NULL);
- if ( res!=0 ) {
- logs2(LOG_DEBUG, "repaint(), SDL_BlitSurface()", SDL_GetError());
+
+ if ( lastViewport.x != gGraph->viewport.x ) {
+ lastViewport.x=gGraph->viewport.x;
+ res=repaint(objStates, &gGraph->surfaces, &srcRect, tmpSurf);
+ if ( res != 0 ) {
+ logs(LOG_WARN, "updateGraphics(), repaint() failed");
+ }
}
- SDL_UpdateRect(gGraph->screen, 0,0,0,0);
- SDL_LockSurface(tmpSurf);
- for(i=0; i < tmpSurf->pitch * tmpSurf->h ; ++i) {
- ((Uint8 *)tmpSurf->pixels)[i] *= 0.9;
+ refresh(tmpSurf, &srcRect, gGraph->screen, dstRect);
+
+ if ( (params->debugFlags & DEBUG_DIRTYRECTANGLES) == DEBUG_DIRTYRECTANGLES ) {
+ SDL_LockSurface(tmpSurf);
+ for(i=0; i < tmpSurf->pitch * tmpSurf->h ; ++i) {
+ ((Uint8 *)tmpSurf->pixels)[i] *= 0.9;
+ }
+ SDL_UnlockSurface(tmpSurf);
}
- SDL_UnlockSurface(tmpSurf);
}
break;
default: