how can i draw shapefile, figures, images
i use QT but i don't know opengl of QT. i want to draw moving circle or image on qopenghView which draw shapefile.
fot my object, i downloaded source code of this(https://github.com/blueluna/shapes).
and i downloaded shapefile of this(http://www.naturalearthdata.com/down...10m-coastline/).
and i added this code(//added my code) at void OpenGLWidget::paintGL().
but it can't move or can't draw circle or rectangle.
what should i do?
void OpenGLWidget::paintGL()
{
//added my code
foreach (CAirCraft *bubble, bubbles)
{
bubble->drawBubble();
}
}
//=================
//added my code
CAirCraft::CAirCraft(const QPointF &position, qreal radius, const QPointF &velocity)
: position(position), vel(velocity), radius(radius)
{
innerColor = Qt::transparent;
outerColor = Qt::transparent;
brush = Qt::blue;
QString FilePath = "/home/master/down/img/pokeball.png";
data.load(FilePath);
gldata = QGLWidget::convertToGLFormat(data);
glGenTextures(1, &texture[0]);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, gldata.width(), gldata.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, gldata.bits());
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glBindTexture( GL_TEXTURE_2D, 0 );
}
void CAirCraft::drawBubble()
{
glLoadIdentity();
glPushMatrix();
glTranslated(100, 100,-1);
glDrawPixels(data.width(), data.height(), GL_RGBA,
GL_UNSIGNED_BYTE, gldata.bits());
glPopMatrix();
glFlush();
}
Re: how can i draw shapefile, figures, images
Since you do no error checking in your code to see if any of the functions or methods you call have succeeded, how do you know you even have circles or rectangles to draw? Did data.load() succeed? Did QGLWidget:: convertToGLFormat() succeed? Do any of the gl...() calls succeed? You don't call glGetError(), so how do you know?
Re: how can i draw shapefile, figures, images
i tried draw image and draw ractangle, and the result is that.
for draw air plan on back ground shapefile.
1) image
the way is i written code.
image is drawn but it can't be controlled. it does not move.
2) ractangle
yesterday, i added this code at void OpenGLWidget::paintGL()
but it can't be drawn.
GLfloat vertices[] = {
10000.0, 2000.0, 0.0, //v1
8000, 2000, 0.0, //v2
8000, 8000, 0.0, //v3
2000, 8000, 0.0, //v4
};
shaderProgram->enableAttributeArray(4);
glVertexPointer(3, GL_FLOAT, 0, vertices);
glEnableClientState(GL_VERTEX_ARRAY);
{
glColor4f(1.0, 1.0, 1.0, 1.0);
glDrawArrays(GL_LINE_LOOP, 0, 4);
}
glDisableClientState(GL_VERTEX_ARRAY);
shaderProgram->disableAttributeArray(4);