Hi
Thanks for the response - I am magnifying - the texture 2k x 2k - please find attached
I have tried the GL_LINEAR_MIPMAP_LINEAR - didn’t make any difference
I’m not sure if I’m drawing the quad strips correctly - see the code at the bottom of post
Show below is the fixed function implemenation
glNewList(displayList, GL_COMPILE);
glEnable(GL_TEXTURE_2D);
GLuint texture = m_radarView->texture()->textureId();
glBindTexture(GL_TEXTURE_2D, texture);
for(uint azimuth = 0 ; azimuth < azimuthSamples; ++azimuth)
{
auto azimuth2 = azimuth+1;
if (azimuth2 >= azimuthSamples)
azimuth2 = 0;
glBegin(GL_QUAD_STRIP);
GLfloat atex = (azimuth * atexd) + (atexd / 2.0), atex2 = azimuth2 != 0 ? (azimuth2 * atexd) + (atexd / 2.0) : 1.0;
const QList<QPointF> &line1 = watcher->resultAt(azimuth), &line2 = watcher->resultAt(azimuth2);
for(int range = 0; range < rangeSamples; range++)
{
glTexCoord2f((rtexd * range) + (rtexd / 2.0), atex);
glVertex3f(line1.at(range).x(), line1.at(range).y(), 0.0);
glTexCoord2f((rtexd * range) + (rtexd / 2.0), atex2);
glVertex3f(line2.at(range).x(), line2.at(range).y(), 0.0);
}
glEnd();
}
glBindTexture(GL_TEXTURE_2D, 0);
glEndList();
The in render I do the
glCallList(displayList);
This works fine
Using shaders (Qt OpenGL wrappers)
The VBO stores the vertices and texture coordinates - initialisation below
m_vao = new QOpenGLVertexArrayObject(this);,
m_vbo = new QOpenGLBuffer(QOpenGLBuffer::VertexBuffer);
m_vao->create();
m_vbo->setUsagePattern(QOpenGLBuffer::DynamicDraw);
m_vbo->create();
auto numVertices = textureSize().width() * textureSize().height() * 2;
auto verticesSize = numVertices * sizeof(QVector2D);
auto textureSize = numVertices * sizeof(QVector2D);
auto textureOffset = verticesSize;
m_vao->bind();
m_vbo->bind();
//the VAO must be bound here - this is part of the VAO state
m_vbo->allocate(verticesSize + textureSize);
shaderProgram()->bind();
const int vertexLocation = 1;
shaderProgram()->enableAttributeArray(vertexLocation);
shaderProgram()->setAttributeBuffer(vertexLocation, GL_FLOAT, 0, 2);
const int texLocation = 2;
shaderProgram()->enableAttributeArray(texLocation);
shaderProgram()->setAttributeBuffer(texLocation, GL_FLOAT, textureOffset, 2);
m_vao->release();
m_vbo->release();
shaderProgram()->release();type or paste code here
- create vertices and texture coordinates and write to VBO
//map each cartesian point to a texture coordinate - one quad strip for each azimuth spoke
for(uint azimuth = 0 ; azimuth < azimuthSamples; ++azimuth)
{
auto azimuth2 = azimuth+1;
if (azimuth2 >= azimuthSamples)
azimuth2 = 0;
const QList<QPointF> &line1 = watcher->resultAt(azimuth), &line2 = watcher->resultAt(azimuth2);
auto atex = (azimuth * atexd) + (atexd / 2.0), atex2 = azimuth2 != 0 ? (azimuth2 * atexd) + (atexd / 2.0) : 1.0;
for (uint range = 0; range < rangeSamples; ++range)
{
vertices.append(QVector2D(line1.at(range).x(), line1.at(range).y()));
textCords.append(QVector2D((rtexd * range) + (rtexd / 2.0), atex));
vertices.append(QVector2D(line2.at(range).x(), line2.at(range).y()));
textCords.append(QVector2D((rtexd * range) + (rtexd / 2.0), atex2));
Q_ASSERT(textCords.last().x()<=1.0 && textCords.last().y()<=1.0);
}
}
m_vbo->bind();
auto verticesSize = vertices.size() * sizeof(QVector2D);
auto textureSize = textCords.size() * sizeof(QVector2D);
m_vbo->write(0, vertices.constData(), verticesSize);
m_vbo->write(verticesSize, textCords.constData(), textureSize);
m_vbo->release();
Then in render
shaderProgram()->bind();
shaderProgram()->setUniformValue(shaderProgram()->uniformLocation("modelViewMatrix"), projection);
//explicitly set the texture unit
shaderProgram()->setUniformValue("bscan", 0);
texture()->bind();
m_vao->bind();
**pragma message ("TODO - use GL_TRIANGLE_STRIP" - is this correct ????)**
glDrawArrays(GL_QUAD_STRIP, 0, textureSize().width() * textureSize().height() * 2);
m_vao->release();
shaderProgram()->release();
texture()->release();
The fixed function implementation using display lists creates a quad strip for each spoke/azimuth, the shader implementation calls
glDrawArrays(GL_QUAD_STRIP, 0, textureSize().width() * textureSize().height() * 2);
I don’t think this is correct
Thanks for your help