Fixed bug 4914 - Expose SDL_ScaleMode and add SDL_SetTextureScaleMode/SDL_GetTextureScaleMode
Konrad This was something rather trivial to add, but asked at least several times before (I did google about it as well). It should be possible to dynamically change scaling mode of the texture. It is actually trivial task, but until now it was only possible with a hint before creating a texture. I needed it for my game as well, so I took the liberty of writing it myself. This patch adds following functions: SDL_SetTextureScaleMode(SDL_Texture * texture, SDL_ScaleMode scaleMode); SDL_GetTextureScaleMode(SDL_Texture * texture, SDL_ScaleMode *scaleMode); That way you can change texture scaling on the fly.
This commit is contained in:
parent
0d52bf57d7
commit
b88aaba9c1
14 changed files with 212 additions and 7 deletions
|
@ -722,6 +722,18 @@ D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
D3D_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode)
|
||||
{
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
|
||||
|
||||
if (!texturedata) {
|
||||
return;
|
||||
}
|
||||
|
||||
texturedata->scaleMode = (scaleMode == SDL_ScaleModeNearest) ? D3DTEXF_POINT : D3DTEXF_LINEAR;
|
||||
}
|
||||
|
||||
static int
|
||||
D3D_SetRenderTargetInternal(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
|
@ -1704,6 +1716,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
|
|||
renderer->UpdateTextureYUV = D3D_UpdateTextureYUV;
|
||||
renderer->LockTexture = D3D_LockTexture;
|
||||
renderer->UnlockTexture = D3D_UnlockTexture;
|
||||
renderer->SetTextureScaleMode = D3D_SetTextureScaleMode;
|
||||
renderer->SetRenderTarget = D3D_SetRenderTarget;
|
||||
renderer->QueueSetViewport = D3D_QueueSetViewport;
|
||||
renderer->QueueSetDrawColor = D3D_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue