summaryrefslogtreecommitdiffstats
path: root/src/datavisualization
diff options
context:
space:
mode:
authorTomi Korpipää <tomi.korpipaa@digia.com>2013-10-21 11:26:41 +0300
committerTomi Korpipää <tomi.korpipaa@digia.com>2013-10-21 11:32:29 +0300
commitee54e1ad611b30b40b42f7205f3c2c1e0cfa0620 (patch)
tree9f366593706e37b96daadc3d3151e4fbb9692030 /src/datavisualization
parent5dfdb409f50bd12b128d5252a8a951ad437a8961 (diff)
Fixed ES2 gradient problem
Task-number: QTRD-2453 + changed gradient texture to a power-of-two size to avoid gradient errors on Android Change-Id: I67b1c87d3143073ceb2523017e3968d16d0cd503 Change-Id: I67b1c87d3143073ceb2523017e3968d16d0cd503 Reviewed-by: Mika Salmela <mika.salmela@digia.com>
Diffstat (limited to 'src/datavisualization')
-rw-r--r--src/datavisualization/engine/shaders/surface_ES2.frag2
-rw-r--r--src/datavisualization/engine/surface3dcontroller.cpp2
-rw-r--r--src/datavisualization/engine/surface3drenderer.cpp4
-rw-r--r--src/datavisualization/engine/theme.cpp2
-rw-r--r--src/datavisualization/utils/utils.cpp2
5 files changed, 6 insertions, 6 deletions
diff --git a/src/datavisualization/engine/shaders/surface_ES2.frag b/src/datavisualization/engine/shaders/surface_ES2.frag
index a9aec528..7f40ba4d 100644
--- a/src/datavisualization/engine/shaders/surface_ES2.frag
+++ b/src/datavisualization/engine/shaders/surface_ES2.frag
@@ -11,7 +11,7 @@ uniform highp float lightStrength;
uniform highp float ambientStrength;
void main() {
- highp vec2 gradientUV = vec2(0.5, (coords_mdl.y + 1.0) / 2.0);
+ highp vec2 gradientUV = vec2(0.0, (coords_mdl.y + 1.001) / 2.0); // ~1000 pixel texture, we need a margin for 1/1000 rounding error
highp vec3 materialDiffuseColor = texture2D(textureSampler, gradientUV).xyz;
highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0);
diff --git a/src/datavisualization/engine/surface3dcontroller.cpp b/src/datavisualization/engine/surface3dcontroller.cpp
index c8823eb7..688747bb 100644
--- a/src/datavisualization/engine/surface3dcontroller.cpp
+++ b/src/datavisualization/engine/surface3dcontroller.cpp
@@ -142,7 +142,7 @@ bool Surface3DController::surfaceGrid()
void Surface3DController::setGradient(const QLinearGradient &gradient)
{
m_userDefinedGradient = gradient;
- m_userDefinedGradient.setStart(1, 1000);
+ m_userDefinedGradient.setStart(2, 1024);
m_userDefinedGradient.setFinalStop(0, 0);
m_changeTracker.gradientColorChanged = true;
emitNeedRender();
diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp
index 31da7af4..67ad66d4 100644
--- a/src/datavisualization/engine/surface3drenderer.cpp
+++ b/src/datavisualization/engine/surface3drenderer.cpp
@@ -1644,11 +1644,11 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
void Surface3DRenderer::updateSurfaceGradient(const QLinearGradient &gradient)
{
- QImage image(QSize(1, 1000), QImage::Format_RGB32);
+ QImage image(QSize(2, 1024), QImage::Format_RGB32);
QPainter pmp(&image);
pmp.setBrush(QBrush(gradient));
pmp.setPen(Qt::NoPen);
- pmp.drawRect(0, 0, 1, 1000);
+ pmp.drawRect(0, 0, 2, 1024);
if (m_gradientTexture) {
m_textureHelper->deleteTexture(&m_gradientTexture);
diff --git a/src/datavisualization/engine/theme.cpp b/src/datavisualization/engine/theme.cpp
index d9f2974a..387540b1 100644
--- a/src/datavisualization/engine/theme.cpp
+++ b/src/datavisualization/engine/theme.cpp
@@ -37,7 +37,7 @@ Theme::Theme()
m_highlightBarColor(QColor(Qt::red)),
m_highlightRowColor(QColor(Qt::darkRed)),
m_highlightColumnColor(QColor(Qt::darkMagenta)),
- m_surfaceGradient(QLinearGradient(1, 1000, 0, 0)),
+ m_surfaceGradient(QLinearGradient(2, 1024, 0, 0)),
m_lightStrength(4.0f),
m_ambientStrength(0.3f),
m_highlightLightStrength(8.0f),
diff --git a/src/datavisualization/utils/utils.cpp b/src/datavisualization/utils/utils.cpp
index 947dbfba..eb74d1a3 100644
--- a/src/datavisualization/utils/utils.cpp
+++ b/src/datavisualization/utils/utils.cpp
@@ -29,7 +29,7 @@
QT_DATAVISUALIZATION_BEGIN_NAMESPACE
#define NUM_IN_POWER(y, x) for (;y<x;y<<=1)
-#define MIN_POWER 32
+#define MIN_POWER 2
GLuint Utils::getNearestPowerOfTwo(GLuint value, GLuint &padding)
{