Results 1 to 11 of 11

Thread: Render 2d Density graph with OpenGL

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #9
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,318
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Render 2d Density graph with OpenGL

    Quote Originally Posted by kkaz View Post
    Store the processed data in a 2d double array "ToRenderStructObject"
    • Could you please also show the definition of ToRenderStructObject and did you check how much time it takes to fill it ?
    • What type of color map do you use ?
    • Did you enable DEBUG_RENDER and what values do you see ?
    • And are you using more than one core ?



    The resolution of the data is relatively high, 1080x500 in one occasion, and 2000x2000 in another occasion, and they are painted in rather small resolution widgets-graphs since they can't both fit in the screen.
    I have not re implemented pixelHint(). Is that something that would help me?
    The image is rendered in the minimum of the resolutions of data/screen. But without implementing the pixelHint() the resolution of the data is not known and it will always end up in screen resolution.
    Implementing a pixelHint helps, when the data resolution is below the resolution of the plot canvas ( = size in pixels ) - so in your case probably not.

    My implementation of the value() function:
    This method is called for every pixel - for a resolution of 1000x1000 this will be a million times and removing any pointless operation from it will have a significant effect.


    • Better do these "will never happen" checks in debug mode only.
    • Everything that can be calculated in advance should be done in YourRasterData::initRaster. F.e something like "(data_.size() - 1) * interval_y.maxValue() - interval_y.minValue()" is constant and does not need to be calculated again and again.
    • Don't use std::round() - casting to int should be good enough.


    But the implementation is not totally bad and accessing data_ might be the bottleneck.

    Why don't you simply use QwtPlotMatrixData - or at least copy the code and strip it down to the minimum you need ? It is faster than your code and the main reasons for not using it ( calculate the values on the fly or returning values from the original buffer without having an extra copy ) seem to be irrelevant in your situation.

    Concerning using the GPU: as long as you don't have an OpenGL canvas you would need to:


    1. prepare data
    2. upload data
    3. create something with the GPU
    4. download the result
    5. translate it into an image
    6. draw the image


    Uwe

  2. The following user says thank you to Uwe for this useful post:

    kkaz (8th December 2017)

Similar Threads

  1. Does Qt5 have APIs to render text by OpenGL?
    By aniasen in forum Qt Programming
    Replies: 3
    Last Post: 10th June 2014, 08:20
  2. Do offscreen render(openGL) with Qt5
    By stereoMatching in forum Qt Programming
    Replies: 4
    Last Post: 26th June 2013, 11:34
  3. Render image on QLabel using openGl
    By vinodpaul in forum Newbie
    Replies: 2
    Last Post: 14th August 2012, 17:57
  4. OpenGL render to texture
    By Nicuvëo in forum Qt Programming
    Replies: 2
    Last Post: 26th March 2011, 12:07
  5. Replies: 1
    Last Post: 7th May 2010, 17:20

Tags for this Thread

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.