mirror of
https://github.com/minetest/irrlicht.git
synced 2024-11-15 23:10:26 +01:00
Fix pixel-perfect draw2DLine on OpenGL
This commit is contained in:
parent
4931b34625
commit
0335a52479
|
@ -923,8 +923,8 @@ namespace video
|
||||||
|
|
||||||
//! Draws a 2d line.
|
//! Draws a 2d line.
|
||||||
/** In theory both start and end will be included in coloring.
|
/** In theory both start and end will be included in coloring.
|
||||||
BUG: Currently hardware drivers (d3d/opengl) ignore the last pixel
|
BUG: Currently d3d ignores the last pixel
|
||||||
(they use the so called "diamond exit rule" for drawing lines).
|
(it uses the so called "diamond exit rule" for drawing lines).
|
||||||
\param start Screen coordinates of the start of the line
|
\param start Screen coordinates of the start of the line
|
||||||
in pixels.
|
in pixels.
|
||||||
\param end Screen coordinates of the start of the line in
|
\param end Screen coordinates of the start of the line in
|
||||||
|
|
|
@ -1887,8 +1887,6 @@ void COpenGLDriver::draw2DRectangle(const core::rect<s32>& position,
|
||||||
void COpenGLDriver::draw2DLine(const core::position2d<s32>& start,
|
void COpenGLDriver::draw2DLine(const core::position2d<s32>& start,
|
||||||
const core::position2d<s32>& end, SColor color)
|
const core::position2d<s32>& end, SColor color)
|
||||||
{
|
{
|
||||||
// TODO: It's not pixel-exact. Reason is the way OpenGL handles line-drawing (search the web for "diamond exit rule").
|
|
||||||
|
|
||||||
if (start==end)
|
if (start==end)
|
||||||
drawPixel(start.X, start.Y, color);
|
drawPixel(start.X, start.Y, color);
|
||||||
else
|
else
|
||||||
|
@ -1923,6 +1921,9 @@ void COpenGLDriver::draw2DLine(const core::position2d<s32>& start,
|
||||||
}
|
}
|
||||||
|
|
||||||
glDrawElements(GL_LINES, 2, GL_UNSIGNED_SHORT, Quad2DIndices);
|
glDrawElements(GL_LINES, 2, GL_UNSIGNED_SHORT, Quad2DIndices);
|
||||||
|
|
||||||
|
// Draw non-drawn last pixel (search for "diamond exit rule")
|
||||||
|
glDrawArrays(GL_POINTS, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user