Results 1 to 3 of 3

Thread: how can i draw shapefile, figures, images

  1. #1
    Join Date
    Apr 2017
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default 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:aintGL().
    but it can't move or can't draw circle or rectangle.
    what should i do?


    void OpenGLWidget:aintGL()
    {
    //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();
    }

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default 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?
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Apr 2017
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default 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:aintGL()
    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);

Similar Threads

  1. Draw text on images
    By arunkumaraymuo1 in forum Qt Programming
    Replies: 2
    Last Post: 23rd August 2012, 05:38
  2. How to draw a line with tiled images with QPainter?
    By MadBear in forum Qt Programming
    Replies: 5
    Last Post: 25th July 2011, 06:36
  3. To draw images in QLabel
    By augusbas in forum Qt Programming
    Replies: 5
    Last Post: 11th October 2010, 06:27
  4. Qt Draw fast png images
    By anafor2004 in forum Newbie
    Replies: 4
    Last Post: 4th November 2008, 09:28
  5. Opening a shapefile
    By peace_comp in forum Qt Programming
    Replies: 1
    Last Post: 1st May 2008, 20:59

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.