From febefd5cc70741dc1e65b9747866daa673fedc59 Mon Sep 17 00:00:00 2001 From: Sofian Audry Date: Wed, 14 Feb 2018 05:40:49 +0000 Subject: [PATCH] Fixed all compile errors on Raspbian (runs and can add colors but images not working yet). --- ShapeGraphicsItem.cpp | 46 +++++++++++++++++++++++++++---------------- ShapeGraphicsItem.h | 2 +- Util.cpp | 2 +- Util.h | 2 +- mapmap.pro | 1 + 5 files changed, 33 insertions(+), 20 deletions(-) diff --git a/ShapeGraphicsItem.cpp b/ShapeGraphicsItem.cpp index b10c29c..ed3acba 100644 --- a/ShapeGraphicsItem.cpp +++ b/ShapeGraphicsItem.cpp @@ -232,10 +232,10 @@ void TextureGraphicsItem::_doDrawInput(QPainter* painter) if (isMappingCurrent()) { // FIXME: Does this draw the quad counterclockwise? + QRectF rect = mapFromScene(_texture.toStrongRef()->getRect()).boundingRect(); #if !defined(HAVE_GLES) glBegin (GL_QUADS); { - QRectF rect = mapFromScene(_texture.toStrongRef()->getRect()).boundingRect(); glTexCoord2f (0, 0); glVertex3f (rect.x(), rect.y(), 0); @@ -264,15 +264,22 @@ void TextureGraphicsItem::_doDrawInput(QPainter* painter) 0, 1 }; - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); +// glEnableClientState(GL_VERTEX_ARRAY); +// glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, quad); - glTexCoordPointer(2, GL_FLOAT, 0, tex); + GLuint ATTRIB_VERTEX = 0; + GLuint ATTRIB_TEXTURE = 1; + + glVertexAttribPointer(ATTRIB_VERTEX, 3, GL_FLOAT, GL_FALSE, 0, quad); + glVertexAttribPointer(ATTRIB_TEXTURE, 2, GL_FLOAT, GL_FALSE, 0, tex); + glEnableVertexAttribArray(ATTRIB_VERTEX); + glEnableVertexAttribArray(ATTRIB_TEXTURE); + + // OR GL_TRIANGLE_STRIP??? glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); + // glDisableClientState(GL_VERTEX_ARRAY); + // glDisableClientState(GL_TEXTURE_COORD_ARRAY); #endif } } @@ -315,15 +322,18 @@ void TextureGraphicsItem::_prePaint(QPainter* painter, } texture->unlockMutex(); +#if !defined(HAVE_GLES) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); +#endif glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); +#if !defined(HAVE_GLES) // Set texture color (apply opacity). glColor4f(1.0f, 1.0f, 1.0f, isOutput() ? getMapping()->getComputedOpacity() : getMapping()->getPaint()->getOpacity()); - +#endif } void TextureGraphicsItem::_postPaint(QPainter* painter, @@ -337,7 +347,7 @@ void TextureGraphicsItem::_postPaint(QPainter* painter, } #if defined(HAVE_GLES) -void _drawTexture(const QVector& input, QVector& output, bool mapFromScene=true); +void TextureGraphicsItem::_drawTexture(const QVector& input, const QVector& output, bool mapFromScene_) { int nVertices = input.size(); GLfloat tex[nVertices*2]; @@ -345,18 +355,20 @@ void _drawTexture(const QVector& input, QVector& output, bool for (int i=0, j=0, k=0; i& input, QVector& output, bool mapFromScene=true); +void _drawTexture(const QVector& input, const QVector& output, bool mapFromScene=true); #endif QWeakPointer _textureMapping; diff --git a/Util.cpp b/Util.cpp index 6b8eaeb..bfc58ae 100644 --- a/Util.cpp +++ b/Util.cpp @@ -57,7 +57,7 @@ void getGlTexPoint(GLfloat* texPoint, GLfloat* dstPoint, { // Set point in texture. texPoint[0] = (inputPoint.x() - texture.getX()) / (GLfloat) texture.getWidth(); - texPoint[1] = (inputPoint.y() - texture.getY()) / (GLfloat) texture.getHeight()); + texPoint[1] = (inputPoint.y() - texture.getY()) / (GLfloat) texture.getHeight(); // Add point in output. dstPoint[0] = outputPoint.x(); dstPoint[1] = outputPoint.y(); diff --git a/Util.h b/Util.h index 473009c..3ac7863 100644 --- a/Util.h +++ b/Util.h @@ -55,7 +55,7 @@ void setGlTexPoint(const Texture& texture, const QPointF& inputPoint, const QPoi #else -void getGlTexPoint(GLfloat* texPoint, GLfloat dstPoint, +void getGlTexPoint(GLfloat* texPoint, GLfloat* dstPoint, const Texture& texture, const QPointF& inputPoint, const QPointF& outputPoint); #endif diff --git a/mapmap.pro b/mapmap.pro index 6d8eeab..1936a65 100644 --- a/mapmap.pro +++ b/mapmap.pro @@ -134,6 +134,7 @@ unix:!mac { contains(QMAKE_HOST.arch, arm.*): { QMAKE_CXXFLAGS_RELEASE -= -O2 QMAKE_CXXFLAGS_RELEASE -= -O1 + DEFINES += HAVE_GLES } DEFINES += UNIX