summaryrefslogtreecommitdiff
path: root/src/renderer.cc
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2011-12-11 22:45:14 (GMT)
committerMarius Kintel <marius@kintel.net>2011-12-11 22:45:14 (GMT)
commit9ed8d9a6732e1eea0265ff84917278a82d81e2dd (patch)
tree6322830c95d70b2310b45c7008cfd4dac6d4bf31 /src/renderer.cc
parent647fdf5f98f6337955972375a17837aede922988 (diff)
Some small refactoring of color handling to support using the color() module to change only alpha
Diffstat (limited to 'src/renderer.cc')
-rw-r--r--src/renderer.cc66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/renderer.cc b/src/renderer.cc
new file mode 100644
index 0000000..b791673
--- /dev/null
+++ b/src/renderer.cc
@@ -0,0 +1,66 @@
+#include "renderer.h"
+#include "rendersettings.h"
+#include <QColor>
+
+void Renderer::setColor(const double color[4], GLint *shaderinfo) const
+{
+ QColor col = RenderSettings::inst()->color(RenderSettings::OPENCSG_FACE_FRONT_COLOR);
+ double c[4] = {color[0], color[1], color[2], color[3]};
+ if (c[0] < 0) c[0] = col.redF();
+ if (c[1] < 0) c[1] = col.greenF();
+ if (c[2] < 0) c[2] = col.blueF();
+ if (c[3] < 0) c[3] = col.alphaF();
+ glColor4dv(c);
+ if (shaderinfo) {
+ glUniform4f(shaderinfo[1], c[0], c[1], c[2], c[3]);
+ glUniform4f(shaderinfo[2], (c[0]+1)/2, (c[1]+1)/2, (c[2]+1)/2, 1.0);
+ }
+}
+
+void Renderer::setColor(ColorMode colormode, GLint *shaderinfo) const
+{
+ QColor col;
+ switch (colormode) {
+ case COLORMODE_NONE:
+ return;
+ break;
+ case COLORMODE_MATERIAL:
+ col = RenderSettings::inst()->color(RenderSettings::OPENCSG_FACE_FRONT_COLOR);
+ break;
+ case COLORMODE_CUTOUT:
+ col = RenderSettings::inst()->color(RenderSettings::OPENCSG_FACE_BACK_COLOR);
+ break;
+ case COLORMODE_HIGHLIGHT:
+ col.setRgb(255, 157, 81, 128);
+ break;
+ case COLORMODE_BACKGROUND:
+ col.setRgb(180, 180, 180, 128);
+ break;
+ case COLORMODE_MATERIAL_EDGES:
+ col.setRgb(255, 236, 94);
+ break;
+ case COLORMODE_CUTOUT_EDGES:
+ col.setRgb(171, 216, 86);
+ break;
+ case COLORMODE_HIGHLIGHT_EDGES:
+ col.setRgb(255, 171, 86, 128);
+ break;
+ case COLORMODE_BACKGROUND_EDGES:
+ col.setRgb(150, 150, 150, 128);
+ break;
+ default:
+ break;
+ }
+ float rgba[4];
+ rgba[0] = col.redF();
+ rgba[1] = col.greenF();
+ rgba[2] = col.blueF();
+ rgba[3] = col.alphaF();
+ glColor4fv(rgba);
+#ifdef ENABLE_OPENCSG
+ if (shaderinfo) {
+ glUniform4f(shaderinfo[1], col.redF(), col.greenF(), col.blueF(), 1.0f);
+ glUniform4f(shaderinfo[2], (col.redF()+1)/2, (col.greenF()+1)/2, (col.blueF()+1)/2, 1.0f);
+ }
+#endif
+}
contact: Jan Huwald // Impressum