mirror of
https://github.com/blupi-games/planetblupi
synced 2024-12-30 10:15:36 +01:00
Add a BltFast function with src and dst rect
This commit is contained in:
parent
f4caf6a1b1
commit
dfe3647a74
@ -101,13 +101,44 @@ CPixmap::Create (Point dim)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Sint32
|
||||||
|
CPixmap::BltFast (Sint32 dstCh, size_t srcCh, Rect dstR, Rect srcR)
|
||||||
|
{
|
||||||
|
Sint32 res;
|
||||||
|
|
||||||
|
SDL_Rect srcRect, dstRect;
|
||||||
|
srcRect.x = srcR.left;
|
||||||
|
srcRect.y = srcR.top;
|
||||||
|
srcRect.w = srcR.right - srcR.left;
|
||||||
|
srcRect.h = srcR.bottom - srcR.top;
|
||||||
|
dstRect.x = dstR.left;
|
||||||
|
dstRect.y = dstR.top;
|
||||||
|
dstRect.w = dstR.right - dstR.left;
|
||||||
|
dstRect.h = dstR.bottom - dstR.top;
|
||||||
|
|
||||||
|
if (dstCh < 0)
|
||||||
|
{
|
||||||
|
res = SDL_RenderCopy (
|
||||||
|
g_renderer, m_SDLTextureInfo[srcCh].texture, &srcRect, &dstRect);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SDL_SetRenderTarget (g_renderer, m_SDLTextureInfo[dstCh].texture);
|
||||||
|
res = SDL_RenderCopy (
|
||||||
|
g_renderer, m_SDLTextureInfo[srcCh].texture, &srcRect, &dstRect);
|
||||||
|
SDL_SetRenderTarget (g_renderer, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
// Effectue un appel BltFast.
|
// Effectue un appel BltFast.
|
||||||
// Les modes sont 0=transparent, 1=opaque.
|
// Les modes sont 0=transparent, 1=opaque.
|
||||||
|
|
||||||
Sint32
|
Sint32
|
||||||
CPixmap::BltFast (Sint32 chDst, size_t channel, Point dst, Rect rcRect)
|
CPixmap::BltFast (Sint32 chDst, size_t channel, Point dst, Rect rcRect)
|
||||||
{
|
{
|
||||||
Sint32 res, limit;
|
Sint32 limit;
|
||||||
|
|
||||||
// Effectue un peu de clipping.
|
// Effectue un peu de clipping.
|
||||||
if (dst.x < m_clipRect.left)
|
if (dst.x < m_clipRect.left)
|
||||||
@ -130,38 +161,12 @@ CPixmap::BltFast (Sint32 chDst, size_t channel, Point dst, Rect rcRect)
|
|||||||
if (rcRect.left >= rcRect.right || rcRect.top >= rcRect.bottom)
|
if (rcRect.left >= rcRect.right || rcRect.top >= rcRect.bottom)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (chDst < 0)
|
Rect dstRect;
|
||||||
{
|
dstRect.left = dst.x;
|
||||||
SDL_Rect srcRect, dstRect;
|
dstRect.top = dst.y;
|
||||||
srcRect.x = rcRect.left;
|
dstRect.right = dstRect.left + rcRect.right - rcRect.left;
|
||||||
srcRect.y = rcRect.top;
|
dstRect.bottom = dstRect.top + rcRect.bottom - rcRect.top;
|
||||||
srcRect.w = rcRect.right - rcRect.left;
|
return this->BltFast (chDst, channel, dstRect, rcRect);
|
||||||
srcRect.h = rcRect.bottom - rcRect.top;
|
|
||||||
dstRect = srcRect;
|
|
||||||
dstRect.x = dst.x;
|
|
||||||
dstRect.y = dst.y;
|
|
||||||
|
|
||||||
res = SDL_RenderCopy (
|
|
||||||
g_renderer, m_SDLTextureInfo[channel].texture, &srcRect, &dstRect);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SDL_Rect srcRect, dstRect;
|
|
||||||
srcRect.x = rcRect.left;
|
|
||||||
srcRect.y = rcRect.top;
|
|
||||||
srcRect.w = rcRect.right - rcRect.left;
|
|
||||||
srcRect.h = rcRect.bottom - rcRect.top;
|
|
||||||
dstRect = srcRect;
|
|
||||||
dstRect.x = dst.x;
|
|
||||||
dstRect.y = dst.y;
|
|
||||||
|
|
||||||
SDL_SetRenderTarget (g_renderer, m_SDLTextureInfo[chDst].texture);
|
|
||||||
res = SDL_RenderCopy (
|
|
||||||
g_renderer, m_SDLTextureInfo[channel].texture, &srcRect, &dstRect);
|
|
||||||
SDL_SetRenderTarget (g_renderer, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Effectue un appel BltFast.
|
// Effectue un appel BltFast.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user