You don't need to copy the pixels into the streaming texture's pixel data. This behavior is defined specifically to optimize the UpdateTexture path.
This commit is contained in:
parent
1c8816f6fe
commit
87ca0acb3f
2 changed files with 3 additions and 25 deletions
|
@ -164,7 +164,7 @@ main(int argc, char *argv[])
|
||||||
} else if (delay > MILLESECONDS_PER_FRAME) {
|
} else if (delay > MILLESECONDS_PER_FRAME) {
|
||||||
delay = MILLESECONDS_PER_FRAME;
|
delay = MILLESECONDS_PER_FRAME;
|
||||||
}
|
}
|
||||||
//SDL_Delay(delay);
|
SDL_Delay(delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
|
|
|
@ -389,35 +389,13 @@ GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect
|
||||||
tdata->pixel_format,
|
tdata->pixel_format,
|
||||||
tdata->pixel_type,
|
tdata->pixel_type,
|
||||||
src);
|
src);
|
||||||
|
SDL_free(blob);
|
||||||
|
|
||||||
if (glGetError() != GL_NO_ERROR)
|
if (glGetError() != GL_NO_ERROR)
|
||||||
{
|
{
|
||||||
SDL_SetError("Failed to update texture");
|
SDL_SetError("Failed to update texture");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the (streaming) texture buffer, in one pass if possible */
|
|
||||||
if (tdata->pixel_data)
|
|
||||||
{
|
|
||||||
dest = (Uint8 *)tdata->pixel_data +
|
|
||||||
(tdata->pitch * rect->y) +
|
|
||||||
(SDL_BYTESPERPIXEL(texture->format) * rect->x);
|
|
||||||
if (rect->w == texture->w)
|
|
||||||
{
|
|
||||||
SDL_memcpy(dest, src, srcPitch * rect->h);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (y = 0; y < rect->h; ++y)
|
|
||||||
{
|
|
||||||
SDL_memcpy(dest, src, srcPitch);
|
|
||||||
src += srcPitch;
|
|
||||||
dest += tdata->pitch;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Clean up and return */
|
|
||||||
SDL_free(blob);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue