src/video/photon/SDL_ph_image.c
changeset 380 bce7171e7a85
parent 370 ba72f259bc88
child 571 8e3ce997621c
     1.1 --- a/src/video/photon/SDL_ph_image.c	Tue May 28 19:24:11 2002 +0000
     1.2 +++ b/src/video/photon/SDL_ph_image.c	Tue May 28 19:31:32 2002 +0000
     1.3 @@ -38,11 +38,14 @@
     1.4  
     1.5  int ph_SetupImage(_THIS, SDL_Surface *screen)
     1.6  {
     1.7 +    PgColor_t* palette=NULL;
     1.8      int type=0;
     1.9 -    PgColor_t* palette=NULL;
    1.10 +    int bpp;
    1.11 +    
    1.12 +    bpp=screen->format->BitsPerPixel;
    1.13  
    1.14      /* Determine image type */
    1.15 -    switch(screen->format->BitsPerPixel)
    1.16 +    switch(bpp)
    1.17      {
    1.18          case 8:{
    1.19              type = Pg_IMAGE_PALETTE_BYTE;
    1.20 @@ -65,14 +68,14 @@
    1.21          }
    1.22          break;
    1.23          default:{
    1.24 -            fprintf(stderr,"ph_SetupImage(): unsupported bbp = %d\n", screen->format->BitsPerPixel);
    1.25 +            fprintf(stderr,"ph_SetupImage(): unsupported bbp = %d\n", bpp);
    1.26              return -1;
    1.27          }
    1.28          break;
    1.29      }
    1.30  
    1.31      /* palette emulation code */
    1.32 -    if ((screen->format->BitsPerPixel==8) && (desktoppal==SDLPH_PAL_EMULATE))
    1.33 +    if ((bpp==8) && (desktoppal==SDLPH_PAL_EMULATE))
    1.34      {
    1.35          /* creating image palette */
    1.36          palette=malloc(_Pg_MAX_PALETTE*sizeof(PgColor_t));
    1.37 @@ -81,7 +84,7 @@
    1.38          /* using shared memory for speed (set last param to 1) */
    1.39          if ((SDL_Image = PhCreateImage(NULL, screen->w, screen->h, type, palette, _Pg_MAX_PALETTE, 1)) == NULL)
    1.40          {
    1.41 -            fprintf(stderr,"ph_SetupImage: PhCreateImage failed for bpp=8.\n");
    1.42 +            fprintf(stderr,"ph_SetupImage(): PhCreateImage failed for bpp=8.\n");
    1.43              return -1;
    1.44          }
    1.45      }
    1.46 @@ -94,8 +97,9 @@
    1.47              return -1;
    1.48          }
    1.49      }
    1.50 -
    1.51 +    
    1.52      screen->pixels = SDL_Image->image;
    1.53 +    screen->pitch = SDL_Image->bpl; /* Recalculated pitch, created by PhCreateImage */
    1.54  
    1.55      this->UpdateRects = ph_NormalUpdate;
    1.56  
    1.57 @@ -105,9 +109,12 @@
    1.58  int ph_SetupOCImage(_THIS, SDL_Surface *screen)
    1.59  {
    1.60      int type = 0;
    1.61 +    int bpp;
    1.62 +    
    1.63 +    bpp=screen->format->BitsPerPixel;
    1.64  
    1.65      /* Determine image type */
    1.66 -    switch(screen->format->BitsPerPixel)
    1.67 +    switch(bpp)
    1.68      {
    1.69          case 8: {
    1.70                      type = Pg_IMAGE_PALETTE_BYTE;
    1.71 @@ -130,7 +137,7 @@
    1.72                  }
    1.73                  break;
    1.74          default:{
    1.75 -                    fprintf(stderr,"ph_SetupOCImage(): unsupported bpp = %d\n", screen->format->BitsPerPixel);
    1.76 +                    fprintf(stderr,"ph_SetupOCImage(): unsupported bpp = %d\n", bpp);
    1.77                      return -1;
    1.78                  }
    1.79                  break;
    1.80 @@ -138,6 +145,8 @@
    1.81  
    1.82      OCImage.FrameData0 = (FRAMEDATA *) malloc((size_t)(sizeof(FRAMEDATA)));
    1.83      OCImage.FrameData1 = (FRAMEDATA *) malloc((size_t)(sizeof(FRAMEDATA)));
    1.84 +    memset(OCImage.FrameData0, 0x00, (size_t)(sizeof(FRAMEDATA)));
    1.85 +    memset(OCImage.FrameData1, 0x00, (size_t)(sizeof(FRAMEDATA)));
    1.86  
    1.87      if(OCImage.direct_context == NULL)
    1.88      {
    1.89 @@ -152,7 +161,7 @@
    1.90          return -1;
    1.91      }
    1.92  
    1.93 -    OCImage.Stride = OCImage.offscreen_context->pitch;	
    1.94 +    screen->pitch = OCImage.offscreen_context->pitch; /* Recalculated pitch */
    1.95  
    1.96      if (OCImage.flags & SDL_DOUBLEBUF)
    1.97      {
    1.98 @@ -269,10 +278,6 @@
    1.99      return;
   1.100  }
   1.101  
   1.102 -static PhPoint_t ph_pos;
   1.103 -static PhRect_t ph_rect;
   1.104 -static int i;
   1.105 -
   1.106  void ph_OpenGLUpdate(_THIS, int numrects, SDL_Rect* rects)
   1.107  {
   1.108     this->GL_SwapBuffers(this);
   1.109 @@ -282,7 +287,11 @@
   1.110  
   1.111  void ph_NormalUpdate(_THIS, int numrects, SDL_Rect *rects)
   1.112  {
   1.113 -    for ( i=0; i<numrects; ++i ) 
   1.114 +    PhPoint_t ph_pos;
   1.115 +    PhRect_t ph_rect;
   1.116 +    int i;
   1.117 +
   1.118 +    for (i=0; i<numrects; ++i) 
   1.119      {
   1.120      	if (rects[i].w==0) /* Clipped? */
   1.121          { 
   1.122 @@ -310,6 +319,8 @@
   1.123  
   1.124  void ph_OCUpdate(_THIS, int numrects, SDL_Rect *rects)
   1.125  {
   1.126 +    int i;
   1.127 +
   1.128      PhPoint_t zero = {0};
   1.129      PhArea_t src_rect;
   1.130      PhArea_t dest_rect;