Commit 5f4c2795 authored by nadro's avatar nadro

- Added support for rotation 2D images. This patch base on FuzzYspo0N patch...

- Added support for rotation 2D images. This patch base on FuzzYspo0N patch from irrEXT. (Software drivers aren't supported).

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4478 dfc29bdd-3216-0410-991c-e03cc46cb475
parent c2b593fb
...@@ -827,10 +827,11 @@ namespace video ...@@ -827,10 +827,11 @@ namespace video
alpha component is used: If alpha is other than 255, the image alpha component is used: If alpha is other than 255, the image
will be transparent. will be transparent.
\param useAlphaChannelOfTexture: If true, the alpha channel of \param useAlphaChannelOfTexture: If true, the alpha channel of
the texture is used to draw the image.*/ the texture is used to draw the image.
\param rotation Rotation of the image. */
virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect =0, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect =0,
SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false) =0; SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false, f32 rotation = 0.f) =0;
//! Draws a set of 2d images, using a color and the alpha channel of the texture. //! Draws a set of 2d images, using a color and the alpha channel of the texture.
/** The images are drawn beginning at pos and concatenated in /** The images are drawn beginning at pos and concatenated in
...@@ -851,7 +852,8 @@ namespace video ...@@ -851,7 +852,8 @@ namespace video
Note that the alpha component is used. If alpha is other than Note that the alpha component is used. If alpha is other than
255, the image will be transparent. 255, the image will be transparent.
\param useAlphaChannelOfTexture: If true, the alpha channel of \param useAlphaChannelOfTexture: If true, the alpha channel of
the texture is used to draw the image. */ the texture is used to draw the image.
\param rotation Rotation of the image. */
virtual void draw2DImageBatch(const video::ITexture* texture, virtual void draw2DImageBatch(const video::ITexture* texture,
const core::position2d<s32>& pos, const core::position2d<s32>& pos,
const core::array<core::rect<s32> >& sourceRects, const core::array<core::rect<s32> >& sourceRects,
...@@ -859,7 +861,8 @@ namespace video ...@@ -859,7 +861,8 @@ namespace video
s32 kerningWidth=0, s32 kerningWidth=0,
const core::rect<s32>* clipRect=0, const core::rect<s32>* clipRect=0,
SColor color=SColor(255,255,255,255), SColor color=SColor(255,255,255,255),
bool useAlphaChannelOfTexture=false) =0; bool useAlphaChannelOfTexture=false,
f32 rotation = 0.f) =0;
//! Draws a set of 2d images, using a color and the alpha channel of the texture. //! Draws a set of 2d images, using a color and the alpha channel of the texture.
/** All drawings are clipped against clipRect (if != 0). /** All drawings are clipped against clipRect (if != 0).
...@@ -876,13 +879,15 @@ namespace video ...@@ -876,13 +879,15 @@ namespace video
Note that the alpha component is used. If alpha is other than Note that the alpha component is used. If alpha is other than
255, the image will be transparent. 255, the image will be transparent.
\param useAlphaChannelOfTexture: If true, the alpha channel of \param useAlphaChannelOfTexture: If true, the alpha channel of
the texture is used to draw the image. */ the texture is used to draw the image.
\param rotation Rotation of the image. */
virtual void draw2DImageBatch(const video::ITexture* texture, virtual void draw2DImageBatch(const video::ITexture* texture,
const core::array<core::position2d<s32> >& positions, const core::array<core::position2d<s32> >& positions,
const core::array<core::rect<s32> >& sourceRects, const core::array<core::rect<s32> >& sourceRects,
const core::rect<s32>* clipRect=0, const core::rect<s32>* clipRect=0,
SColor color=SColor(255,255,255,255), SColor color=SColor(255,255,255,255),
bool useAlphaChannelOfTexture=false) =0; bool useAlphaChannelOfTexture=false,
f32 rotation = 0.f) =0;
//! Draws a part of the texture into the rectangle. Note that colors must be an array of 4 colors if used. //! Draws a part of the texture into the rectangle. Note that colors must be an array of 4 colors if used.
/** Suggested and first implemented by zola. /** Suggested and first implemented by zola.
...@@ -893,10 +898,11 @@ namespace video ...@@ -893,10 +898,11 @@ namespace video
\param colors Array of 4 colors denoting the color values of \param colors Array of 4 colors denoting the color values of
the corners of the destRect the corners of the destRect
\param useAlphaChannelOfTexture True if alpha channel will be \param useAlphaChannelOfTexture True if alpha channel will be
blended. */ blended.
\param rotation Rotation of the image. */
virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect, virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect =0, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect =0,
const video::SColor * const colors=0, bool useAlphaChannelOfTexture=false) =0; const video::SColor * const colors=0, bool useAlphaChannelOfTexture=false, f32 rotation = 0.f) =0;
//! Draws a 2d rectangle. //! Draws a 2d rectangle.
/** \param color Color of the rectangle to draw. The alpha /** \param color Color of the rectangle to draw. The alpha
......
...@@ -1009,7 +1009,7 @@ void CD3D8Driver::draw2DImage(const video::ITexture* texture, ...@@ -1009,7 +1009,7 @@ void CD3D8Driver::draw2DImage(const video::ITexture* texture,
const core::position2d<s32>& pos, const core::position2d<s32>& pos,
const core::rect<s32>& sourceRect, const core::rect<s32>& sourceRect,
const core::rect<s32>* clipRect, SColor color, const core::rect<s32>* clipRect, SColor color,
bool useAlphaChannelOfTexture) bool useAlphaChannelOfTexture, f32 rotation)
{ {
if (!texture) if (!texture)
return; return;
...@@ -1112,21 +1112,34 @@ void CD3D8Driver::draw2DImage(const video::ITexture* texture, ...@@ -1112,21 +1112,34 @@ void CD3D8Driver::draw2DImage(const video::ITexture* texture,
setRenderStates2DMode(color.getAlpha()<255, true, useAlphaChannelOfTexture); setRenderStates2DMode(color.getAlpha()<255, true, useAlphaChannelOfTexture);
core::vector2df fpos[4];
fpos[0] = core::vector2df((f32)poss.UpperLeftCorner.X, (f32)poss.UpperLeftCorner.Y);
fpos[1] = core::vector2df((f32)poss.LowerRightCorner.X, (f32)poss.UpperLeftCorner.Y);
fpos[2] = core::vector2df((f32)poss.LowerRightCorner.X, (f32)poss.LowerRightCorner.Y);
fpos[3] = core::vector2df((f32)poss.UpperLeftCorner.X, (f32)poss.LowerRightCorner.Y);
if(rotation > 0.f)
{
if(rotation > 360.0f)
rotation = fmodf(rotation, 360.f);
core::vector2d<s32> rcenter = poss.getCenter();
for (u32 i = 0; i < 4; ++i)
fpos[i].rotateBy(rotation, core::vector2df(rcenter.X, rcenter.Y));
}
S3DVertex vtx[4]; S3DVertex vtx[4];
vtx[0] = S3DVertex((f32)poss.UpperLeftCorner.X, vtx[0] = S3DVertex(fpos[0].X, fpos[0].Y, 0.0f,
(f32)poss.UpperLeftCorner.Y, 0.0f,
0.0f, 0.0f, 0.0f, color, 0.0f, 0.0f, 0.0f, color,
tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y);
vtx[1] = S3DVertex((f32)poss.LowerRightCorner.X, vtx[1] = S3DVertex(fpos[1].X, fpos[1].Y, 0.0f,
(f32)poss.UpperLeftCorner.Y, 0.0f,
0.0f, 0.0f, 0.0f, color, 0.0f, 0.0f, 0.0f, color,
tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y);
vtx[2] = S3DVertex((f32)poss.LowerRightCorner.X, vtx[2] = S3DVertex(fpos[2].X, fpos[2].Y, 0.0f,
(f32)poss.LowerRightCorner.Y, 0.0f,
0.0f, 0.0f, 0.0f, color, 0.0f, 0.0f, 0.0f, color,
tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y);
vtx[3] = S3DVertex((f32)poss.UpperLeftCorner.X, vtx[3] = S3DVertex(fpos[3].X, fpos[3].Y, 0.0f,
(f32)poss.LowerRightCorner.Y, 0.0f,
0.0f, 0.0f, 0.0f, color, 0.0f, 0.0f, 0.0f, color,
tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y);
...@@ -1144,7 +1157,8 @@ void CD3D8Driver::draw2DImage(const video::ITexture* texture, ...@@ -1144,7 +1157,8 @@ void CD3D8Driver::draw2DImage(const video::ITexture* texture,
const core::rect<s32>& sourceRect, const core::rect<s32>& sourceRect,
const core::rect<s32>* clipRect, const core::rect<s32>* clipRect,
const video::SColor* const colors, const video::SColor* const colors,
bool useAlphaChannelOfTexture) bool useAlphaChannelOfTexture,
f32 rotation)
{ {
if(!texture) if(!texture)
return; return;
...@@ -1188,17 +1202,34 @@ void CD3D8Driver::draw2DImage(const video::ITexture* texture, ...@@ -1188,17 +1202,34 @@ void CD3D8Driver::draw2DImage(const video::ITexture* texture,
const video::SColor* const useColor = colors ? colors : temp; const video::SColor* const useColor = colors ? colors : temp;
core::vector2df fpos[4];
fpos[0] = core::vector2df((f32)clippedRect.UpperLeftCorner.X, (f32)clippedRect.UpperLeftCorner.Y);
fpos[1] = core::vector2df((f32)clippedRect.LowerRightCorner.X, (f32)clippedRect.UpperLeftCorner.Y);
fpos[2] = core::vector2df((f32)clippedRect.LowerRightCorner.X, (f32)clippedRect.LowerRightCorner.Y);
fpos[3] = core::vector2df((f32)clippedRect.UpperLeftCorner.X, (f32)clippedRect.LowerRightCorner.Y);
if(rotation > 0.f)
{
if(rotation > 360.0f)
rotation = fmodf(rotation, 360.f);
core::vector2d<s32> rcenter = clippedRect.getCenter();
for (u32 i = 0; i < 4; ++i)
fpos[i].rotateBy(rotation, core::vector2df(rcenter.X, rcenter.Y));
}
S3DVertex vtx[4]; // clock wise S3DVertex vtx[4]; // clock wise
vtx[0] = S3DVertex((f32)clippedRect.UpperLeftCorner.X, (f32)clippedRect.UpperLeftCorner.Y, 0.0f, vtx[0] = S3DVertex(fpos[0].X, fpos[0].Y, 0.0f,
0.0f, 0.0f, 0.0f, useColor[0], 0.0f, 0.0f, 0.0f, useColor[0],
tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y);
vtx[1] = S3DVertex((f32)clippedRect.LowerRightCorner.X, (f32)clippedRect.UpperLeftCorner.Y, 0.0f, vtx[1] = S3DVertex(fpos[1].X, fpos[1].Y, 0.0f,
0.0f, 0.0f, 0.0f, useColor[3], 0.0f, 0.0f, 0.0f, useColor[3],
tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y);
vtx[2] = S3DVertex((f32)clippedRect.LowerRightCorner.X, (f32)clippedRect.LowerRightCorner.Y, 0.0f, vtx[2] = S3DVertex(fpos[2].X, fpos[2].Y, 0.0f,
0.0f, 0.0f, 0.0f, useColor[2], 0.0f, 0.0f, 0.0f, useColor[2],
tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y);
vtx[3] = S3DVertex((f32)clippedRect.UpperLeftCorner.X, (f32)clippedRect.LowerRightCorner.Y, 0.0f, vtx[3] = S3DVertex(fpos[3].X, fpos[3].Y, 0.0f,
0.0f, 0.0f, 0.0f, useColor[1], 0.0f, 0.0f, 0.0f, useColor[1],
tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y);
......
...@@ -81,12 +81,12 @@ namespace video ...@@ -81,12 +81,12 @@ namespace video
//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false, f32 rotation = 0.f);
//! Draws a part of the texture into the rectangle. //! Draws a part of the texture into the rectangle.
virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect, virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false); const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false, f32 rotation = 0.f);
//!Draws an 2d rectangle with a gradient. //!Draws an 2d rectangle with a gradient.
virtual void draw2DRectangle(const core::rect<s32>& pos, virtual void draw2DRectangle(const core::rect<s32>& pos,
......
...@@ -1577,7 +1577,8 @@ void CD3D9Driver::draw2DImage(const video::ITexture* texture, ...@@ -1577,7 +1577,8 @@ void CD3D9Driver::draw2DImage(const video::ITexture* texture,
const core::rect<s32>& sourceRect, const core::rect<s32>& sourceRect,
const core::rect<s32>* clipRect, const core::rect<s32>* clipRect,
const video::SColor* const colors, const video::SColor* const colors,
bool useAlphaChannelOfTexture) bool useAlphaChannelOfTexture,
f32 rotation)
{ {
if(!texture) if(!texture)
return; return;
...@@ -1601,17 +1602,34 @@ void CD3D9Driver::draw2DImage(const video::ITexture* texture, ...@@ -1601,17 +1602,34 @@ void CD3D9Driver::draw2DImage(const video::ITexture* texture,
const video::SColor* const useColor = colors ? colors : temp; const video::SColor* const useColor = colors ? colors : temp;
core::vector2df fpos[4];
fpos[0] = core::vector2df((f32)destRect.UpperLeftCorner.X, (f32)destRect.UpperLeftCorner.Y);
fpos[1] = core::vector2df((f32)destRect.LowerRightCorner.X, (f32)destRect.UpperLeftCorner.Y);
fpos[2] = core::vector2df((f32)destRect.LowerRightCorner.X, (f32)destRect.LowerRightCorner.Y);
fpos[3] = core::vector2df((f32)destRect.UpperLeftCorner.X, (f32)destRect.LowerRightCorner.Y);
if(rotation > 0.f)
{
if(rotation > 360.0f)
rotation = fmodf(rotation, 360.f);
core::vector2d<s32> rcenter = destRect.getCenter();
for (u32 i = 0; i < 4; ++i)
fpos[i].rotateBy(rotation, core::vector2df(rcenter.X, rcenter.Y));
}
S3DVertex vtx[4]; // clock wise S3DVertex vtx[4]; // clock wise
vtx[0] = S3DVertex((f32)destRect.UpperLeftCorner.X, (f32)destRect.UpperLeftCorner.Y, 0.0f, vtx[0] = S3DVertex(fpos[0].X, fpos[0].Y, 0.0f,
0.0f, 0.0f, 0.0f, useColor[0], 0.0f, 0.0f, 0.0f, useColor[0],
tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y);
vtx[1] = S3DVertex((f32)destRect.LowerRightCorner.X, (f32)destRect.UpperLeftCorner.Y, 0.0f, vtx[1] = S3DVertex(fpos[1].X, fpos[1].Y, 0.0f,
0.0f, 0.0f, 0.0f, useColor[3], 0.0f, 0.0f, 0.0f, useColor[3],
tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y);
vtx[2] = S3DVertex((f32)destRect.LowerRightCorner.X, (f32)destRect.LowerRightCorner.Y, 0.0f, vtx[2] = S3DVertex(fpos[2].X, fpos[2].Y, 0.0f,
0.0f, 0.0f, 0.0f, useColor[2], 0.0f, 0.0f, 0.0f, useColor[2],
tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y);
vtx[3] = S3DVertex((f32)destRect.UpperLeftCorner.X, (f32)destRect.LowerRightCorner.Y, 0.0f, vtx[3] = S3DVertex(fpos[3].X, fpos[3].Y, 0.0f,
0.0f, 0.0f, 0.0f, useColor[1], 0.0f, 0.0f, 0.0f, useColor[1],
tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y);
...@@ -1649,7 +1667,8 @@ void CD3D9Driver::draw2DImageBatch(const video::ITexture* texture, ...@@ -1649,7 +1667,8 @@ void CD3D9Driver::draw2DImageBatch(const video::ITexture* texture,
const core::array<core::rect<s32> >& sourceRects, const core::array<core::rect<s32> >& sourceRects,
const core::rect<s32>* clipRect, const core::rect<s32>* clipRect,
SColor color, SColor color,
bool useAlphaChannelOfTexture) bool useAlphaChannelOfTexture,
f32 rotation)
{ {
if (!texture) if (!texture)
return; return;
...@@ -1757,16 +1776,33 @@ void CD3D9Driver::draw2DImageBatch(const video::ITexture* texture, ...@@ -1757,16 +1776,33 @@ void CD3D9Driver::draw2DImageBatch(const video::ITexture* texture,
const core::rect<s32> poss(targetPos, sourceSize); const core::rect<s32> poss(targetPos, sourceSize);
vtx.push_back(S3DVertex((f32)poss.UpperLeftCorner.X, (f32)poss.UpperLeftCorner.Y, 0.0f, core::vector2df fpos[4];
fpos[0] = core::vector2df((f32)poss.UpperLeftCorner.X, (f32)poss.UpperLeftCorner.Y);
fpos[1] = core::vector2df((f32)poss.LowerRightCorner.X, (f32)poss.UpperLeftCorner.Y);
fpos[2] = core::vector2df((f32)poss.LowerRightCorner.X, (f32)poss.LowerRightCorner.Y);
fpos[3] = core::vector2df((f32)poss.UpperLeftCorner.X, (f32)poss.LowerRightCorner.Y);
if(rotation > 0.f)
{
if(rotation > 360.0f)
rotation = fmodf(rotation, 360.f);
core::vector2d<s32> rcenter = poss.getCenter();
for (u32 i = 0; i < 4; ++i)
fpos[i].rotateBy(rotation, core::vector2df(rcenter.X, rcenter.Y));
}
vtx.push_back(S3DVertex(fpos[0].X, fpos[0].Y, 0.0f,
0.0f, 0.0f, 0.0f, color, 0.0f, 0.0f, 0.0f, color,
tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y)); tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y));
vtx.push_back(S3DVertex((f32)poss.LowerRightCorner.X, (f32)poss.UpperLeftCorner.Y, 0.0f, vtx.push_back(S3DVertex(fpos[1].X, fpos[1].Y, 0.0f,
0.0f, 0.0f, 0.0f, color, 0.0f, 0.0f, 0.0f, color,
tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y)); tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y));
vtx.push_back(S3DVertex((f32)poss.LowerRightCorner.X, (f32)poss.LowerRightCorner.Y, 0.0f, vtx.push_back(S3DVertex(fpos[2].X, fpos[2].Y, 0.0f,
0.0f, 0.0f, 0.0f, color, 0.0f, 0.0f, 0.0f, color,
tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y)); tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y));
vtx.push_back(S3DVertex((f32)poss.UpperLeftCorner.X, (f32)poss.LowerRightCorner.Y, 0.0f, vtx.push_back(S3DVertex(fpos[3].X, fpos[3].Y, 0.0f,
0.0f, 0.0f, 0.0f, color, 0.0f, 0.0f, 0.0f, color,
tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y)); tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y));
...@@ -1796,7 +1832,7 @@ void CD3D9Driver::draw2DImage(const video::ITexture* texture, ...@@ -1796,7 +1832,7 @@ void CD3D9Driver::draw2DImage(const video::ITexture* texture,
const core::position2d<s32>& pos, const core::position2d<s32>& pos,
const core::rect<s32>& sourceRect, const core::rect<s32>& sourceRect,
const core::rect<s32>* clipRect, SColor color, const core::rect<s32>* clipRect, SColor color,
bool useAlphaChannelOfTexture) bool useAlphaChannelOfTexture, f32 rotation)
{ {
if (!texture) if (!texture)
return; return;
...@@ -1900,17 +1936,34 @@ void CD3D9Driver::draw2DImage(const video::ITexture* texture, ...@@ -1900,17 +1936,34 @@ void CD3D9Driver::draw2DImage(const video::ITexture* texture,
setRenderStates2DMode(color.getAlpha()<255, true, useAlphaChannelOfTexture); setRenderStates2DMode(color.getAlpha()<255, true, useAlphaChannelOfTexture);
core::vector2df fpos[4];
fpos[0] = core::vector2df((f32)poss.UpperLeftCorner.X, (f32)poss.UpperLeftCorner.Y);
fpos[1] = core::vector2df((f32)poss.LowerRightCorner.X, (f32)poss.UpperLeftCorner.Y);
fpos[2] = core::vector2df((f32)poss.LowerRightCorner.X, (f32)poss.LowerRightCorner.Y);
fpos[3] = core::vector2df((f32)poss.UpperLeftCorner.X, (f32)poss.LowerRightCorner.Y);
if(rotation > 0.f)
{
if(rotation > 360.0f)
rotation = fmodf(rotation, 360.f);
core::vector2d<s32> rcenter = poss.getCenter();
for (u32 i = 0; i < 4; ++i)
fpos[i].rotateBy(rotation, core::vector2df(rcenter.X, rcenter.Y));
}
S3DVertex vtx[4]; S3DVertex vtx[4];
vtx[0] = S3DVertex((f32)poss.UpperLeftCorner.X, (f32)poss.UpperLeftCorner.Y, 0.0f, vtx[0] = S3DVertex(fpos[0].X, fpos[0].Y, 0.0f,
0.0f, 0.0f, 0.0f, color, 0.0f, 0.0f, 0.0f, color,
tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y);
vtx[1] = S3DVertex((f32)poss.LowerRightCorner.X, (f32)poss.UpperLeftCorner.Y, 0.0f, vtx[1] = S3DVertex(fpos[1].X, fpos[1].Y, 0.0f,
0.0f, 0.0f, 0.0f, color, 0.0f, 0.0f, 0.0f, color,
tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y);
vtx[2] = S3DVertex((f32)poss.LowerRightCorner.X, (f32)poss.LowerRightCorner.Y, 0.0f, vtx[2] = S3DVertex(fpos[2].X, fpos[2].Y, 0.0f,
0.0f, 0.0f, 0.0f, color, 0.0f, 0.0f, 0.0f, color,
tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y);
vtx[3] = S3DVertex((f32)poss.UpperLeftCorner.X, (f32)poss.LowerRightCorner.Y, 0.0f, vtx[3] = S3DVertex(fpos[3].X, fpos[3].Y, 0.0f,
0.0f, 0.0f, 0.0f, color, 0.0f, 0.0f, 0.0f, color,
tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y);
......
...@@ -163,12 +163,12 @@ namespace video ...@@ -163,12 +163,12 @@ namespace video
//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false, f32 rotation = 0.f);
//! Draws a part of the texture into the rectangle. //! Draws a part of the texture into the rectangle.
virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect, virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false); const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false, f32 rotation = 0.f);
//! Draws a set of 2d images, using a color and the alpha channel of the texture. //! Draws a set of 2d images, using a color and the alpha channel of the texture.
virtual void draw2DImageBatch(const video::ITexture* texture, virtual void draw2DImageBatch(const video::ITexture* texture,
...@@ -176,7 +176,8 @@ namespace video ...@@ -176,7 +176,8 @@ namespace video
const core::array<core::rect<s32> >& sourceRects, const core::array<core::rect<s32> >& sourceRects,
const core::rect<s32>* clipRect=0, const core::rect<s32>* clipRect=0,
SColor color=SColor(255,255,255,255), SColor color=SColor(255,255,255,255),
bool useAlphaChannelOfTexture=false); bool useAlphaChannelOfTexture=false,
f32 rotation = 0.f);
//!Draws an 2d rectangle with a gradient. //!Draws an 2d rectangle with a gradient.
virtual void draw2DRectangle(const core::rect<s32>& pos, virtual void draw2DRectangle(const core::rect<s32>& pos,
......
...@@ -736,14 +736,15 @@ void CNullDriver::draw2DImageBatch(const video::ITexture* texture, ...@@ -736,14 +736,15 @@ void CNullDriver::draw2DImageBatch(const video::ITexture* texture,
const core::array<s32>& indices, const core::array<s32>& indices,
s32 kerningWidth, s32 kerningWidth,
const core::rect<s32>* clipRect, SColor color, const core::rect<s32>* clipRect, SColor color,
bool useAlphaChannelOfTexture) bool useAlphaChannelOfTexture,
f32 rotation)
{ {
core::position2d<s32> target(pos); core::position2d<s32> target(pos);
for (u32 i=0; i<indices.size(); ++i) for (u32 i=0; i<indices.size(); ++i)
{ {
draw2DImage(texture, target, sourceRects[indices[i]], draw2DImage(texture, target, sourceRects[indices[i]],
clipRect, color, useAlphaChannelOfTexture); clipRect, color, useAlphaChannelOfTexture, rotation);
target.X += sourceRects[indices[i]].getWidth(); target.X += sourceRects[indices[i]].getWidth();
target.X += kerningWidth; target.X += kerningWidth;
} }
...@@ -756,14 +757,15 @@ void CNullDriver::draw2DImageBatch(const video::ITexture* texture, ...@@ -756,14 +757,15 @@ void CNullDriver::draw2DImageBatch(const video::ITexture* texture,
const core::array<core::rect<s32> >& sourceRects, const core::array<core::rect<s32> >& sourceRects,
const core::rect<s32>* clipRect, const core::rect<s32>* clipRect,
SColor color, SColor color,
bool useAlphaChannelOfTexture) bool useAlphaChannelOfTexture,
f32 rotation)
{ {
const irr::u32 drawCount = core::min_<u32>(positions.size(), sourceRects.size()); const irr::u32 drawCount = core::min_<u32>(positions.size(), sourceRects.size());
for (u32 i=0; i<drawCount; ++i) for (u32 i=0; i<drawCount; ++i)
{ {
draw2DImage(texture, positions[i], sourceRects[i], draw2DImage(texture, positions[i], sourceRects[i],
clipRect, color, useAlphaChannelOfTexture); clipRect, color, useAlphaChannelOfTexture, rotation);
} }
} }
...@@ -771,12 +773,12 @@ void CNullDriver::draw2DImageBatch(const video::ITexture* texture, ...@@ -771,12 +773,12 @@ void CNullDriver::draw2DImageBatch(const video::ITexture* texture,
//! Draws a part of the texture into the rectangle. //! Draws a part of the texture into the rectangle.
void CNullDriver::draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect, void CNullDriver::draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect,
const video::SColor* const colors, bool useAlphaChannelOfTexture) const video::SColor* const colors, bool useAlphaChannelOfTexture, f32 rotation)
{ {
if (destRect.isValid()) if (destRect.isValid())
draw2DImage(texture, core::position2d<s32>(destRect.UpperLeftCorner), draw2DImage(texture, core::position2d<s32>(destRect.UpperLeftCorner),
sourceRect, clipRect, colors?colors[0]:video::SColor(0xffffffff), sourceRect, clipRect, colors?colors[0]:video::SColor(0xffffffff),
useAlphaChannelOfTexture); useAlphaChannelOfTexture, rotation);
} }
...@@ -784,7 +786,7 @@ void CNullDriver::draw2DImage(const video::ITexture* texture, const core::rect<s ...@@ -784,7 +786,7 @@ void CNullDriver::draw2DImage(const video::ITexture* texture, const core::rect<s
void CNullDriver::draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, void CNullDriver::draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
const core::rect<s32>& sourceRect, const core::rect<s32>& sourceRect,
const core::rect<s32>* clipRect, SColor color, const core::rect<s32>* clipRect, SColor color,
bool useAlphaChannelOfTexture) bool useAlphaChannelOfTexture, f32 rotation)
{ {
} }
......
...@@ -167,7 +167,8 @@ namespace video ...@@ -167,7 +167,8 @@ namespace video
s32 kerningWidth = 0, s32 kerningWidth = 0,
const core::rect<s32>* clipRect = 0, const core::rect<s32>* clipRect = 0,
SColor color=SColor(255,255,255,255), SColor color=SColor(255,255,255,255),
bool useAlphaChannelOfTexture=false); bool useAlphaChannelOfTexture=false,
f32 rotation = 0.f);
//! Draws a set of 2d images, using a color and the alpha channel of the texture. //! Draws a set of 2d images, using a color and the alpha channel of the texture.
/** All drawings are clipped against clipRect (if != 0). /** All drawings are clipped against clipRect (if != 0).
...@@ -190,17 +191,18 @@ namespace video ...@@ -190,17 +191,18 @@ namespace video
const core::array<core::rect<s32> >& sourceRects, const core::array<core::rect<s32> >& sourceRects,
const core::rect<s32>* clipRect=0, const core::rect<s32>* clipRect=0,
SColor color=SColor(255,255,255,255), SColor color=SColor(255,255,255,255),
bool useAlphaChannelOfTexture=false); bool useAlphaChannelOfTexture=false,
f32 rotation = 0.f);
//! Draws a 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. //! Draws a 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false, f32 rotation = 0.f);
//! Draws a part of the texture into the rectangle. //! Draws a part of the texture into the rectangle.
virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect, virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false); const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false, f32 rotation = 0.f);
//! Draws a 2d rectangle //! Draws a 2d rectangle
virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos, const core::rect<s32>* clip = 0); virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos, const core::rect<s32>* clip = 0);
......
This diff is collapsed.
...@@ -158,12 +158,13 @@ namespace video ...@@ -158,12 +158,13 @@ namespace video
const core::array<core::rect<s32> >& sourceRects, const core::array<core::rect<s32> >& sourceRects,
const core::rect<s32>* clipRect, const core::rect<s32>* clipRect,
SColor color, SColor color,
bool useAlphaChannelOfTexture); bool useAlphaChannelOfTexture,
f32 rotation = 0.f);
//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false, f32 rotation = 0.f);
//! draws a set of 2d images, using a color and the alpha //! draws a set of 2d images, using a color and the alpha
/** channel of the texture if desired. The images are drawn /** channel of the texture if desired. The images are drawn
...@@ -187,12 +188,13 @@ namespace video ...@@ -187,12 +188,13 @@ namespace video
const core::array<s32>& indices, const core::array<s32>& indices,
const core::rect<s32>* clipRect=0, const core::rect<s32>* clipRect=0,
SColor color=SColor(255,255,255,255), SColor color=SColor(255,255,255,255),
bool useAlphaChannelOfTexture=false); bool useAlphaChannelOfTexture=false,
f32 rotation = 0.f);
//! Draws a part of the texture into the rectangle. //! Draws a part of the texture into the rectangle.
virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect, virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false); const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false, f32 rotation = 0.f);
//! draw an 2d rectangle //! draw an 2d rectangle
virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos, virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos,
......
...@@ -795,7 +795,7 @@ const core::dimension2d<u32>& CSoftwareDriver::getCurrentRenderTargetSize() cons ...@@ -795,7 +795,7 @@ const core::dimension2d<u32>& CSoftwareDriver::getCurrentRenderTargetSize() cons
void CSoftwareDriver::draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, void CSoftwareDriver::draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
const core::rect<s32>& sourceRect, const core::rect<s32>& sourceRect,
const core::rect<s32>* clipRect, SColor color, const core::rect<s32>* clipRect, SColor color,
bool useAlphaChannelOfTexture) bool useAlphaChannelOfTexture, f32 rotation)
{ {
if (texture) if (texture)
{ {
......
...@@ -67,7 +67,7 @@ namespace video ...@@ -67,7 +67,7 @@ namespace video
//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false, f32 rotation = 0.f);
//! draw an 2d rectangle //! draw an 2d rectangle
virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos, virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos,
......
...@@ -2191,7 +2191,7 @@ void CBurningVideoDriver::lightVertex ( s4DVertex *dest, u32 vertexargb ) ...@@ -2191,7 +2191,7 @@ void CBurningVideoDriver::lightVertex ( s4DVertex *dest, u32 vertexargb )
void CBurningVideoDriver::draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, void CBurningVideoDriver::draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
const core::rect<s32>& sourceRect, const core::rect<s32>& sourceRect,
const core::rect<s32>* clipRect, SColor color, const core::rect<s32>* clipRect, SColor color,
bool useAlphaChannelOfTexture) bool useAlphaChannelOfTexture, f32 rotation)
{ {
if (texture) if (texture)
{ {
...@@ -2229,7 +2229,7 @@ void CBurningVideoDriver::draw2DImage(const video::ITexture* texture, const core ...@@ -2229,7 +2229,7 @@ void CBurningVideoDriver::draw2DImage(const video::ITexture* texture, const core
//! Draws a part of the texture into the rectangle. //! Draws a part of the texture into the rectangle.
void CBurningVideoDriver::draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect, void CBurningVideoDriver::draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect,
const video::SColor* const colors, bool useAlphaChannelOfTexture) const video::SColor* const colors, bool useAlphaChannelOfTexture, f32 rotation)
{ {
if (texture) if (texture)
{ {
......
...@@ -87,12 +87,12 @@ namespace video ...@@ -87,12 +87,12 @@ namespace video
//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false, f32 rotation = 0.f);
//! Draws a part of the texture into the rectangle. //! Draws a part of the texture into the rectangle.
virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect, virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false); const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false, f32 rotation = 0.f);
//! Draws a 3d line. //! Draws a 3d line.
virtual void draw3DLine(const core::vector3df& start, virtual void draw3DLine(const core::vector3df& start,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment