How copy a rettangular?

Hi, in attachment ou have my code that does not work…
I create a window 640x480 pixels. I set a background color (green). Create
a second Surface of 100x100 pixels-dimension. The color of this surface is
pink. I copy surface2 to surface1, but I have only a black rectangular.
Why it? where is my error?

tnx in advance…–
Michel Morelli michel at enter.it
http://ziobudda.enter.it
Italian Linux FAQ http://ziobudda.enter.it/FAQ/
Italian Linux Press http://ziobudda.enter.it/ILP/
-------------- next part --------------
nclude "SDL.h"
SDL_Rect rett;

int MouseInRect(const SDL_Event event)
{ //printf(“dati event: %d - %d\n dati rett: %d - %d - %d - %d”,event->motion.x,
// event->motion.y, rett.x,rett.y, rett.x+rett.w,rett.y+rett.h);
if (event->motion.x > rett.x &&
event->motion.x < (rett.x+rett.w) &&
event->motion.y > rett.y &&
event->motion.y < (rett.y+rett.h))
{ return (1);
}
else {
return(0);
}
}
/
This function may run in a separate event thread */
int FilterEvents(const SDL_Event *event) {
static int boycott = 1;
static int mousedown = 0;

					        //printf("Event type = %d\n",event->type);
						        if (event->type == SDL_MOUSEBUTTONDOWN)
							         { mousedown = 1;
								          }
									          else { 
										           if (event->type == SDL_MOUSEBUTTONUP)
											             { mousedown = 0;   
												               }
													               }
														               if ( event->type == SDL_MOUSEMOTION ) {
															                       
																	                       /*printf("Mouse moved to (%d,%d)\n",
																			                                               event->motion.x, event->motion.y);
																								                       */
																										                    if (MouseInRect(event) && mousedown == 1)
																												                   { printf("premuto nel rettangolo\n");
																														                  }
																																               else { if (MouseInRect(event) && mousedown == 0)
																																	                            { printf("non premuto ma nel rettangolo\n");
																																				                         }
																																							                     else {printf("mouse non nel rett\n");
																																									                              }
																																												                   }
																																														                return(0);      /* Drop it, we've handled it */
																																																        }
																																																	        else {
																																																		          if (event->type == SDL_KEYDOWN)
																																																			              { printf("pulito!!!\n");
																																																				                    exit(0);
																																																						                }
																																																								        }
																																																									        return(1);
																																																										}

																																																										/*
																																																										**      Function name : main
																																																										**
																																																										**      Description :
																																																										**      Input :
																																																										**      Output :
																																																										*/
																																																										int main(void)
																																																										{ SDL_Surface *screen, *screen2;
																																																										  char *bmpfile = "";
																																																										    int i;
																																																										                 return(0);      /* Drop it, we've handled it */
																																																												         }
																																																													         else {
																																																														           if (event->type == SDL_KEYDOWN)
																																																															               { printf("pulito!!!\n");
																																																																                     exit(0);
																																																																		                 }
																																																																				         }
																																																																					         return(1);
																																																																						 }

																																																																						 /*
																																																																						 **      Function name : main
																																																																						 **
																																																																						 **      Description :
																																																																						 **      Input :
																																																																						 **      Output :
																																																																						 */
																																																																						 int main(void)
																																																																						 { SDL_Surface *screen, *screen2;
																																																																						   char *bmpfile = "";
																																																																						     int i;
																																																																						       SDL_Surface *picture;
																																																																						         Uint32 color2;
																																																																							   //SDL_Rect rett;
																																																																							     SDL_Event event;

																																																																							       rett.x=10; rett.y=10; rett.w=100; rett.h=100;

																																																																							         /* Initialize the SDL library */
																																																																								   if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
																																																																								    
																																																																								        fprintf(stderr,
																																																																									            "Couldn't initialize SDL: %s\n", SDL_GetError());
																																																																										        exit(1);
																																																																											  }
																																																																											    
																																																																											      /* Clean up on exit */
																																																																											        atexit(SDL_Quit);

																																																																												  SDL_EventState(SDL_KEYDOWN,SDL_ENABLE);
																																																																												    //SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
																																																																												      
																																																																												        SDL_SetEventFilter(FilterEvents);
																																																																													  
																																																																													    /* Initialize the display in a 640x480 8-bit palettized mode */
																																																																													      screen = SDL_SetVideoMode(640, 480, 8, 0);
																																																																													        screen2 = SDL_AllocSurface(SDL_SWSURFACE,100,100,8,0,0,0,0);
																																																																														  
																																																																														    if ( screen == NULL ) {
																																																																														        fprintf(stderr, "Couldn't set 640x480x8 video mode: %s\n",
																																																																															            SDL_GetError());
																																																																																        exit(1);
																																																																																	  }
																																																																																	   
																																																																																	     /* Definisco lo sfondo */
																																																																																	       if ( SDL_LockSurface(screen) == 0 ) {
																																																																																	                       Uint32 black;
																																																																																			                       Uint8 *pixels;

																																																																																					                       SDL_LockSurface(screen2);
																																																																																							                       black = SDL_MapRGB(screen->format, 10, 50, 90);
																																																																																									                       color2 = SDL_MapRGB(screen->format, 100,100,100);
																																																																																											                       SDL_FillRect(screen, NULL, black);
																																																																																													                       //SDL_FillRect(screen2, NULL, black);
																																																																																															                       SDL_FillRect(screen2, NULL, color2);
																																																																																																	                       SDL_UnlockSurface(screen2);
																																																																																																			                       SDL_UpdateRect(screen2, 0, 0, 0, 0);

																																																																																																					                       SDL_BlitSurface(screen2, NULL, screen, &rett);
																																																																																																							                       SDL_UnlockSurface(screen);
																																																																																																									                       SDL_UpdateRect(screen, 0, 0, 0, 0);
																																																																																																											               }
																																																																																																												         
																																																																																																													   if ( bmpfile == NULL ) {
																																																																																																													                   bmpfile = "sample.bmp";         /* Sample image */
																																																																																																															           }

																																																																																																																     picture = SDL_LoadBMP(bmpfile);
																																																																																																																       
																																																																																																																         while ( SDL_WaitEvent(&event) >= 0 ) {
																																																																																																																	   }
																																																																																																																	   }