src/video/SDL_renderer_gl.c
changeset 3443 7f477a22dff5
parent 3440 e9502d56ae94
child 3446 0f969d273f65
equal deleted inserted replaced
3442:204609180482 3443:7f477a22dff5
  1271     if (pixel_format == SDL_PIXELFORMAT_INDEX1LSB) {
  1271     if (pixel_format == SDL_PIXELFORMAT_INDEX1LSB) {
  1272         data->glPixelStorei(GL_PACK_LSB_FIRST, 1);
  1272         data->glPixelStorei(GL_PACK_LSB_FIRST, 1);
  1273     } else if (pixel_format == SDL_PIXELFORMAT_INDEX1MSB) {
  1273     } else if (pixel_format == SDL_PIXELFORMAT_INDEX1MSB) {
  1274         data->glPixelStorei(GL_PACK_LSB_FIRST, 0);
  1274         data->glPixelStorei(GL_PACK_LSB_FIRST, 0);
  1275     }
  1275     }
  1276     data->glPixelStorei(GL_PACK_ALIGNMENT, 1);
  1276     //data->glPixelStorei(GL_PACK_ALIGNMENT, 1);
  1277     data->glPixelStorei(GL_PACK_ROW_LENGTH,
  1277     //data->glPixelStorei(GL_PACK_ROW_LENGTH,
  1278                         (pitch / bytes_per_pixel(pixel_format)));
  1278     //                    (pitch / bytes_per_pixel(pixel_format)));
  1279 
  1279     data->glReadBuffer(GL_FRONT);
       
  1280 
       
  1281 memset(pixels, 0xff, rect->h*pitch);
  1280     data->glReadPixels(rect->x, rect->y+rect->h-1, rect->w, rect->h,
  1282     data->glReadPixels(rect->x, rect->y+rect->h-1, rect->w, rect->h,
  1281                        format, type, pixels);
  1283                        format, type, pixels);
  1282 
  1284 
       
  1285 #if 0
  1283     /* Flip the rows to be top-down */
  1286     /* Flip the rows to be top-down */
  1284     length = rect->w * bytes_per_pixel(pixel_format);
  1287     length = rect->w * bytes_per_pixel(pixel_format);
  1285     src = (Uint8*)pixels + (rect->h-1)*pitch;
  1288     src = (Uint8*)pixels + (rect->h-1)*pitch;
  1286     dst = (Uint8*)pixels;
  1289     dst = (Uint8*)pixels;
  1287     tmp = SDL_stack_alloc(Uint8, length);
  1290     tmp = SDL_stack_alloc(Uint8, length);
  1290         SDL_memcpy(tmp, dst, length);
  1293         SDL_memcpy(tmp, dst, length);
  1291         SDL_memcpy(dst, src, length);
  1294         SDL_memcpy(dst, src, length);
  1292         SDL_memcpy(src, tmp, length);
  1295         SDL_memcpy(src, tmp, length);
  1293     }
  1296     }
  1294     SDL_stack_free(tmp);
  1297     SDL_stack_free(tmp);
       
  1298 #endif
  1295 
  1299 
  1296     return 0;
  1300     return 0;
  1297 }
  1301 }
  1298 
  1302 
  1299 static int
  1303 static int