Mercurial > fife-parpg
changeset 583:47b49b9b0c0a
* Improved the floatingtextrenderer. Now you can set an alpha value for font, background quad and border. Splited quad and border into own commands.
* Added a triangle function to backends and genericrenderer, also added the functions to set an alpha value for geometric figures.
line wrap: on
line diff
--- a/demos/rio_de_hola/scripts/world.py Tue Aug 03 13:57:12 2010 +0000 +++ b/demos/rio_de_hola/scripts/world.py Sat Aug 07 16:36:35 2010 +0000 @@ -233,7 +233,8 @@ textfont = self.engine.getGuiManager().createFont('fonts/rpgfont.png', 0, str(TDS.get("FIFE", "FontGlyphs"))); renderer.changeDefaultFont(textfont) renderer.activateAllLayers(self.map) - renderer.setDefaultBackground(100, 255, 100, 50, 255, 50) + renderer.setDefaultBackground(100, 255, 100, 165) + renderer.setDefaultBorder(50, 255, 50) renderer.setEnabled(True) # Activate the grid renderer on all layers
--- a/engine/core/gui/base/gui_font.cpp Tue Aug 03 13:57:12 2010 +0000 +++ b/engine/core/gui/base/gui_font.cpp Sat Aug 07 16:36:35 2010 +0000 @@ -127,8 +127,8 @@ return m_font->splitTextToWidth(text,render_width); } - void GuiFont::setColor(uint8_t r,uint8_t g,uint8_t b) { - m_font->setColor(r, g, b); + void GuiFont::setColor(uint8_t r,uint8_t g,uint8_t b, uint8_t a) { + m_font->setColor(r, g, b, a); } SDL_Color GuiFont::getColor() const {
--- a/engine/core/gui/base/gui_font.h Tue Aug 03 13:57:12 2010 +0000 +++ b/engine/core/gui/base/gui_font.h Sat Aug 07 16:36:35 2010 +0000 @@ -57,7 +57,7 @@ bool isAntiAlias(); Image* getAsImage(const std::string& text); Image* getAsImageMultiline(const std::string& text); - void setColor(uint8_t r,uint8_t g,uint8_t b); + void setColor(uint8_t r,uint8_t g,uint8_t b, uint8_t a = 255); SDL_Color getColor() const; int getWidth(const std::string& text) const; int getHeight() const;
--- a/engine/core/gui/base/gui_font.i Tue Aug 03 13:57:12 2010 +0000 +++ b/engine/core/gui/base/gui_font.i Sat Aug 07 16:36:35 2010 +0000 @@ -60,7 +60,7 @@ void setAntiAlias(bool antiAlias); bool isAntiAlias(); Image* getAsImage(const std::string& text); - void setColor(uint8_t r,uint8_t g,uint8_t b); + void setColor(uint8_t r,uint8_t g,uint8_t b, uint8_t a = 255); SDL_Color getColor() const; int getWidth(const std::string& text) const; int getHeight() const;
--- a/engine/core/video/fonts/abstractfont.h Tue Aug 03 13:57:12 2010 +0000 +++ b/engine/core/video/fonts/abstractfont.h Sat Aug 07 16:36:35 2010 +0000 @@ -104,7 +104,7 @@ /** Set the color the text should be rendered in */ - virtual void setColor(uint8_t r,uint8_t g,uint8_t b) = 0; + virtual void setColor(uint8_t r,uint8_t g,uint8_t b, uint8_t a = 255) = 0; /** Get the color the text was rendered in */
--- a/engine/core/video/fonts/fonts.i Tue Aug 03 13:57:12 2010 +0000 +++ b/engine/core/video/fonts/fonts.i Sat Aug 07 16:36:35 2010 +0000 @@ -39,7 +39,7 @@ virtual int getGlyphSpacing() const = 0; virtual void setAntiAlias(bool antiAlias) = 0; virtual bool isAntiAlias() = 0; - virtual void setColor(uint8_t r,uint8_t g,uint8_t b) = 0; + virtual void setColor(uint8_t r,uint8_t g,uint8_t b, uint8_t a = 255) = 0; virtual SDL_Color getColor() const = 0; virtual int getWidth(const std::string& text) const = 0; virtual int getHeight() const = 0; @@ -56,7 +56,7 @@ public: TrueTypeFont(const std::string& filename, int size); virtual ~TrueTypeFont(); - virtual void setColor(Uint8 r, Uint8 g, Uint8 b); + virtual void setColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255); virtual int getWidth(const std::string& text) const; virtual int getHeight() const; }; @@ -67,7 +67,7 @@ public: SubImageFont(const std::string& filename, const std::string& glyphs, ImagePool& pool); virtual ~SubImageFont(); - virtual void setColor(Uint8 r, Uint8 g, Uint8 b); + virtual void setColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255); virtual int getWidth(const std::string& text) const; virtual int getHeight() const; };
--- a/engine/core/video/fonts/imagefontbase.cpp Tue Aug 03 13:57:12 2010 +0000 +++ b/engine/core/video/fonts/imagefontbase.cpp Sat Aug 07 16:36:35 2010 +0000 @@ -110,6 +110,6 @@ return surface; } - void ImageFontBase::setColor(Uint8 r, Uint8 g, Uint8 b) { + void ImageFontBase::setColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a) { } }
--- a/engine/core/video/fonts/imagefontbase.h Tue Aug 03 13:57:12 2010 +0000 +++ b/engine/core/video/fonts/imagefontbase.h Sat Aug 07 16:36:35 2010 +0000 @@ -66,7 +66,7 @@ virtual int getHeight() const; virtual SDL_Surface *renderString(const std::string& text); - virtual void setColor(Uint8 r, Uint8 g, Uint8 b); + virtual void setColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255); protected: // A glyph (visible character)
--- a/engine/core/video/fonts/truetypefont.cpp Tue Aug 03 13:57:12 2010 +0000 +++ b/engine/core/video/fonts/truetypefont.cpp Sat Aug 07 16:36:35 2010 +0000 @@ -49,7 +49,7 @@ if (mFont == NULL) { throw FIFE::CannotOpenFile(filename + " (" + TTF_GetError() + ")"); } - mColor.r = mColor.g = mColor.b = 255; + mColor.r = mColor.g = mColor.b = mColor.unused = 255; } TrueTypeFont::~TrueTypeFont() { @@ -94,9 +94,10 @@ return renderedText; } - void TrueTypeFont::setColor(Uint8 r, Uint8 g, Uint8 b) { + void TrueTypeFont::setColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a) { mColor.r = r; mColor.g = g; mColor.b = b; + mColor.unused = a; } }
--- a/engine/core/video/fonts/truetypefont.h Tue Aug 03 13:57:12 2010 +0000 +++ b/engine/core/video/fonts/truetypefont.h Sat Aug 07 16:36:35 2010 +0000 @@ -73,7 +73,7 @@ virtual SDL_Surface *renderString(const std::string& text); - virtual void setColor(Uint8 r, Uint8 g, Uint8 b); + virtual void setColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255); protected: TTF_Font *mFont;
--- a/engine/core/video/image.h Tue Aug 03 13:57:12 2010 +0000 +++ b/engine/core/video/image.h Sat Aug 07 16:36:35 2010 +0000 @@ -68,19 +68,23 @@ /** Writes pixel to given position. Returns true, if pixel was written (not out of bounds) */ - virtual bool putPixel(int x, int y, int r, int g, int b) = 0; + virtual bool putPixel(int x, int y, int r, int g, int b, int a = 255) = 0; /** Draws line between given points with given RGBA */ - virtual void drawLine(const Point& p1, const Point& p2, int r, int g, int b) = 0; + virtual void drawLine(const Point& p1, const Point& p2, int r, int g, int b, int a = 255) = 0; + + /** Draws triangle between given points with given RGBA + */ + virtual void drawTriangle(const Point& p1, const Point& p2, const Point& p3, int r, int g, int b, int a = 255) = 0; /** Draws quad between given points with given RGBA */ - virtual void drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b) = 0; + virtual void drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b, int a = 255) = 0; /** Draws a quad that represents a vertex with given RGBA */ - virtual void drawVertex(const Point& p, const uint8_t size, int r, int g, int b) = 0; + virtual void drawVertex(const Point& p, const uint8_t size, int r, int g, int b, int a = 255) = 0; /** Returns pixel RGBA values from given position */
--- a/engine/core/video/opengl/glimage.cpp Tue Aug 03 13:57:12 2010 +0000 +++ b/engine/core/video/opengl/glimage.cpp Sat Aug 07 16:36:35 2010 +0000 @@ -315,23 +315,28 @@ } } - bool GLImage::putPixel(int x, int y, int r, int g, int b) { + bool GLImage::putPixel(int x, int y, int r, int g, int b, int a) { cleanup(); - return m_sdlimage->putPixel(x, y, r, g, b); + return m_sdlimage->putPixel(x, y, r, g, b, a); } - void GLImage::drawLine(const Point& p1, const Point& p2, int r, int g, int b) { + void GLImage::drawLine(const Point& p1, const Point& p2, int r, int g, int b, int a) { cleanup(); - m_sdlimage->drawLine(p1, p2, r, g, b); + m_sdlimage->drawLine(p1, p2, r, g, b, a); } - void GLImage::drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b) { + void GLImage::drawTriangle(const Point& p1, const Point& p2, const Point& p3, int r, int g, int b, int a) { cleanup(); - m_sdlimage->drawQuad(p1, p2, p3, p4, r, g, b); + m_sdlimage->drawTriangle(p1, p2, p3, r, g, b, a); } - void GLImage::drawVertex(const Point& p, const uint8_t size, int r, int g, int b) { + void GLImage::drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b, int a) { cleanup(); - m_sdlimage->drawVertex(p, size, r, g, b); + m_sdlimage->drawQuad(p1, p2, p3, p4, r, g, b, a); + } + + void GLImage::drawVertex(const Point& p, const uint8_t size, int r, int g, int b, int a) { + cleanup(); + m_sdlimage->drawVertex(p, size, r, g, b, a); } }
--- a/engine/core/video/opengl/glimage.h Tue Aug 03 13:57:12 2010 +0000 +++ b/engine/core/video/opengl/glimage.h Sat Aug 07 16:36:35 2010 +0000 @@ -62,10 +62,11 @@ virtual ~GLImage(); void render(const Rect& rect, SDL_Surface* dst, unsigned char alpha = 255); void saveImage(const std::string& filename); - bool putPixel(int x, int y, int r, int g, int b); - void drawLine(const Point& p1, const Point& p2, int r, int g, int b); - void drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b); - void drawVertex(const Point& p, const uint8_t size, int r, int g, int b); + bool putPixel(int x, int y, int r, int g, int b, int a = 255); + void drawLine(const Point& p1, const Point& p2, int r, int g, int b, int a = 255); + void drawTriangle(const Point& p1, const Point& p2, const Point& p3, int r, int g, int b, int a = 255); + void drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b, int a = 255); + void drawVertex(const Point& p, const uint8_t size, int r, int g, int b, int a = 255); protected: void setClipArea(const Rect& cliparea, bool clear);
--- a/engine/core/video/opengl/renderbackendopengl.cpp Tue Aug 03 13:57:12 2010 +0000 +++ b/engine/core/video/opengl/renderbackendopengl.cpp Sat Aug 07 16:36:35 2010 +0000 @@ -183,19 +183,22 @@ m_clear = clear; } - bool RenderBackendOpenGL::putPixel(int x, int y, int r, int g, int b) { + bool RenderBackendOpenGL::putPixel(int x, int y, int r, int g, int b, int a) { if ((x < 0) || (x >= (int)getWidth()) || (y < 0) || (y >= (int)getHeight())) { return false; } - glColor3ub(r, g, b); + + glColor4ub(r, g, b, a); + glBegin(GL_POINTS); glVertex2i(x, y); glEnd(); return true; } - void RenderBackendOpenGL::drawLine(const Point& p1, const Point& p2, int r, int g, int b) { - glColor3ub(r, g, b); + void RenderBackendOpenGL::drawLine(const Point& p1, const Point& p2, int r, int g, int b, int a) { + glColor4ub(r, g, b, a); + glBegin(GL_LINES); glVertex2f(p1.x+0.5f, p1.y+0.5f); glVertex2f(p2.x+0.5f, p2.y+0.5f); @@ -206,8 +209,19 @@ glEnd(); } - void RenderBackendOpenGL::drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b) { - glColor4ub(r, g, b, 165); + void RenderBackendOpenGL::drawTriangle(const Point& p1, const Point& p2, const Point& p3, int r, int g, int b, int a) { + glColor4ub(r, g, b, a); + + glBegin(GL_TRIANGLES); + glVertex2f(p1.x, p1.y); + glVertex2f(p2.x, p2.y); + glVertex2f(p3.x, p3.y); + glEnd(); + } + + void RenderBackendOpenGL::drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b, int a) { + glColor4ub(r, g, b, a); + glBegin(GL_QUADS); glVertex2f(p1.x, p1.y); glVertex2f(p2.x, p2.y); @@ -216,12 +230,13 @@ glEnd(); } - void RenderBackendOpenGL::drawVertex(const Point& p, const uint8_t size, int r, int g, int b){ + void RenderBackendOpenGL::drawVertex(const Point& p, const uint8_t size, int r, int g, int b, int a){ GLfloat width; glGetFloatv(GL_LINE_WIDTH, &width); glLineWidth(1.0); - glColor3ub(r, g, b); + glColor4ub(r, g, b, a); + glBegin(GL_LINE_LOOP); glVertex2f(p.x-size, p.y+size); glVertex2f(p.x+size, p.y+size);
--- a/engine/core/video/opengl/renderbackendopengl.h Tue Aug 03 13:57:12 2010 +0000 +++ b/engine/core/video/opengl/renderbackendopengl.h Sat Aug 07 16:36:35 2010 +0000 @@ -48,10 +48,11 @@ Image* createMainScreen(unsigned int width, unsigned int height, unsigned char bitsPerPixel, bool fullscreen, const std::string& title, const std::string& icon); Image* createImage(const uint8_t* data, unsigned int width, unsigned int height); Image* createImage(SDL_Surface* surface); - bool putPixel(int x, int y, int r, int g, int b); - void drawLine(const Point& p1, const Point& p2, int r, int g, int b); - void drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b); - void drawVertex(const Point& p, const uint8_t size, int r, int g, int b); + bool putPixel(int x, int y, int r, int g, int b, int a = 255); + void drawLine(const Point& p1, const Point& p2, int r, int g, int b, int a = 255); + void drawTriangle(const Point& p1, const Point& p2, const Point& p3, int r, int g, int b, int a = 255); + void drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b, int a = 255); + void drawVertex(const Point& p, const uint8_t size, int r, int g, int b, int a = 255); void isClearNeeded(bool clear);
--- a/engine/core/video/sdl/renderbackendsdl.cpp Tue Aug 03 13:57:12 2010 +0000 +++ b/engine/core/video/sdl/renderbackendsdl.cpp Sat Aug 07 16:36:35 2010 +0000 @@ -139,20 +139,24 @@ m_clear = clear; } - bool RenderBackendSDL::putPixel(int x, int y, int r, int g, int b) { - return static_cast<SDLImage*>(m_screen)->putPixel(x, y, r, g, b); + bool RenderBackendSDL::putPixel(int x, int y, int r, int g, int b, int a) { + return static_cast<SDLImage*>(m_screen)->putPixel(x, y, r, g, b, a); + } + + void RenderBackendSDL::drawLine(const Point& p1, const Point& p2, int r, int g, int b, int a) { + static_cast<SDLImage*>(m_screen)->drawLine(p1, p2, r, g, b, a); } - void RenderBackendSDL::drawLine(const Point& p1, const Point& p2, int r, int g, int b) { - static_cast<SDLImage*>(m_screen)->drawLine(p1, p2, r, g, b); + void RenderBackendSDL::drawTriangle(const Point& p1, const Point& p2, const Point& p3, int r, int g, int b, int a) { + static_cast<SDLImage*>(m_screen)->drawTriangle(p1, p2, p3, r, g, b, a); } - void RenderBackendSDL::drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b) { - static_cast<SDLImage*>(m_screen)->drawQuad(p1, p2, p3, p4, r, g, b); + void RenderBackendSDL::drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b, int a) { + static_cast<SDLImage*>(m_screen)->drawQuad(p1, p2, p3, p4, r, g, b, a); } - void RenderBackendSDL::drawVertex(const Point& p, const uint8_t size, int r, int g, int b){ - static_cast<SDLImage*>(m_screen)->drawVertex(p, 2, r, g, b); + void RenderBackendSDL::drawVertex(const Point& p, const uint8_t size, int r, int g, int b, int a){ + static_cast<SDLImage*>(m_screen)->drawVertex(p, 2, r, g, b, a); } }//FIFE
--- a/engine/core/video/sdl/renderbackendsdl.h Tue Aug 03 13:57:12 2010 +0000 +++ b/engine/core/video/sdl/renderbackendsdl.h Sat Aug 07 16:36:35 2010 +0000 @@ -50,10 +50,11 @@ Image* createMainScreen(unsigned int width, unsigned int height, unsigned char bitsPerPixel, bool fullscreen, const std::string& title, const std::string& icon); Image* createImage(const uint8_t* data, unsigned int width, unsigned int height); Image* createImage(SDL_Surface* surface); - bool putPixel(int x, int y, int r, int g, int b); - void drawLine(const Point& p1, const Point& p2, int r, int g, int b); - void drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b); - void drawVertex(const Point& p, const uint8_t size, int r, int g, int b); + bool putPixel(int x, int y, int r, int g, int b, int a = 255); + void drawLine(const Point& p1, const Point& p2, int r, int g, int b, int a = 255); + void drawTriangle(const Point& p1, const Point& p2, const Point& p3, int r, int g, int b, int a = 255); + void drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b, int a = 255); + void drawVertex(const Point& p, const uint8_t size, int r, int g, int b, int a = 255); void isClearNeeded(bool clear);
--- a/engine/core/video/sdl/sdlimage.cpp Tue Aug 03 13:57:12 2010 +0000 +++ b/engine/core/video/sdl/sdlimage.cpp Sat Aug 07 16:36:35 2010 +0000 @@ -470,7 +470,7 @@ return convert; } // end optimize - bool SDLImage::putPixel(int x, int y, int r, int g, int b) { + bool SDLImage::putPixel(int x, int y, int r, int g, int b, int a) { if ((x < 0) || (x >= m_surface->w) || (y < 0) || (y >= m_surface->h)) { return false; } @@ -510,7 +510,7 @@ return true; } - void SDLImage::drawLine(const Point& p1, const Point& p2, int r, int g, int b) { + void SDLImage::drawLine(const Point& p1, const Point& p2, int r, int g, int b, int a) { // Draw a line with Bresenham, imitated from guichan int x1 = p1.x; int x2 = p2.x; @@ -537,7 +537,7 @@ int p = 0; for (int x = x1; x <= x2; x++) { - putPixel(x, y, r, g, b); + putPixel(x, y, r, g, b, a); p += dy; if (p * 2 >= dx) { y++; @@ -550,7 +550,7 @@ int p = 0; for (int x = x1; x <= x2; x++) { - putPixel(x, y, r, g, b); + putPixel(x, y, r, g, b, a); p += dy; if (p * 2 >= dx) { @@ -578,7 +578,7 @@ int p = 0; for (int y = y1; y <= y2; y++) { - putPixel(x, y, r, g, b); + putPixel(x, y, r, g, b, a); p += dx; if (p * 2 >= dy) { x++; @@ -591,7 +591,7 @@ int p = 0; for (int y = y1; y <= y2; y++) { - putPixel(x, y, r, g, b); + putPixel(x, y, r, g, b, a); p += dx; if (p * 2 >= dy) { x--; @@ -602,23 +602,29 @@ } } - void SDLImage::drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b) { - drawLine(p1, p2, r, g, b); - drawLine(p2, p3, r, g, b); - drawLine(p3, p4, r, g, b); - drawLine(p4, p1, r, g, b); + void SDLImage::drawTriangle(const Point& p1, const Point& p2, const Point& p3, int r, int g, int b, int a) { + drawLine(p1, p2, r, g, b, a); + drawLine(p2, p3, r, g, b, a); + drawLine(p3, p1, r, g, b, a); } - void SDLImage::drawVertex(const Point& p, const uint8_t size, int r, int g, int b){ + void SDLImage::drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b, int a) { + drawLine(p1, p2, r, g, b, a); + drawLine(p2, p3, r, g, b, a); + drawLine(p3, p4, r, g, b, a); + drawLine(p4, p1, r, g, b, a); + } + + void SDLImage::drawVertex(const Point& p, const uint8_t size, int r, int g, int b, int a){ Point p1 = Point(p.x-size, p.y+size); Point p2 = Point(p.x+size, p.y+size); Point p3 = Point(p.x+size, p.y-size); Point p4 = Point(p.x-size, p.y-size); - drawLine(p1, p2, r, g, b); - drawLine(p2, p3, r, g, b); - drawLine(p3, p4, r, g, b); - drawLine(p4, p1, r, g, b); + drawLine(p1, p2, r, g, b, a); + drawLine(p2, p3, r, g, b, a); + drawLine(p3, p4, r, g, b, a); + drawLine(p4, p1, r, g, b, a); } void SDLImage::saveImage(const std::string& filename) {
--- a/engine/core/video/sdl/sdlimage.h Tue Aug 03 13:57:12 2010 +0000 +++ b/engine/core/video/sdl/sdlimage.h Sat Aug 07 16:36:35 2010 +0000 @@ -44,10 +44,11 @@ virtual ~SDLImage(); void render(const Rect& rect, SDL_Surface* dst, unsigned char alpha = 255); void saveImage(const std::string& filename); - bool putPixel(int x, int y, int r, int g, int b); - void drawLine(const Point& p1, const Point& p2, int r, int g, int b); - void drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b); - void drawVertex(const Point& p, const uint8_t size, int r, int g, int b); + bool putPixel(int x, int y, int r, int g, int b, int a = 255); + void drawLine(const Point& p1, const Point& p2, int r, int g, int b, int a = 255); + void drawTriangle(const Point& p1, const Point& p2, const Point& p3, int r, int g, int b, int a = 255); + void drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b, int a = 255); + void drawVertex(const Point& p, const uint8_t size, int r, int g, int b, int a = 255); protected: void setClipArea(const Rect& cliparea, bool clear);
--- a/engine/core/video/video.i Tue Aug 03 13:57:12 2010 +0000 +++ b/engine/core/video/video.i Sat Aug 07 16:36:35 2010 +0000 @@ -49,9 +49,10 @@ virtual unsigned int getHeight() const = 0; virtual const Rect& getArea() = 0; virtual void getPixelRGBA(int x, int y, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) = 0; - virtual bool putPixel(int x, int y, int r, int g, int b) = 0; - virtual void drawLine(const Point& p1, const Point& p2, int r, int g, int b) = 0; - virtual void drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b) = 0; + virtual bool putPixel(int x, int y, int r, int g, int b, int a = 255) = 0; + virtual void drawLine(const Point& p1, const Point& p2, int r, int g, int b, int a = 255) = 0; + virtual void drawTriangle(const Point& p1, const Point& p2, const Point& p3, int r, int g, int b, int a = 255) = 0; + virtual void drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b, int a = 255) = 0; virtual void pushClipArea(const Rect& cliparea, bool clear=true) = 0; virtual void popClipArea() = 0; virtual const Rect& getClipArea() const = 0; @@ -152,10 +153,11 @@ unsigned int getScreenHeight() const { return getHeight(); } const Rect& getArea(); void getPixelRGBA(int x, int y, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a); - bool putPixel(int x, int y, int r, int g, int b); - void drawLine(const Point& p1, const Point& p2, int r, int g, int b); - void drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b); - void drawVertex(const Point& p, int size, int r, int g, int b); + bool putPixel(int x, int y, int r, int g, int b, int a = 255); + void drawLine(const Point& p1, const Point& p2, int r, int g, int b, int a = 255); + void drawTriangle(const Point& p1, const Point& p2, const Point& p3, int r, int g, int b, int a = 255); + void drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b, int a = 255); + void drawVertex(const Point& p, int size, int r, int g, int b, int a = 255); void pushClipArea(const Rect& cliparea, bool clear=true); void popClipArea(); const Rect& getClipArea() const;
--- a/engine/core/view/renderers/floatingtextrenderer.cpp Tue Aug 03 13:57:12 2010 +0000 +++ b/engine/core/view/renderers/floatingtextrenderer.cpp Sat Aug 07 16:36:35 2010 +0000 @@ -61,6 +61,7 @@ m_font_color(old.m_font_color), m_color(old.m_color) { setEnabled(false); + m_font_color = m_background = m_backborder = false; } RendererBase* FloatingTextRenderer::clone() { @@ -78,9 +79,8 @@ RenderList::const_iterator instance_it = instances.begin(); const std::string* saytext = NULL; SDL_Color old_color = m_font->getColor(); - if(old_color.r != m_color.r || old_color.g != m_color.g || old_color.b != m_color.b) { - m_font->setColor(m_color.r, m_color.g, m_color.b); - m_font_color = true; + if(m_font_color) { + m_font->setColor(m_color.r, m_color.g, m_color.b, m_color.unused); } for (;instance_it != instances.end(); ++instance_it) { Instance* instance = (*instance_it)->instance; @@ -93,51 +93,67 @@ r.y = ir.y- img->getHeight(); /// make the text rect floating higher than the instance. r.w = img->getWidth(); r.h = img->getHeight(); - if(m_background) { + if(m_background || m_backborder) { const int overdraw = 5; Point p1 = Point(r.x-overdraw, r.y-overdraw); Point p2 = Point(r.x+r.w+overdraw, r.y-overdraw); Point p3 = Point(r.x+r.w+overdraw, r.y+r.h+overdraw); Point p4 = Point(r.x-overdraw, r.y+r.h+overdraw); - m_renderbackend->drawQuad(p1, p2, p3, p4, m_backcolor.r, m_backcolor.g, m_backcolor.b); + if(m_background) { + m_renderbackend->drawQuad(p1, p2, p3, p4, m_backcolor.r, m_backcolor.g, m_backcolor.b, m_backcolor.unused); + } - m_renderbackend->drawLine(p1, p2, m_backbordercolor.r, m_backbordercolor.g, m_backbordercolor.b); - m_renderbackend->drawLine(p2, p3, m_backbordercolor.r, m_backbordercolor.g, m_backbordercolor.b); - m_renderbackend->drawLine(p3, p4, m_backbordercolor.r, m_backbordercolor.g, m_backbordercolor.b); - m_renderbackend->drawLine(p4, p1, m_backbordercolor.r, m_backbordercolor.g, m_backbordercolor.b); + if(m_backborder) { + m_renderbackend->drawLine(p1, p2, m_backbordercolor.r, m_backbordercolor.g, m_backbordercolor.b, m_backbordercolor.unused); + m_renderbackend->drawLine(p2, p3, m_backbordercolor.r, m_backbordercolor.g, m_backbordercolor.b, m_backbordercolor.unused); + m_renderbackend->drawLine(p3, p4, m_backbordercolor.r, m_backbordercolor.g, m_backbordercolor.b, m_backbordercolor.unused); + m_renderbackend->drawLine(p4, p1, m_backbordercolor.r, m_backbordercolor.g, m_backbordercolor.b, m_backbordercolor.unused); + } } img->render(r); } } if(m_font_color) { - m_font->setColor(old_color.r, old_color.g, old_color.b); - m_font_color = false; + m_font->setColor(old_color.r, old_color.g, old_color.b, old_color.unused); } } - void FloatingTextRenderer::setColor(Uint8 r, Uint8 g, Uint8 b) { + void FloatingTextRenderer::setColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a) { m_color.r = r; m_color.g = g; m_color.b = b; + m_color.unused = a; + + m_font_color = true; } - void FloatingTextRenderer::setDefaultBackground(Uint8 br, Uint8 bg, Uint8 bb, Uint8 bbr, Uint8 bbg, Uint8 bbb) { + void FloatingTextRenderer::setDefaultBackground(Uint8 br, Uint8 bg, Uint8 bb, Uint8 ba) { m_backcolor.r = br; m_backcolor.g = bg; m_backcolor.b = bb; + m_backcolor.unused = ba; + m_background = true; + } + + void FloatingTextRenderer::setDefaultBorder(Uint8 bbr, Uint8 bbg, Uint8 bbb, Uint8 bba) { m_backbordercolor.r = bbr; m_backbordercolor.g = bbg; m_backbordercolor.b = bbb; + m_backbordercolor.unused = bba; - m_background = true; + m_backborder = true; } void FloatingTextRenderer::resetDefaultBackground() { m_background = false; } + void FloatingTextRenderer::resetDefaultBorder() { + m_backborder = false; + } + FloatingTextRenderer* FloatingTextRenderer::getInstance(IRendererContainer* cnt) { return dynamic_cast<FloatingTextRenderer*>(cnt->getRenderer("FloatingTextRenderer")); }
--- a/engine/core/view/renderers/floatingtextrenderer.h Tue Aug 03 13:57:12 2010 +0000 +++ b/engine/core/view/renderers/floatingtextrenderer.h Sat Aug 07 16:36:35 2010 +0000 @@ -65,17 +65,26 @@ /** Changes default font color * Only usefull for .ttf fonts */ - void setColor(Uint8 r, Uint8 g, Uint8 b); + void setColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255); - /** Set default background quad with border - * first r,g,b values for background, second for border color + /** Set default background quad + * r,g,b,a values for background */ - void setDefaultBackground(Uint8 br, Uint8 bg, Uint8 bb, Uint8 bbr, Uint8 bbg, Uint8 bbb); + void setDefaultBackground(Uint8 br, Uint8 bg, Uint8 bb, Uint8 ba = 255); + + /** Set default border + * r,g,b,a values for border + */ + void setDefaultBorder(Uint8 bbr, Uint8 bbg, Uint8 bbb, Uint8 bba = 255); /** Disable the default background */ void resetDefaultBackground(); + /** Disable the default border + */ + void resetDefaultBorder(); + /** returns instance used in given view */ static FloatingTextRenderer* getInstance(IRendererContainer* cnt); @@ -86,6 +95,7 @@ bool m_font_color; SDL_Color m_color; bool m_background; + bool m_backborder; SDL_Color m_backcolor; SDL_Color m_backbordercolor; };
--- a/engine/core/view/renderers/floatingtextrenderer.i Tue Aug 03 13:57:12 2010 +0000 +++ b/engine/core/view/renderers/floatingtextrenderer.i Sat Aug 07 16:36:35 2010 +0000 @@ -32,9 +32,11 @@ public: virtual ~FloatingTextRenderer(); void changeDefaultFont(AbstractFont* font); - void setColor(Uint8 r, Uint8 g, Uint8 b); - void setDefaultBackground(Uint8 br, Uint8 bg, Uint8 bb, Uint8 bbr, Uint8 bbg, Uint8 bbb); + void setColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255); + void setDefaultBackground(Uint8 br, Uint8 bg, Uint8 bb, Uint8 ba = 255); + void setDefaultBorder(Uint8 bbr, Uint8 bbg, Uint8 bbb, Uint8 bba = 255); void resetDefaultBackground(); + void resetDefaultBorder(); static FloatingTextRenderer* getInstance(IRendererContainer* cnt);
--- a/engine/core/view/renderers/genericrenderer.cpp Tue Aug 03 13:57:12 2010 +0000 +++ b/engine/core/view/renderers/genericrenderer.cpp Sat Aug 07 16:36:35 2010 +0000 @@ -229,37 +229,58 @@ return Point(m_point.x + p.x, m_point.y + p.y); } - GenericRendererLineInfo::GenericRendererLineInfo(GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b): + GenericRendererLineInfo::GenericRendererLineInfo(GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b, uint8_t a): GenericRendererElementInfo(), m_edge1(n1), m_edge2(n2), m_red(r), m_green(g), - m_blue(b) { + m_blue(b), + m_alpha(a) { } void GenericRendererLineInfo::render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) { Point p1 = m_edge1.getCalculatedPoint(cam, layer); Point p2 = m_edge2.getCalculatedPoint(cam, layer); if(m_edge1.getLayer() == layer) { - renderbackend->drawLine(p1, p2, m_red, m_green, m_blue); + renderbackend->drawLine(p1, p2, m_red, m_green, m_blue, m_alpha); } } - GenericRendererPointInfo::GenericRendererPointInfo(GenericRendererNode anchor, uint8_t r, uint8_t g, uint8_t b): + GenericRendererPointInfo::GenericRendererPointInfo(GenericRendererNode anchor, uint8_t r, uint8_t g, uint8_t b, uint8_t a): GenericRendererElementInfo(), m_anchor(anchor), m_red(r), m_green(g), - m_blue(b) { + m_blue(b), + m_alpha(a) { } void GenericRendererPointInfo::render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) { Point p = m_anchor.getCalculatedPoint(cam, layer); if(m_anchor.getLayer() == layer) { - renderbackend->putPixel(p.x, p.y, m_red, m_green, m_blue); + renderbackend->putPixel(p.x, p.y, m_red, m_green, m_blue, m_alpha); } } - GenericRendererQuadInfo::GenericRendererQuadInfo(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b): + GenericRendererTriangleInfo::GenericRendererTriangleInfo(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, uint8_t r, uint8_t g, uint8_t b, uint8_t a): + GenericRendererElementInfo(), + m_edge1(n1), + m_edge2(n2), + m_edge3(n3), + m_red(r), + m_green(g), + m_blue(b), + m_alpha(a) { + } + void GenericRendererTriangleInfo::render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) { + Point p1 = m_edge1.getCalculatedPoint(cam, layer); + Point p2 = m_edge2.getCalculatedPoint(cam, layer); + Point p3 = m_edge3.getCalculatedPoint(cam, layer); + if(m_edge1.getLayer() == layer) { + renderbackend->drawTriangle(p1, p2, p3, m_red, m_green, m_blue, m_alpha); + } + } + + GenericRendererQuadInfo::GenericRendererQuadInfo(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b, uint8_t a): GenericRendererElementInfo(), m_edge1(n1), m_edge2(n2), @@ -267,7 +288,8 @@ m_edge4(n4), m_red(r), m_green(g), - m_blue(b) { + m_blue(b), + m_alpha(a) { } void GenericRendererQuadInfo::render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) { Point p1 = m_edge1.getCalculatedPoint(cam, layer); @@ -275,22 +297,23 @@ Point p3 = m_edge3.getCalculatedPoint(cam, layer); Point p4 = m_edge4.getCalculatedPoint(cam, layer); if(m_edge1.getLayer() == layer) { - renderbackend->drawQuad(p1, p2, p3, p4, m_red, m_green, m_blue); + renderbackend->drawQuad(p1, p2, p3, p4, m_red, m_green, m_blue, m_alpha); } } - GenericRendererVertexInfo::GenericRendererVertexInfo(GenericRendererNode center, int size, uint8_t r, uint8_t g, uint8_t b): + GenericRendererVertexInfo::GenericRendererVertexInfo(GenericRendererNode center, int size, uint8_t r, uint8_t g, uint8_t b, uint8_t a): GenericRendererElementInfo(), m_center(center), m_size(size), m_red(r), m_green(g), - m_blue(b) { + m_blue(b), + m_alpha(a) { } void GenericRendererVertexInfo::render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) { Point p = m_center.getCalculatedPoint(cam, layer); if(m_center.getLayer() == layer) { - renderbackend->drawVertex(p, m_size, m_red, m_green, m_blue); + renderbackend->drawVertex(p, m_size, m_red, m_green, m_blue, m_alpha); } } @@ -385,20 +408,24 @@ GenericRenderer::~GenericRenderer() { } - void GenericRenderer::addLine(const std::string &group, GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b) { - GenericRendererElementInfo* info = new GenericRendererLineInfo(n1, n2, r, g, b); + void GenericRenderer::addLine(const std::string &group, GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { + GenericRendererElementInfo* info = new GenericRendererLineInfo(n1, n2, r, g, b, a); + m_groups[group].push_back(info); + } + void GenericRenderer::addPoint(const std::string &group, GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { + GenericRendererElementInfo* info = new GenericRendererPointInfo(n, r, g, b, a); m_groups[group].push_back(info); } - void GenericRenderer::addPoint(const std::string &group, GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b) { - GenericRendererElementInfo* info = new GenericRendererPointInfo(n, r, g, b); + void GenericRenderer::addTriangle(const std::string &group, GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { + GenericRendererElementInfo* info = new GenericRendererTriangleInfo(n1, n2, n3, r, g, b, a); m_groups[group].push_back(info); } - void GenericRenderer::addQuad(const std::string &group, GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b) { - GenericRendererElementInfo* info = new GenericRendererQuadInfo(n1, n2, n3, n4, r, g, b); + void GenericRenderer::addQuad(const std::string &group, GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { + GenericRendererElementInfo* info = new GenericRendererQuadInfo(n1, n2, n3, n4, r, g, b, a); m_groups[group].push_back(info); } - void GenericRenderer::addVertex(const std::string &group, GenericRendererNode n, int size, uint8_t r, uint8_t g, uint8_t b) { - GenericRendererElementInfo* info = new GenericRendererVertexInfo(n, size, r, g, b); + void GenericRenderer::addVertex(const std::string &group, GenericRendererNode n, int size, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { + GenericRendererElementInfo* info = new GenericRendererVertexInfo(n, size, r, g, b, a); m_groups[group].push_back(info); } void GenericRenderer::addText(const std::string &group, GenericRendererNode n, AbstractFont* font, const std::string &text) {
--- a/engine/core/view/renderers/genericrenderer.h Tue Aug 03 13:57:12 2010 +0000 +++ b/engine/core/view/renderers/genericrenderer.h Sat Aug 07 16:36:35 2010 +0000 @@ -92,7 +92,7 @@ class GenericRendererLineInfo : public GenericRendererElementInfo { public: void render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool); - GenericRendererLineInfo(GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b); + GenericRendererLineInfo(GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b, uint8_t a); virtual ~GenericRendererLineInfo() {}; private: GenericRendererNode m_edge1; @@ -100,22 +100,38 @@ uint8_t m_red; uint8_t m_green; uint8_t m_blue; + uint8_t m_alpha; }; class GenericRendererPointInfo : public GenericRendererElementInfo { public: void render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool); - GenericRendererPointInfo(GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b); + GenericRendererPointInfo(GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b, uint8_t a); virtual ~GenericRendererPointInfo() {}; private: GenericRendererNode m_anchor; uint8_t m_red; uint8_t m_green; uint8_t m_blue; + uint8_t m_alpha; + }; + class GenericRendererTriangleInfo : public GenericRendererElementInfo { + public: + void render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool); + GenericRendererTriangleInfo(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, uint8_t r, uint8_t g, uint8_t b, uint8_t a); + virtual ~GenericRendererTriangleInfo() {}; + private: + GenericRendererNode m_edge1; + GenericRendererNode m_edge2; + GenericRendererNode m_edge3; + uint8_t m_red; + uint8_t m_green; + uint8_t m_blue; + uint8_t m_alpha; }; class GenericRendererQuadInfo : public GenericRendererElementInfo { public: void render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool); - GenericRendererQuadInfo(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b); + GenericRendererQuadInfo(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b, uint8_t a); virtual ~GenericRendererQuadInfo() {}; private: GenericRendererNode m_edge1; @@ -125,12 +141,13 @@ uint8_t m_red; uint8_t m_green; uint8_t m_blue; + uint8_t m_alpha; }; class GenericRendererVertexInfo : public GenericRendererElementInfo { public: void render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool); - GenericRendererVertexInfo(GenericRendererNode center, int size, uint8_t r, uint8_t g, uint8_t b); + GenericRendererVertexInfo(GenericRendererNode center, int size, uint8_t r, uint8_t g, uint8_t b, uint8_t a); virtual ~GenericRendererVertexInfo() {}; private: GenericRendererNode m_center; @@ -138,6 +155,7 @@ uint8_t m_red; uint8_t m_green; uint8_t m_blue; + uint8_t m_alpha; }; class GenericRendererImageInfo : public GenericRendererElementInfo { @@ -192,10 +210,11 @@ */ static GenericRenderer* getInstance(IRendererContainer* cnt); - void addLine(const std::string &group, GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b); - void addPoint(const std::string &group, GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b); - void addQuad(const std::string &group, GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b); - void addVertex(const std::string &group, GenericRendererNode n, int size, uint8_t r, uint8_t g, uint8_t b); + void addLine(const std::string &group, GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); + void addPoint(const std::string &group, GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); + void addTriangle(const std::string &group, GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); + void addQuad(const std::string &group, GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); + void addVertex(const std::string &group, GenericRendererNode n, int size, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); void addText(const std::string &group, GenericRendererNode n, AbstractFont* font, const std::string &text); void addImage(const std::string &group, GenericRendererNode n, int image); void addAnimation(const std::string &group, GenericRendererNode n, int animation);
--- a/engine/core/view/renderers/genericrenderer.i Tue Aug 03 13:57:12 2010 +0000 +++ b/engine/core/view/renderers/genericrenderer.i Sat Aug 07 16:36:35 2010 +0000 @@ -79,7 +79,7 @@ class GenericRendererLineInfo : public GenericRendererElementInfo { public: - GenericRendererLineInfo(GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b); + GenericRendererLineInfo(GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b, uint8_t a); virtual ~GenericRendererLineInfo() {}; private: GenericRendererNode m_edge1; @@ -87,20 +87,35 @@ uint8_t m_red; uint8_t m_green; uint8_t m_blue; + uint8_t m_alpha; }; class GenericRendererPointInfo : public GenericRendererElementInfo { public: - GenericRendererPointInfo(GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b); + GenericRendererPointInfo(GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b, uint8_t a); virtual ~GenericRendererPointInfo() {}; private: GenericRendererNode m_anchor; uint8_t m_red; uint8_t m_green; uint8_t m_blue; + uint8_t m_alpha; + }; + class GenericRendererTriangleInfo : public GenericRendererElementInfo { + public: + GenericRendererTriangleInfo(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, uint8_t r, uint8_t g, uint8_t b, uint8_t a); + virtual ~GenericRendererTriangleInfo() {}; + private: + GenericRendererNode m_edge1; + GenericRendererNode m_edge2; + GenericRendererNode m_edge3; + uint8_t m_red; + uint8_t m_green; + uint8_t m_blue; + uint8_t m_alpha; }; class GenericRendererQuadInfo : public GenericRendererElementInfo { public: - GenericRendererQuadInfo(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b); + GenericRendererQuadInfo(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b, uint8_t a); virtual ~GenericRendererQuadInfo() {}; private: GenericRendererNode m_edge1; @@ -110,10 +125,11 @@ uint8_t m_red; uint8_t m_green; uint8_t m_blue; + uint8_t m_alpha; }; class GenericRendererVertexInfo : public GenericRendererElementInfo { public: - GenericRendererVertexInfo(GenericRendererNode center, int size, uint8_t r, uint8_t g, uint8_t b); + GenericRendererVertexInfo(GenericRendererNode center, int size, uint8_t r, uint8_t g, uint8_t b, uint8_t a); virtual ~GenericRendererVertexInfo() {}; private: GenericRendererNode m_center; @@ -121,6 +137,7 @@ uint8_t m_red; uint8_t m_green; uint8_t m_blue; + uint8_t m_alpha; }; class GenericRendererImageInfo : public GenericRendererElementInfo { public: @@ -153,10 +170,11 @@ ~GenericRenderer(); std::string getName(); static GenericRenderer* getInstance(IRendererContainer* cnt); - void addLine(const std::string &group, GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b); - void addPoint(const std::string &group, GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b); - void addQuad(const std::string &group, GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b); - void addVertex(const std::string &group, GenericRendererNode n, int size, uint8_t r, uint8_t g, uint8_t b); + void addLine(const std::string &group, GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); + void addPoint(const std::string &group, GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); + void addTriangle(const std::string &group, GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); + void addQuad(const std::string &group, GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); + void addVertex(const std::string &group, GenericRendererNode n, int size, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); void addText(const std::string &group, GenericRendererNode n, AbstractFont* font, const std::string &text); void addImage(const std::string &group, GenericRendererNode n, int image); void addAnimation(const std::string &group, GenericRendererNode n, int animation);