Skip to content

Commit

Permalink
Revert to SDL_UpdateTexture; it is faster (#500)
Browse files Browse the repository at this point in the history
  • Loading branch information
cxong authored May 24, 2017
1 parent 5d01f62 commit 7f2fae6
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions src/cdogs/blit.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,32 +403,7 @@ void BlitClearBuf(GraphicsDevice *g)
}
void BlitUpdateFromBuf(GraphicsDevice *g, SDL_Texture *t)
{
int textureAccess;
if (SDL_QueryTexture(t, NULL, &textureAccess, NULL, NULL) != 0)
{
LOG(LM_GFX, LL_ERROR, "Failed to query texture: %s", SDL_GetError());
return;
}
if (textureAccess == SDL_TEXTUREACCESS_STATIC)
{
SDL_UpdateTexture(
t, NULL, g->buf, g->cachedConfig.Res.x * sizeof(Uint32));
}
else
{
CASSERT(
textureAccess == SDL_TEXTUREACCESS_STREAMING,
"invalid texture access");
void *pixels;
int pitch;
if (SDL_LockTexture(t, NULL, &pixels, &pitch) != 0)
{
LOG(LM_GFX, LL_ERROR, "Failed to lock texture: %s", SDL_GetError());
return;
}
memcpy(pixels, g->buf, GraphicsGetMemSize(&g->cachedConfig));
SDL_UnlockTexture(t);
}
SDL_UpdateTexture(t, NULL, g->buf, g->cachedConfig.Res.x * sizeof(Uint32));
}

static void RenderTexture(SDL_Renderer *r, SDL_Texture *t);
Expand Down

0 comments on commit 7f2fae6

Please sign in to comment.