progress rect

This commit is contained in:
Henrique Santiago
2012-06-10 03:09:37 -03:00
parent ea70b85c8b
commit 52333f5d28
14 changed files with 191 additions and 2 deletions

View File

@@ -41,6 +41,10 @@ public:
m_hardwareCached = false;
}
void addTriangle(const Point& a, const Point& b, const Point& c) {
m_vertexArray.addTriangle(a, b, c);
m_hardwareCached = false;
}
void addRect(const Rect& dest) {
m_vertexArray.addRect(dest);
m_hardwareCached = false;

View File

@@ -76,6 +76,7 @@ public:
void drawTexturedRect(const Rect& dest, const TexturePtr& texture) { drawTexturedRect(dest, texture, Rect(Point(0,0), texture->getSize())); }
virtual void drawRepeatedTexturedRect(const Rect& dest, const TexturePtr& texture, const Rect& src) = 0;
virtual void drawFilledRect(const Rect& dest) = 0;
virtual void drawFilledTriangle(const Point& a, const Point& b, const Point& c) = 0;
virtual void drawBoundingRect(const Rect& dest, int innerLineWidth = 1) = 0;
virtual void setProjectionMatrix(const Matrix3& projectionMatrix) { m_projectionMatrix = projectionMatrix; }

View File

@@ -167,6 +167,18 @@ void PainterOGL1::drawFilledRect(const Rect& dest)
drawCoords(m_coordsBuffer);
}
void PainterOGL1::drawFilledTriangle(const Point& a, const Point& b, const Point& c)
{
if(a == b || a == c || b == c)
return;
setTexture(nullptr);
m_coordsBuffer.clear();
m_coordsBuffer.addTriangle(a, b, c);
drawCoords(m_coordsBuffer);
}
void PainterOGL1::drawBoundingRect(const Rect& dest, int innerLineWidth)
{
if(dest.isEmpty() || innerLineWidth == 0)

View File

@@ -53,6 +53,7 @@ public:
void drawTexturedRect(const Rect& dest, const TexturePtr& texture, const Rect& src);
void drawRepeatedTexturedRect(const Rect& dest, const TexturePtr& texture, const Rect& src);
void drawFilledRect(const Rect& dest);
void drawFilledTriangle(const Point& a, const Point& b, const Point& c);
void drawBoundingRect(const Rect& dest, int innerLineWidth);
void setMatrixMode(MatrixMode matrixMode);

View File

@@ -150,6 +150,18 @@ void PainterOGL2::drawFilledRect(const Rect& dest)
drawCoords(m_coordsBuffer);
}
void PainterOGL2::drawFilledTriangle(const Point& a, const Point& b, const Point& c)
{
if(a == b || a == c || b == c)
return;
setDrawProgram(m_shaderProgram ? m_shaderProgram : g_shaders.getDrawSolidColorProgram().get());
m_coordsBuffer.clear();
m_coordsBuffer.addTriangle(a, b, c);
drawCoords(m_coordsBuffer);
}
void PainterOGL2::drawBoundingRect(const Rect& dest, int innerLineWidth)
{
if(dest.isEmpty() || innerLineWidth == 0)

View File

@@ -46,6 +46,7 @@ public:
void drawTexturedRect(const Rect& dest, const TexturePtr& texture, const Rect& src);
void drawRepeatedTexturedRect(const Rect& dest, const TexturePtr& texture, const Rect& src);
void drawFilledRect(const Rect& dest);
void drawFilledTriangle(const Point& a, const Point& b, const Point& c);
void drawBoundingRect(const Rect& dest, int innerLineWidth = 1);
void setDrawProgram(PainterShaderProgram *drawProgram) { m_drawProgram = drawProgram; }

View File

@@ -30,6 +30,11 @@ class VertexArray
{
public:
inline void addVertex(float x, float y) { m_buffer << x << y; }
inline void addTriangle(const Point& a, const Point& b, const Point& c) {
addVertex(a.x, a.y);
addVertex(b.x, b.y);
addVertex(c.x, c.y);
}
inline void addRect(const Rect& rect) {
float top = rect.top();
float right = rect.right()+1;