Commit a287977b authored by nadro's avatar nadro

Fixed bug in OpenGL 2D rendering system. Thanks Hendu for report this bug.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4515 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 37f8eb7d
......@@ -34,6 +34,9 @@ namespace irr
namespace video
{
// Statics variables
const u16 COpenGLDriver::Quad2DIndices[4] = { 0, 1, 2, 3 };
// -----------------------------------------------------------------------
// WINDOWS CONSTRUCTOR
// -----------------------------------------------------------------------
......@@ -756,22 +759,11 @@ bool COpenGLDriver::genericDriverInit()
extGlProvokingVertex(GL_FIRST_VERTEX_CONVENTION_EXT);
#endif
// Create built-in 2D quad and line for 2D rendering.
Quad2DIndices[0] = 0;
Quad2DIndices[1] = 2;
Quad2DIndices[2] = 3;
Quad2DIndices[3] = 0;
Quad2DIndices[4] = 1;
Quad2DIndices[5] = 2;
Line2DIndices[0] = 0;
Line2DIndices[1] = 1;
// Create built-in 2D quad for 2D rendering (both quads and lines).
Quad2DVertices[0] = S3DVertex(core::vector3df(-1.0f, 1.0f, 0.0f), core::vector3df(0.0f, 0.0f, 0.0f), SColor(255,255,255,255), core::vector2df(0.0f, 1.0f));
Quad2DVertices[0] = S3DVertex(core::vector3df(1.0f, 1.0f, 0.0f), core::vector3df(0.0f, 0.0f, 0.0f), SColor(255,255,255,255), core::vector2df(1.0f, 1.0f));
Quad2DVertices[0] = S3DVertex(core::vector3df(1.0f, -1.0f, 0.0f), core::vector3df(0.0f, 0.0f, 0.0f), SColor(255,255,255,255), core::vector2df(1.0f, 0.0f));
Quad2DVertices[0] = S3DVertex(core::vector3df(-1.0f, -1.0f, 0.0f), core::vector3df(0.0f, 0.0f, 0.0f), SColor(255,255,255,255), core::vector2df(0.0f, 0.0f));
Quad2DVertices[1] = S3DVertex(core::vector3df(1.0f, 1.0f, 0.0f), core::vector3df(0.0f, 0.0f, 0.0f), SColor(255,255,255,255), core::vector2df(1.0f, 1.0f));
Quad2DVertices[2] = S3DVertex(core::vector3df(1.0f, -1.0f, 0.0f), core::vector3df(0.0f, 0.0f, 0.0f), SColor(255,255,255,255), core::vector2df(1.0f, 0.0f));
Quad2DVertices[3] = S3DVertex(core::vector3df(-1.0f, -1.0f, 0.0f), core::vector3df(0.0f, 0.0f, 0.0f), SColor(255,255,255,255), core::vector2df(0.0f, 0.0f));
// create material renderers
createMaterialRenderers();
......@@ -2069,7 +2061,7 @@ void COpenGLDriver::draw2DImageBatch(const video::ITexture* texture,
Quad2DVertices[2].TCoords = core::vector2df(tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y);
Quad2DVertices[3].TCoords = core::vector2df(tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, Quad2DIndices);
glDrawElements(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_SHORT, Quad2DIndices);
}
}
......@@ -2223,7 +2215,7 @@ void COpenGLDriver::draw2DImage(const video::ITexture* texture,
glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]);
}
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, Quad2DIndices);
glDrawElements(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_SHORT, Quad2DIndices);
}
......@@ -2308,7 +2300,7 @@ void COpenGLDriver::draw2DImage(const video::ITexture* texture, const core::rect
glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]);
}
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, Quad2DIndices);
glDrawElements(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_SHORT, Quad2DIndices);
if (clipRect)
glDisable(GL_SCISSOR_TEST);
......@@ -2401,7 +2393,7 @@ void COpenGLDriver::draw2DImage(const video::ITexture* texture,
Quad2DVertices[2].TCoords = core::vector2df(tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y);
Quad2DVertices[3].TCoords = core::vector2df(tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, Quad2DIndices);
glDrawElements(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_SHORT, Quad2DIndices);
targetPos.X += sourceRects[currentIndex].getWidth();
}
......@@ -2482,7 +2474,7 @@ void COpenGLDriver::draw2DRectangle(const core::rect<s32>& position,
glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]);
}
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, Quad2DIndices);
glDrawElements(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_SHORT, Quad2DIndices);
}
......@@ -2523,7 +2515,7 @@ void COpenGLDriver::draw2DLine(const core::position2d<s32>& start,
glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]);
}
glDrawElements(GL_LINES, 2, GL_UNSIGNED_SHORT, Line2DIndices);
glDrawElements(GL_LINES, 2, GL_UNSIGNED_SHORT, Quad2DIndices);
}
}
......@@ -3979,7 +3971,7 @@ void COpenGLDriver::drawStencilShadow(bool clearStencilBuffer, video::SColor lef
glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]);
}
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, Quad2DIndices);
glDrawElements(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_SHORT, Quad2DIndices);
clearBuffers(false, false, clearStencilBuffer, 0x0);
......@@ -4064,7 +4056,7 @@ void COpenGLDriver::draw3DLine(const core::vector3df& start,
glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]);
}
glDrawElements(GL_LINES, 2, GL_UNSIGNED_SHORT, Line2DIndices);
glDrawElements(GL_LINES, 2, GL_UNSIGNED_SHORT, Quad2DIndices);
}
......
......@@ -602,8 +602,7 @@ namespace video
//! Built-in 2D quad for 2D rendering.
S3DVertex Quad2DVertices[4];
u16 Quad2DIndices[6];
u16 Line2DIndices[2];
static const u16 Quad2DIndices[4];
#ifdef _IRR_WINDOWS_API_
HDC HDc; // Private GDI Device Context
......
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