×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    2

    The proper Q-type to store PPM image for terrain rendering in OpenGL?

    Hello,

    I am trying to load a height map image file (in PPM format ) into a QPixmap (would this be the correct type to store and access grayscale values for terrain rendering in OpenGL, rather than a QByteArray?) but, do not exactly understand what goes into the QPixmap.load(??) parameters and if QPixmap.index(x,y) will yield the color/integer values properly. These are the relevant parts of my code to what I am trying to achieve:

    ==========================================
    //-----Heightfield.h-----//
    class Heightfield {
    public:
    void Create(char *hFilename);
    void Render(void);

    QPixmap hHeightField;

    private:
    int hmHeight;
    int hmWidth;
    };


    //-----Heightfield.cpp-----//
    void Heightfield::Create(char *hFilename) {
    hHeightField.load(hFilename, ???); <----- const char*format =0?
    hmHeight = hHeightField.height();
    hmWidth = hHeightField.width();
    }

    void Heightfield::Render() {
    // x & z because we're mapping terrain on that plane
    glBegin(GL_POINTS);
    for (int hmX = 0; hmX < hmWidth; hmX++) {
    for (int hmZ = 0; hmZ < hmHeight; hmZ++)
    glVertex3f(hmX, hHeightField.index(hmX,hmZ), hmZ); // plot heights for the corresponding pt in x/z-plane
    }
    glEnd();
    }


    //-----glwidget.cpp-----//
    **beforehand created Heightfield hField;
    In InitializeGL():
    hField.Create("map.ppm");

    In paintGL():
    // call terrain rendering function
    glPushMatrix();
    hField.Render();
    glPopMatrix();

    ==========================================
    This is what I got from Qt's refrence library:

    bool load ( const QString & fileName, const char * format = 0, ColorMode mode = Auto )
    bool load ( const QString & fileName, const char * format, int conversion_flags )

    Any help will be greatly appreciated; thank you for regarding my question!

    - Alessandra

  2. #2
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: The proper Q-type to store PPM image for terrain rendering in OpenGL?

    Hi Alessandra,

    You should use QImage instead of QPixmap or ByteArray.
    Here the doc to the constructor that I think you should use:
    http://doc.trolltech.com/4.6/qimage.html#QImage-2

  3. #3
    Registered User
    Join Date
    Oct 2010
    Posts
    2

    Re: The proper Q-type to store PPM image for terrain rendering in OpenGL?

    Hi gnuton,

    I found out a bit before but still thank you so much for responding and helping out :-D ; QImage was indeed the best choice for processing height maps.

Similar Threads

  1. image rendering problem with webkit
    By Flo1240 in forum Qt
    Replies: 8
    Last Post: 2010-01-21, 19:23
  2. Rendering scene continuosly using opengl
    By sneha27 in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2009-08-13, 08:50
  3. After rendering into Image2D image gets artefacts on it.
    By westman2000 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 9
    Last Post: 2007-02-01, 14:24
  4. SVG image rendering problem..
    By pankaj_hotwani in forum Mobile Java General
    Replies: 5
    Last Post: 2006-08-31, 13:08
  5. Size of rendering area using OpenGL ES
    By allankrebs in forum Symbian Media (Closed)
    Replies: 0
    Last Post: 2005-12-29, 17:15

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×