Adding IVideoDriver::drawPixel() and implementations, as per http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=30741. Test code is in that post.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1642 dfc29bdd-3216-0410-991c-e03cc46cb475
master
Rogerborg 2008-10-24 13:45:47 +00:00
parent 9a64087ec3
commit a1e21da6b0
13 changed files with 97 additions and 1 deletions

View File

@ -590,6 +590,11 @@ namespace video
const core::position2d<s32>& end,
SColor color=SColor(255,255,255,255)) = 0;
//! Draws a pixel.
/** \param position: the position of the pixel.
\param color: Color of the pixel to draw. */
virtual void drawPixel(u32 x, u32 y, const SColor & color) = 0;
//! Draws a non filled concyclic regular 2d polyon.
/** This method can be used to draw circles, but also
triangles, tetragons, pentagons, hexagons, heptagons, octagons,

View File

@ -1211,6 +1211,29 @@ void CD3D8Driver::draw2DLine(const core::position2d<s32>& start,
pID3DDevice->DrawPrimitiveUP(D3DPT_LINELIST, 1, &vtx[0], sizeof(S3DVertex));
}
//! Draws a pixel
void CD3D8Driver::drawPixel(u32 x, u32 y, const SColor & color)
{
const core::dimension2d<s32>& renderTargetSize = getCurrentRenderTargetSize();
if(x > (u32)renderTargetSize.Width || y > (u32)renderTargetSize.Height)
return;
setRenderStates2DMode(color.getAlpha() < 255, false, false);
setTexture(0,0);
setVertexShader(EVT_STANDARD);
const s32 xPlus = -renderTargetSize.Width / 2;
const f32 xFact = 2.0f / renderTargetSize.Width;
const s32 yPlus = renderTargetSize.Height / 2;
const f32 yFact = 2.0f / renderTargetSize.Height;
S3DVertex vertex((f32)((s32)x + xPlus) * xFact,
(f32)(yPlus - (s32)y) * yFact,
0.f, 0.f, 0.f, 0.f, color, 0.f, 0.f);
pID3DDevice->DrawPrimitiveUP(D3DPT_POINTLIST, 1, &vertex, sizeof(vertex));
}
//! sets right vertex shader

View File

@ -93,6 +93,9 @@ namespace video
const core::position2d<s32>& end,
SColor color=SColor(255,255,255,255));
//! Draws a pixel.
virtual void drawPixel(u32 x, u32 y, const SColor & color);
//! Draws a 3d line.
virtual void draw3DLine(const core::vector3df& start,
const core::vector3df& end, SColor color = SColor(255,255,255,255));

View File

@ -1513,6 +1513,28 @@ void CD3D9Driver::draw2DLine(const core::position2d<s32>& start,
&vtx[0], sizeof(S3DVertex) );
}
//! Draws a pixel
void CD3D9Driver::drawPixel(u32 x, u32 y, const SColor & color)
{
const core::dimension2d<s32>& renderTargetSize = getCurrentRenderTargetSize();
if(x > (u32)renderTargetSize.Width || y > (u32)renderTargetSize.Height)
return;
setRenderStates2DMode(color.getAlpha() < 255, false, false);
setTexture(0,0);
setVertexShader(EVT_STANDARD);
const s32 xPlus = -renderTargetSize.Width / 2;
const f32 xFact = 2.0f / renderTargetSize.Width;
const s32 yPlus = renderTargetSize.Height / 2;
const f32 yFact = 2.0f / renderTargetSize.Height;
S3DVertex vertex((f32)((s32)x + xPlus) * xFact,
(f32)(yPlus - (s32)y) * yFact,
0.f, 0.f, 0.f, 0.f, color, 0.f, 0.f);
pID3DDevice->DrawPrimitiveUP(D3DPT_POINTLIST, 1, &vertex, sizeof(vertex));
}
//! sets right vertex shader

View File

@ -113,6 +113,9 @@ namespace video
const core::position2d<s32>& end,
SColor color=SColor(255,255,255,255));
//! Draws a pixel.
virtual void drawPixel(u32 x, u32 y, const SColor & color);
//! Draws a 3d line.
virtual void draw3DLine(const core::vector3df& start,
const core::vector3df& end, SColor color = SColor(255,255,255,255));

View File

@ -688,6 +688,10 @@ void CNullDriver::draw2DLine(const core::position2d<s32>& start,
{
}
//! Draws a pixel
void CNullDriver::drawPixel(u32 x, u32 y, const SColor & color)
{
}
//! Draws a non filled concyclic regular 2d polyon.

View File

@ -186,6 +186,9 @@ namespace video
const core::position2d<s32>& end,
SColor color=SColor(255,255,255,255));
//! Draws a pixel
virtual void drawPixel(u32 x, u32 y, const SColor & color);
//! Draws a non filled concyclic reqular 2d polyon.
virtual void draw2DPolygon(core::position2d<s32> center,
f32 radius, video::SColor Color, s32 vertexCount);

View File

@ -1487,7 +1487,21 @@ void COpenGLDriver::draw2DLine(const core::position2d<s32>& start,
glEnd();
}
//! Draws a pixel
void COpenGLDriver::drawPixel(u32 x, u32 y, const SColor &color)
{
const core::dimension2d<s32>& renderTargetSize = getCurrentRenderTargetSize();
if(x > (u32)renderTargetSize.Width || y > (u32)renderTargetSize.Height)
return;
disableTextures();
setRenderStates2DMode(color.getAlpha() < 255, false, false);
glBegin(GL_POINTS);
glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
glVertex2i(x, y);
glEnd();
}
bool COpenGLDriver::setTexture(u32 stage, const video::ITexture* texture)
{

View File

@ -201,6 +201,9 @@ namespace video
const core::position2d<s32>& end,
SColor color=SColor(255,255,255,255));
//! Draws a single pixel
virtual void drawPixel(u32 x, u32 y, const SColor & color);
//! Draws a 3d line.
virtual void draw3DLine(const core::vector3df& start,
const core::vector3df& end,

View File

@ -812,6 +812,11 @@ void CSoftwareDriver::draw2DLine(const core::position2d<s32>& start,
((CImage*)RenderTargetSurface)->drawLine(start, end, color );
}
//! Draws a pixel
void CSoftwareDriver::drawPixel(u32 x, u32 y, const SColor & color)
{
((CImage*)BackBuffer)->setPixel(x, y, color);
}
//! draw a 2d rectangle

View File

@ -83,6 +83,9 @@ namespace video
const core::position2d<s32>& end,
SColor color=SColor(255,255,255,255));
//! Draws a single pixel
virtual void drawPixel(u32 x, u32 y, const SColor & color);
//! \return Returns the name of the video driver. Example: In case of the Direct3D8
//! driver, it would return "Direct3D8.1".
virtual const wchar_t* getName() const;

View File

@ -1578,6 +1578,11 @@ void CBurningVideoDriver::draw2DLine(const core::position2d<s32>& start,
((CImage*)BackBuffer)->drawLine(start, end, color );
}
//! Draws a pixel
void CBurningVideoDriver::drawPixel(u32 x, u32 y, const SColor & color)
{
((CImage*)BackBuffer)->setPixel(x, y, color);
}
//! draw an 2d rectangle
void CBurningVideoDriver::draw2DRectangle(SColor color, const core::rect<s32>& pos,

View File

@ -99,6 +99,9 @@ namespace video
const core::position2d<s32>& end,
SColor color=SColor(255,255,255,255));
//! Draws a single pixel
virtual void drawPixel(u32 x, u32 y, const SColor & color);
//! \return Returns the name of the video driver. Example: In case of the DirectX8
//! driver, it would return "Direct3D8.1".
virtual const wchar_t* getName() const;