diff options
author | Tomi Korpipää <tomi.korpipaa@digia.com> | 2013-05-27 09:54:17 +0300 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@digia.com> | 2013-05-27 10:11:04 +0300 |
commit | ec9db0da09fe5468b8029e2caa01800717cac24b (patch) | |
tree | f78742652f30b0e77ae65718723de1cc24222d17 /src/datavis3d | |
parent | 3b9027e93265e303ce06992c4d0b41fe40baf713 (diff) |
Android fix
Check that we have heightnormalizer before trying to draw grid lines to
walls.
Improved selection color logic. Old one didn't work well on android.
Change-Id: I0fe45cf60eba3d55721d7e42f9e3f356a507f2ca
Change-Id: I0fe45cf60eba3d55721d7e42f9e3f356a507f2ca
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Diffstat (limited to 'src/datavis3d')
-rw-r--r-- | src/datavis3d/engine/q3dbars.cpp | 41 | ||||
-rw-r--r-- | src/datavis3d/utils/texturehelper.cpp | 10 | ||||
-rw-r--r-- | src/datavis3d/utils/utils.cpp | 27 |
3 files changed, 46 insertions, 32 deletions
diff --git a/src/datavis3d/engine/q3dbars.cpp b/src/datavis3d/engine/q3dbars.cpp index 8b0af058..fd65393d 100644 --- a/src/datavis3d/engine/q3dbars.cpp +++ b/src/datavis3d/engine/q3dbars.cpp @@ -82,6 +82,7 @@ QTCOMMERCIALDATAVIS3D_BEGIN_NAMESPACE #define DISPLAY_FULL_DATA_ON_SELECTION // Append selection value text with row and column labels const GLfloat gridLineWidth = 0.005f; +static QVector3D skipColor = QVector3D(255, 255, 255); // Selection texture's background color Q3DBars::Q3DBars() : d_ptr(new Q3DBarsPrivate(this)) @@ -447,7 +448,7 @@ void Q3DBars::drawScene() GLfloat barPos = 0; GLfloat rowPos = 0; - static QVector3D selection = QVector3D(0, 0, 0); + static QVector3D selection = skipColor; // Specify viewport glViewport(d_ptr->m_sceneViewPort.x(), d_ptr->m_sceneViewPort.y(), @@ -641,7 +642,7 @@ void Q3DBars::drawScene() #ifndef USE_HAX0R_SELECTION glBindFramebuffer(GL_FRAMEBUFFER, d_ptr->m_selectionFrameBuffer); glEnable(GL_DEPTH_TEST); // Needed, otherwise the depth render buffer is not used - glClearColor(1.0f, 1.0f, 1.0f, 1.0f); // Set clear color to white + glClearColor(skipColor.x() / 255, skipColor.y() / 255, skipColor.z() / 255, 1.0f); // Set clear color to white (= skipColor) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Needed for clearing the frame buffer #endif glDisable(GL_DITHER); // disable dithering, it may affect colors if enabled @@ -676,12 +677,15 @@ void Q3DBars::drawScene() // TODO: Save position to qdataitem, so that we don't need to calculate it each time? - // add +2 to avoid black - QVector3D barColor = QVector3D((GLdouble)(row + 2) - / (GLdouble)(d_ptr->m_sampleCount.second + 2), - (GLdouble)(bar + 2) - / (GLdouble)(d_ptr->m_sampleCount.first + 2), +//#if !defined(QT_OPENGL_ES_2) +// QVector3D barColor = QVector3D((GLdouble)row / 32767.0, +// (GLdouble)bar / 32767.0, +// 0.0); +//#else + QVector3D barColor = QVector3D((GLdouble)row / 255.0, + (GLdouble)bar / 255.0, 0.0); +//#endif d_ptr->m_selectionShader->setUniformValue(d_ptr->m_selectionShader->MVP(), MVPMatrix); @@ -830,10 +834,6 @@ void Q3DBars::drawScene() case Q3DBarsPrivate::SelectionBar: { barColor = Utils::vectorFromColor(d_ptr->m_theme->m_highlightBarColor); lightStrength = d_ptr->m_theme->m_highlightLightStrength; - //if (d_ptr->m_mousePressed) { - // qDebug() << "selected object:" << barIndex << "( row:" << row + 1 << ", column:" << bar + 1 << ")"; - // qDebug() << "object position:" << modelMatrix.column(3).toVector3D(); - //} // Insert data to QDataItem. We have no ownership, don't delete the previous one if (!d_ptr->m_zoomActivated) { d_ptr->m_selectedBar = item; @@ -1015,7 +1015,7 @@ void Q3DBars::drawScene() d_ptr->m_backgroundShader->release(); // Draw grid lines - if (d_ptr->m_gridEnabled) { + if (d_ptr->m_gridEnabled && d_ptr->m_heightNormalizer) { // Bind bar shader d_ptr->m_barShader->bind(); @@ -2180,17 +2180,20 @@ Q3DBarsPrivate::SelectionType Q3DBarsPrivate::isSelected(GLint row, GLint bar, #ifdef USE_HAX0R_SELECTION if (selection == Utils::vectorFromColor(m_theme->m_windowColor)) #else - if (selection == Utils::vectorFromColor(Qt::white)) + if (selection == skipColor) #endif return isSelectedType; // skip window - QVector3D current = QVector3D((GLubyte)(((GLdouble)(row + 2) / (GLdouble)(m_sampleCount.second + 2)) - * 255.0 + 0.49), // +0.49 to fix rounding (there are conversions from unsigned short to GLdouble and back) - (GLubyte)(((GLdouble)(bar + 2) / (GLdouble)(m_sampleCount.first + 2)) - * 255.0 + 0.49), // +0.49 to fix rounding (there are conversions from unsigned short to GLdouble and back) - 0); + +//#if !defined(QT_OPENGL_ES_2) +// QVector3D current = QVector3D((GLuint)row, (GLuint)bar, 0); +//#else + QVector3D current = QVector3D((GLubyte)row, (GLubyte)bar, 0); +//#endif + // TODO: For debugging //if (selection != prevSel) { - // qDebug() << selection.x() << selection .y() << selection.z(); + // qDebug() << "current" << current.x() << current .y() << current.z(); + // qDebug() << "selection" << selection.x() << selection .y() << selection.z(); // prevSel = selection; //} if (current == selection) diff --git a/src/datavis3d/utils/texturehelper.cpp b/src/datavis3d/utils/texturehelper.cpp index c21a09ab..917a3842 100644 --- a/src/datavis3d/utils/texturehelper.cpp +++ b/src/datavis3d/utils/texturehelper.cpp @@ -121,8 +121,13 @@ GLuint TextureHelper::createSelectionBuffer(const QSize &size, GLuint &texture, glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); +//#if !defined(QT_OPENGL_ES_2) +// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, size.width(), size.height(), 0, GL_RGB, +// GL_UNSIGNED_INT, NULL); +//#else glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, size.width(), size.height(), 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); +//#endif // Create texture object for the depth buffer glGenTextures(1, &depthTexture); @@ -159,8 +164,13 @@ GLuint TextureHelper::createSelectionTexture(const QSize &size, GLuint &frameBuf glBindTexture(GL_TEXTURE_2D, textureid); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); +//#if !defined(QT_OPENGL_ES_2) +// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, size.width(), size.height(), 0, GL_RGB, +// GL_UNSIGNED_INT, NULL); +//#else glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, size.width(), size.height(), 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); +//#endif glBindTexture(GL_TEXTURE_2D, 0); // Create render buffer diff --git a/src/datavis3d/utils/utils.cpp b/src/datavis3d/utils/utils.cpp index 7b4cb6f6..5ef4f4d5 100644 --- a/src/datavis3d/utils/utils.cpp +++ b/src/datavis3d/utils/utils.cpp @@ -198,25 +198,26 @@ QVector3D Utils::getSelection(QPoint mousepos, int height) { QVector3D selectedColor; +//#if defined(QT_OPENGL_ES_2) // This is the only one that works with ANGLE (ES 2.0) // Item count will be limited to 256*256*256 GLubyte pixel[4]; glReadPixels(mousepos.x(), height - mousepos.y(), 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void *)pixel); - - // These work with desktop OpenGL - // They offer a lot higher possible object count and a possibility to use object id's - //GLuint pixel2[3]; - //glReadPixels(mousepos.x(), height - mousepos.y(), 1, 1, - // GL_RGB, GL_UNSIGNED_INT, (void *)pixel2); - - //GLfloat pixel3[3]; - //glReadPixels(mousepos.x(), height - mousepos.y(), 1, 1, - // GL_RGB, GL_FLOAT, (void *)pixel3); - //qDebug() << "rgba" << pixel[0] << pixel[1] << pixel[2];// << pixel[3]; - //qDebug() << "rgba2" << pixel2[0] << pixel2[1] << pixel2[2]; - //qDebug() << "rgba3" << pixel3[0] << pixel3[1] << pixel3[2]; +//#else +// // These work with desktop OpenGL +// // They offer a lot higher possible object count and a possibility to use object ids +// GLuint pixel[3]; +// glReadPixels(mousepos.x(), height - mousepos.y(), 1, 1, +// GL_RGB, GL_UNSIGNED_INT, (void *)pixel); +// qDebug() << "rgba" << pixel[0] << pixel[1] << pixel[2];// << pixel[3]; + +// GLfloat pixel3[3]; +// glReadPixels(mousepos.x(), height - mousepos.y(), 1, 1, +// GL_RGB, GL_FLOAT, (void *)pixel3); +// qDebug() << "rgba" << pixel3[0] << pixel3[1] << pixel3[2];// << pixel[3]; +//#endif selectedColor = QVector3D(pixel[0], pixel[1], pixel[2]); //qDebug() << selectedColor; |