src/render/opengl/SDL_render_gl.c
changeset 6135 b052a5882a47
parent 5981 75caa8a7d559
child 6138 4c64952a58fb
equal deleted inserted replaced
6128:2804d71badce 6135:b052a5882a47
   567                               (pitch / SDL_BYTESPERPIXEL(texture->format)));
   567                               (pitch / SDL_BYTESPERPIXEL(texture->format)));
   568     renderdata->glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w,
   568     renderdata->glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w,
   569                                 rect->h, data->format, data->formattype,
   569                                 rect->h, data->format, data->formattype,
   570                                 pixels);
   570                                 pixels);
   571     if (data->yuv) {
   571     if (data->yuv) {
   572         const void *top;
       
   573 
       
   574         renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, (pitch / 2));
   572         renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, (pitch / 2));
   575 
   573 
   576         /* Skip to the top of the next texture */
       
   577         top = (const void*)((const Uint8*)pixels + (texture->h-rect->y) * pitch - rect->x);
       
   578 
       
   579         /* Skip to the correct offset into the next texture */
   574         /* Skip to the correct offset into the next texture */
   580         pixels = (const void*)((const Uint8*)top + (rect->y / 2) * pitch + rect->x / 2);
   575         pixels = (const void*)((const Uint8*)pixels + rect->h * pitch);
   581         if (texture->format == SDL_PIXELFORMAT_YV12) {
   576         if (texture->format == SDL_PIXELFORMAT_YV12) {
   582             renderdata->glBindTexture(data->type, data->vtexture);
   577             renderdata->glBindTexture(data->type, data->vtexture);
   583         } else {
   578         } else {
   584             renderdata->glBindTexture(data->type, data->utexture);
   579             renderdata->glBindTexture(data->type, data->utexture);
   585         }
   580         }
   586         renderdata->glTexSubImage2D(data->type, 0, rect->x/2, rect->y/2,
   581         renderdata->glTexSubImage2D(data->type, 0, rect->x/2, rect->y/2,
   587                                     rect->w/2, rect->h/2,
   582                                     rect->w/2, rect->h/2,
   588                                     data->format, data->formattype, pixels);
   583                                     data->format, data->formattype, pixels);
   589 
   584 
   590         /* Skip to the top of the next texture */
       
   591         top = (const void*)((const Uint8*)top + (texture->h * pitch)/4);
       
   592 
       
   593         /* Skip to the correct offset into the next texture */
   585         /* Skip to the correct offset into the next texture */
   594         pixels = (const void*)((const Uint8*)top + (rect->y / 2) * pitch + rect->x / 2);
   586         pixels = (const void*)((const Uint8*)pixels + (rect->h * pitch)/4);
   595         if (texture->format == SDL_PIXELFORMAT_YV12) {
   587         if (texture->format == SDL_PIXELFORMAT_YV12) {
   596             renderdata->glBindTexture(data->type, data->utexture);
   588             renderdata->glBindTexture(data->type, data->utexture);
   597         } else {
   589         } else {
   598             renderdata->glBindTexture(data->type, data->vtexture);
   590             renderdata->glBindTexture(data->type, data->vtexture);
   599         }
   591         }