| 1 |
/*************************************************************************** |
| 2 |
* Copyright (C) 2005-2019 by the FIFE team * |
| 3 |
* http://www.fifengine.net * |
| 4 |
* This file is part of FIFE. * |
| 5 |
* * |
| 6 |
* FIFE is free software; you can redistribute it and/or * |
| 7 |
* modify it under the terms of the GNU Lesser General Public * |
| 8 |
* License as published by the Free Software Foundation; either * |
| 9 |
* version 2.1 of the License, or (at your option) any later version. * |
| 10 |
* * |
| 11 |
* This library is distributed in the hope that it will be useful, * |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * |
| 14 |
* Lesser General Public License for more details. * |
| 15 |
* * |
| 16 |
* You should have received a copy of the GNU Lesser General Public * |
| 17 |
* License along with this library; if not, write to the * |
| 18 |
* Free Software Foundation, Inc., * |
| 19 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * |
| 20 |
***************************************************************************/ |
| 21 |
|
| 22 |
#ifndef FIFE_OFFRENDERER_H |
| 23 |
#define FIFE_OFFRENDERER_H |
| 24 |
|
| 25 |
// Standard C++ library includes |
| 26 |
|
| 27 |
// 3rd party library includes |
| 28 |
|
| 29 |
// FIFE includes |
| 30 |
// These includes are split up in two parts, separated by one empty line |
| 31 |
// First block: files included from the FIFE root src directory |
| 32 |
// Second block: files included from the same folder |
| 33 |
#include "video/animation.h" |
| 34 |
|
| 35 |
namespace FIFE { |
| 36 |
class RenderBackend; |
| 37 |
class IFont; |
| 38 |
|
| 39 |
class OffRendererElementInfo { |
| 40 |
public: |
| 41 |
virtual void render(RenderBackend* renderbackend) {}; |
| 42 |
virtual ~OffRendererElementInfo() {}; |
| 43 |
}; |
| 44 |
|
| 45 |
class OffRendererLineInfo : public OffRendererElementInfo { |
| 46 |
public: |
| 47 |
void render(RenderBackend* renderbackend); |
| 48 |
OffRendererLineInfo(Point n1, Point n2, uint8_t r, uint8_t g, uint8_t b, uint8_t a); |
| 49 |
virtual ~OffRendererLineInfo() {}; |
| 50 |
private: |
| 51 |
Point m_edge1; |
| 52 |
Point m_edge2; |
| 53 |
uint8_t m_red; |
| 54 |
uint8_t m_green; |
| 55 |
uint8_t m_blue; |
| 56 |
uint8_t m_alpha; |
| 57 |
}; |
| 58 |
class OffRendererPointInfo : public OffRendererElementInfo { |
| 59 |
public: |
| 60 |
void render(RenderBackend* renderbackend); |
| 61 |
OffRendererPointInfo(Point n, uint8_t r, uint8_t g, uint8_t b, uint8_t a); |
| 62 |
virtual ~OffRendererPointInfo() {}; |
| 63 |
private: |
| 64 |
Point m_anchor; |
| 65 |
uint8_t m_red; |
| 66 |
uint8_t m_green; |
| 67 |
uint8_t m_blue; |
| 68 |
uint8_t m_alpha; |
| 69 |
}; |
| 70 |
class OffRendererTriangleInfo : public OffRendererElementInfo { |
| 71 |
public: |
| 72 |
void render(RenderBackend* renderbackend); |
| 73 |
OffRendererTriangleInfo(Point n1, Point n2, Point n3, uint8_t r, uint8_t g, uint8_t b, uint8_t a); |
| 74 |
virtual ~OffRendererTriangleInfo() {}; |
| 75 |
private: |
| 76 |
Point m_edge1; |
| 77 |
Point m_edge2; |
| 78 |
Point m_edge3; |
| 79 |
uint8_t m_red; |
| 80 |
uint8_t m_green; |
| 81 |
uint8_t m_blue; |
| 82 |
uint8_t m_alpha; |
| 83 |
}; |
| 84 |
class OffRendererQuadInfo : public OffRendererElementInfo { |
| 85 |
public: |
| 86 |
void render(RenderBackend* renderbackend); |
| 87 |
OffRendererQuadInfo(Point n1, Point n2, Point n3, Point n4, uint8_t r, uint8_t g, uint8_t b, uint8_t a); |
| 88 |
virtual ~OffRendererQuadInfo() {}; |
| 89 |
private: |
| 90 |
Point m_edge1; |
| 91 |
Point m_edge2; |
| 92 |
Point m_edge3; |
| 93 |
Point m_edge4; |
| 94 |
uint8_t m_red; |
| 95 |
uint8_t m_green; |
| 96 |
uint8_t m_blue; |
| 97 |
uint8_t m_alpha; |
| 98 |
}; |
| 99 |
|
| 100 |
class OffRendererVertexInfo : public OffRendererElementInfo { |
| 101 |
public: |
| 102 |
void render(RenderBackend* renderbackend); |
| 103 |
OffRendererVertexInfo(Point center, int32_t size, uint8_t r, uint8_t g, uint8_t b, uint8_t a); |
| 104 |
virtual ~OffRendererVertexInfo() {}; |
| 105 |
private: |
| 106 |
Point m_center; |
| 107 |
int32_t m_size; |
| 108 |
uint8_t m_red; |
| 109 |
uint8_t m_green; |
| 110 |
uint8_t m_blue; |
| 111 |
uint8_t m_alpha; |
| 112 |
}; |
| 113 |
|
| 114 |
class OffRendererImageInfo : public OffRendererElementInfo { |
| 115 |
public: |
| 116 |
void render(RenderBackend* renderbackend); |
| 117 |
OffRendererImageInfo(Point n, ImagePtr image); |
| 118 |
virtual ~OffRendererImageInfo() {}; |
| 119 |
private: |
| 120 |
Point m_anchor; |
| 121 |
ImagePtr m_image; |
| 122 |
}; |
| 123 |
class OffRendererAnimationInfo : public OffRendererElementInfo { |
| 124 |
public: |
| 125 |
void render(RenderBackend* renderbackend); |
| 126 |
OffRendererAnimationInfo(Point n, AnimationPtr animation); |
| 127 |
virtual ~OffRendererAnimationInfo() {}; |
| 128 |
private: |
| 129 |
Point m_anchor; |
| 130 |
AnimationPtr m_animation; |
| 131 |
uint32_t m_start_time; |
| 132 |
float m_time_scale; |
| 133 |
}; |
| 134 |
class OffRendererTextInfo : public OffRendererElementInfo { |
| 135 |
public: |
| 136 |
void render(RenderBackend* renderbackend); |
| 137 |
OffRendererTextInfo(Point n, IFont* font, std::string text); |
| 138 |
virtual ~OffRendererTextInfo() {}; |
| 139 |
private: |
| 140 |
Point m_anchor; |
| 141 |
IFont* m_font; |
| 142 |
std::string m_text; |
| 143 |
}; |
| 144 |
class OffRendererResizeInfo : public OffRendererElementInfo { |
| 145 |
public: |
| 146 |
void render(RenderBackend* renderbackend); |
| 147 |
OffRendererResizeInfo(Point n, ImagePtr image, int32_t width, int32_t height); |
| 148 |
virtual ~OffRendererResizeInfo() {}; |
| 149 |
private: |
| 150 |
Point m_anchor; |
| 151 |
ImagePtr m_image; |
| 152 |
int32_t m_width; |
| 153 |
int32_t m_height; |
| 154 |
}; |
| 155 |
class OffRenderer { |
| 156 |
public: |
| 157 |
/** constructor. |
| 158 |
* @param renderbackend to use |
| 159 |
*/ |
| 160 |
OffRenderer(RenderBackend* renderbackend); |
| 161 |
|
| 162 |
/** Destructor. |
| 163 |
*/ |
| 164 |
virtual ~OffRenderer(); |
| 165 |
|
| 166 |
void setEnabled(bool enabled); |
| 167 |
bool isEnabled(); |
| 168 |
void setClipArea(Rect area); |
| 169 |
const Rect& getClipArea() const; |
| 170 |
void render(); |
| 171 |
|
| 172 |
void addLine(const std::string &group, Point n1, Point n2, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); |
| 173 |
void addPoint(const std::string &group, Point n, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); |
| 174 |
void addTriangle(const std::string &group, Point n1, Point n2, Point n3, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); |
| 175 |
void addQuad(const std::string &group, Point n1, Point n2, Point n3, Point n4, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); |
| 176 |
void addVertex(const std::string &group, Point n, int32_t size, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); |
| 177 |
void addText(const std::string &group, Point n, IFont* font, const std::string &text); |
| 178 |
void addImage(const std::string &group, Point n, ImagePtr image); |
| 179 |
void addAnimation(const std::string &group, Point n, AnimationPtr animation); |
| 180 |
void resizeImage(const std::string &group, Point n, ImagePtr image, int32_t width, int32_t height); |
| 181 |
void removeAll(const std::string &group); |
| 182 |
void removeAll(); |
| 183 |
|
| 184 |
private: |
| 185 |
std::map<std::string, std::vector<OffRendererElementInfo*> > m_groups; |
| 186 |
RenderBackend* m_renderbackend; |
| 187 |
bool m_enabled; |
| 188 |
Rect m_area; |
| 189 |
}; |
| 190 |
|
| 191 |
} |
| 192 |
|
| 193 |
#endif |