Mercurial > fife-parpg
annotate engine/core/view/renderers/floatingtextrenderer.cpp @ 661:e3140f01749d
* Merged the light branch back into trunk.
* Modified the demos so they work with the new loaders and setting.
author | helios2000@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 05 Nov 2010 15:21:10 +0000 |
parents | f3457443c95f |
children |
rev | line source |
---|---|
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 /*************************************************************************** |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
2 * Copyright (C) 2005-2008 by the FIFE team * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
3 * http://www.fifengine.de * |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
4 * This file is part of FIFE. * |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
5 * * |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
6 * FIFE is free software; you can redistribute it and/or * |
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
7 * modify it under the terms of the GNU Lesser General Public * |
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
8 * License as published by the Free Software Foundation; either * |
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
9 * version 2.1 of the License, or (at your option) any later version. * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
10 * * |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
11 * This library is distributed in the hope that it will be useful, * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * |
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
14 * Lesser General Public License for more details. * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
15 * * |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
16 * You should have received a copy of the GNU Lesser General Public * |
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
17 * License along with this library; if not, write to the * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
18 * Free Software Foundation, Inc., * |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
20 ***************************************************************************/ |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
22 // Standard C++ library includes |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
23 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 // 3rd party library includes |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 // FIFE includes |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
27 // These includes are split up in two parts, separated by one empty line |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
28 // First block: files included from the FIFE root src directory |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
29 // Second block: files included from the same folder |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
30 #include "video/renderbackend.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
31 #include "util/math/fife_math.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
32 #include "util/log/logger.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
33 #include "video/fonts/abstractfont.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
34 #include "video/image.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
35 #include "model/structures/instance.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
36 #include "model/structures/layer.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
37 #include "model/structures/location.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
38 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
39 #include "view/visual.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
40 #include "view/camera.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
41 #include "floatingtextrenderer.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
42 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
43 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
44 namespace FIFE { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
45 static Logger _log(LM_VIEWVIEW); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
46 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
47 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
48 FloatingTextRenderer::FloatingTextRenderer(RenderBackend* renderbackend, int position, AbstractFont* font): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
49 RendererBase(renderbackend, position), |
582
5e04f6349894
* Improved the floatingtextrenderer. You can now set a background speech quad.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
50 m_renderbackend(renderbackend), |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
51 m_font(font) { |
579
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
522
diff
changeset
|
52 setEnabled(false); |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
522
diff
changeset
|
53 m_font_color = false; |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
522
diff
changeset
|
54 m_color = m_font->getColor(); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
55 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
56 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
57 FloatingTextRenderer::FloatingTextRenderer(const FloatingTextRenderer& old): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
58 RendererBase(old), |
582
5e04f6349894
* Improved the floatingtextrenderer. You can now set a background speech quad.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
59 m_renderbackend(old.m_renderbackend), |
579
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
522
diff
changeset
|
60 m_font(old.m_font), |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
522
diff
changeset
|
61 m_font_color(old.m_font_color), |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
522
diff
changeset
|
62 m_color(old.m_color) { |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
522
diff
changeset
|
63 setEnabled(false); |
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.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
582
diff
changeset
|
64 m_font_color = m_background = m_backborder = false; |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
65 } |
522
7b451e3b2439
FloatingTextRenderer no longer modifies the default font color when rendering.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
482
diff
changeset
|
66 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
67 RendererBase* FloatingTextRenderer::clone() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
68 return new FloatingTextRenderer(*this); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
69 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
70 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
71 FloatingTextRenderer::~FloatingTextRenderer() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
72 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
73 |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
74 void FloatingTextRenderer::render(Camera* cam, Layer* layer, RenderList& instances) { |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
75 if (!m_font) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
76 return; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
77 } |
522
7b451e3b2439
FloatingTextRenderer no longer modifies the default font color when rendering.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
482
diff
changeset
|
78 |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
79 RenderList::const_iterator instance_it = instances.begin(); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
80 const std::string* saytext = NULL; |
661
e3140f01749d
* Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
631
diff
changeset
|
81 unsigned int lm = m_renderbackend->getLightingModel(); |
579
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
522
diff
changeset
|
82 SDL_Color old_color = m_font->getColor(); |
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.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
582
diff
changeset
|
83 if(m_font_color) { |
47b49b9b0c0a
* Improved the floatingtextrenderer. Now you can set an alpha value for font, background quad and border. Splited quad and border into own commands.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
582
diff
changeset
|
84 m_font->setColor(m_color.r, m_color.g, m_color.b, m_color.unused); |
579
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
522
diff
changeset
|
85 } |
661
e3140f01749d
* Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
631
diff
changeset
|
86 if(lm != 0) { |
e3140f01749d
* Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
631
diff
changeset
|
87 m_renderbackend->disableLighting(); |
e3140f01749d
* Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
631
diff
changeset
|
88 m_renderbackend->setStencilTest(255, 2, 7); |
e3140f01749d
* Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
631
diff
changeset
|
89 m_renderbackend->setAlphaTest(0.0); |
e3140f01749d
* Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
631
diff
changeset
|
90 } |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
91 for (;instance_it != instances.end(); ++instance_it) { |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
92 Instance* instance = (*instance_it)->instance; |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
93 saytext = instance->getSayText(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
94 if (saytext) { |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
95 const Rect& ir = (*instance_it)->dimensions; |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
96 Image* img = m_font->getAsImageMultiline(*saytext); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
97 Rect r; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
98 r.x = (ir.x + ir.w/2) - img->getWidth()/2; /// the center of the text rect is always aligned to the instance's rect center. |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
99 r.y = ir.y- img->getHeight(); /// make the text rect floating higher than the instance. |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
100 r.w = img->getWidth(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
101 r.h = img->getHeight(); |
631
f3457443c95f
* Added drawRectangle() and fillRectangle() functions to the renderers
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
589
diff
changeset
|
102 |
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.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
582
diff
changeset
|
103 if(m_background || m_backborder) { |
582
5e04f6349894
* Improved the floatingtextrenderer. You can now set a background speech quad.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
104 const int overdraw = 5; |
631
f3457443c95f
* Added drawRectangle() and fillRectangle() functions to the renderers
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
589
diff
changeset
|
105 |
f3457443c95f
* Added drawRectangle() and fillRectangle() functions to the renderers
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
589
diff
changeset
|
106 Point p = Point(r.x-overdraw, r.y-overdraw); |
582
5e04f6349894
* Improved the floatingtextrenderer. You can now set a background speech quad.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
107 |
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.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
582
diff
changeset
|
108 if(m_background) { |
631
f3457443c95f
* Added drawRectangle() and fillRectangle() functions to the renderers
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
589
diff
changeset
|
109 m_renderbackend->fillRectangle(p, r.w+2*overdraw, r.h+2*overdraw, m_backcolor.r, m_backcolor.g, m_backcolor.b, m_backcolor.unused); |
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.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
582
diff
changeset
|
110 } |
582
5e04f6349894
* Improved the floatingtextrenderer. You can now set a background speech quad.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
111 |
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.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
582
diff
changeset
|
112 if(m_backborder) { |
631
f3457443c95f
* Added drawRectangle() and fillRectangle() functions to the renderers
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
589
diff
changeset
|
113 m_renderbackend->drawRectangle(p, r.w+2*overdraw, r.h+2*overdraw, m_backbordercolor.r, m_backbordercolor.g, m_backbordercolor.b, m_backbordercolor.unused); |
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.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
582
diff
changeset
|
114 } |
582
5e04f6349894
* Improved the floatingtextrenderer. You can now set a background speech quad.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
115 } |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
116 img->render(r); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
117 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
118 } |
661
e3140f01749d
* Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
631
diff
changeset
|
119 if(lm != 0) { |
e3140f01749d
* Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
631
diff
changeset
|
120 m_renderbackend->disableAlphaTest(); |
e3140f01749d
* Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
631
diff
changeset
|
121 m_renderbackend->disableStencilTest(); |
e3140f01749d
* Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
631
diff
changeset
|
122 m_renderbackend->enableLighting(); |
e3140f01749d
* Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
631
diff
changeset
|
123 } |
579
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
522
diff
changeset
|
124 if(m_font_color) { |
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.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
582
diff
changeset
|
125 m_font->setColor(old_color.r, old_color.g, old_color.b, old_color.unused); |
579
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
522
diff
changeset
|
126 } |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
522
diff
changeset
|
127 } |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
522
diff
changeset
|
128 |
631
f3457443c95f
* Added drawRectangle() and fillRectangle() functions to the renderers
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
589
diff
changeset
|
129 void FloatingTextRenderer::setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { |
579
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
522
diff
changeset
|
130 m_color.r = r; |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
522
diff
changeset
|
131 m_color.g = g; |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
522
diff
changeset
|
132 m_color.b = b; |
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.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
582
diff
changeset
|
133 m_color.unused = a; |
47b49b9b0c0a
* Improved the floatingtextrenderer. Now you can set an alpha value for font, background quad and border. Splited quad and border into own commands.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
582
diff
changeset
|
134 |
47b49b9b0c0a
* Improved the floatingtextrenderer. Now you can set an alpha value for font, background quad and border. Splited quad and border into own commands.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
582
diff
changeset
|
135 m_font_color = true; |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
136 } |
522
7b451e3b2439
FloatingTextRenderer no longer modifies the default font color when rendering.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
482
diff
changeset
|
137 |
631
f3457443c95f
* Added drawRectangle() and fillRectangle() functions to the renderers
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
589
diff
changeset
|
138 void FloatingTextRenderer::setBackground(uint8_t br, uint8_t bg, uint8_t bb, uint8_t ba) { |
582
5e04f6349894
* Improved the floatingtextrenderer. You can now set a background speech quad.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
139 m_backcolor.r = br; |
5e04f6349894
* Improved the floatingtextrenderer. You can now set a background speech quad.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
140 m_backcolor.g = bg; |
5e04f6349894
* Improved the floatingtextrenderer. You can now set a background speech quad.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
141 m_backcolor.b = bb; |
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.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
582
diff
changeset
|
142 m_backcolor.unused = ba; |
582
5e04f6349894
* Improved the floatingtextrenderer. You can now set a background speech quad.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
143 |
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.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
582
diff
changeset
|
144 m_background = true; |
47b49b9b0c0a
* Improved the floatingtextrenderer. Now you can set an alpha value for font, background quad and border. Splited quad and border into own commands.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
582
diff
changeset
|
145 } |
47b49b9b0c0a
* Improved the floatingtextrenderer. Now you can set an alpha value for font, background quad and border. Splited quad and border into own commands.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
582
diff
changeset
|
146 |
631
f3457443c95f
* Added drawRectangle() and fillRectangle() functions to the renderers
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
589
diff
changeset
|
147 void FloatingTextRenderer::setBorder(uint8_t bbr, uint8_t bbg, uint8_t bbb, uint8_t bba) { |
582
5e04f6349894
* Improved the floatingtextrenderer. You can now set a background speech quad.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
148 m_backbordercolor.r = bbr; |
5e04f6349894
* Improved the floatingtextrenderer. You can now set a background speech quad.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
149 m_backbordercolor.g = bbg; |
5e04f6349894
* Improved the floatingtextrenderer. You can now set a background speech quad.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
150 m_backbordercolor.b = bbb; |
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.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
582
diff
changeset
|
151 m_backbordercolor.unused = bba; |
582
5e04f6349894
* Improved the floatingtextrenderer. You can now set a background speech quad.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
152 |
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.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
582
diff
changeset
|
153 m_backborder = true; |
582
5e04f6349894
* Improved the floatingtextrenderer. You can now set a background speech quad.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
154 } |
5e04f6349894
* Improved the floatingtextrenderer. You can now set a background speech quad.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
155 |
589
d1df6cf5ff23
* Fixed a bug in RenderBackendSDL, the clip area was not properly set.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
583
diff
changeset
|
156 void FloatingTextRenderer::resetBackground() { |
582
5e04f6349894
* Improved the floatingtextrenderer. You can now set a background speech quad.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
157 m_background = false; |
5e04f6349894
* Improved the floatingtextrenderer. You can now set a background speech quad.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
158 } |
5e04f6349894
* Improved the floatingtextrenderer. You can now set a background speech quad.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
159 |
589
d1df6cf5ff23
* Fixed a bug in RenderBackendSDL, the clip area was not properly set.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
583
diff
changeset
|
160 void FloatingTextRenderer::resetBorder() { |
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.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
582
diff
changeset
|
161 m_backborder = false; |
47b49b9b0c0a
* Improved the floatingtextrenderer. Now you can set an alpha value for font, background quad and border. Splited quad and border into own commands.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
582
diff
changeset
|
162 } |
47b49b9b0c0a
* Improved the floatingtextrenderer. Now you can set an alpha value for font, background quad and border. Splited quad and border into own commands.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
582
diff
changeset
|
163 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
164 FloatingTextRenderer* FloatingTextRenderer::getInstance(IRendererContainer* cnt) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
165 return dynamic_cast<FloatingTextRenderer*>(cnt->getRenderer("FloatingTextRenderer")); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
166 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
167 } |