src/render/opengles2/SDL_render_gles2.c
changeset 7420 fe82b639c4d6
parent 7239 04dda95ba22c
child 7502 6ff02ff3cf06
equal deleted inserted replaced
7419:a22566f42281 7420:fe82b639c4d6
  1506 static int
  1506 static int
  1507 GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
  1507 GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
  1508                     Uint32 pixel_format, void * pixels, int pitch)
  1508                     Uint32 pixel_format, void * pixels, int pitch)
  1509 {
  1509 {
  1510     GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
  1510     GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
  1511     SDL_Window *window = renderer->window;
       
  1512     Uint32 temp_format = SDL_PIXELFORMAT_ABGR8888;
  1511     Uint32 temp_format = SDL_PIXELFORMAT_ABGR8888;
  1513     void *temp_pixels;
  1512     void *temp_pixels;
  1514     int temp_pitch;
  1513     int temp_pitch;
  1515     Uint8 *src, *dst, *tmp;
  1514     Uint8 *src, *dst, *tmp;
  1516     int w, h, length, rows;
  1515     int w, h, length, rows;
  1522     temp_pixels = SDL_malloc(rect->h * temp_pitch);
  1521     temp_pixels = SDL_malloc(rect->h * temp_pitch);
  1523     if (!temp_pixels) {
  1522     if (!temp_pixels) {
  1524         return SDL_OutOfMemory();
  1523         return SDL_OutOfMemory();
  1525     }
  1524     }
  1526 
  1525 
  1527     SDL_GetWindowSize(window, &w, &h);
  1526     SDL_GetRendererOutputSize(renderer, &w, &h);
  1528 
  1527 
  1529     rdata->glPixelStorei(GL_PACK_ALIGNMENT, 1);
  1528     rdata->glPixelStorei(GL_PACK_ALIGNMENT, 1);
  1530 
  1529 
  1531     rdata->glReadPixels(rect->x, (h-rect->y)-rect->h, rect->w, rect->h,
  1530     rdata->glReadPixels(rect->x, (h-rect->y)-rect->h, rect->w, rect->h,
  1532                        GL_RGBA, GL_UNSIGNED_BYTE, temp_pixels);
  1531                        GL_RGBA, GL_UNSIGNED_BYTE, temp_pixels);