Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. OpenGL frame rate issue
Forum Updated to NodeBB v4.3 + New Features

OpenGL frame rate issue

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PeterG
    wrote on last edited by
    #1

    Hi everyone,

    I am working on TI AM5728 EVM board, linux from TI SDK.

    I have an simple Qt openGL widget that just scroll a 1920*640 image on the screen, and the image is preloaded.

    When I set the widget window to 800640 which is the default of the EVM screen, the time between each frame is 16-17ms, or 60 Hz, which is good. And when I connect to a external HDMI display(the monitor is set at 19201080) and the widget stay at 800*640, the time is still 16-17ms, it is normal and reasonable so far.

    but when I increase the resolution to 1000640 and add little by little (1100640 1200640,etc) the strange thing starts.
    @1000
    640: 16-17ms.
    @1100640: 16-17ms.
    @1200
    640: 90% of the time 16-17ms, 10% of the time 33-34 ms, which is 30Hz
    @1300*640: 80% of the time 33-34ms, 20% of the time 16-17 ms.
    @1300+ *640: all 33-34 ms.

    It seems like somewhere around at resolution 1200640, there is a limit, once I cross the limit, it half the FPS.
    My goal is to run it at 1920
    640@60fps.
    Please help.

    There is the part of my code. modified from an example.

    
    MainWidget::MainWidget(QWidget *parent) :
        QOpenGLWidget(parent),
        geometries(0),
        texture(0),
        angularSpeed(0)
    {
    }
    
    MainWidget::~MainWidget()
    {
        // Make sure the context is current when deleting the texture
        // and the buffers.
        makeCurrent();
        delete texture;
        delete geometries;
        doneCurrent();
    }
    
    
    void MainWidget::timerEvent(QTimerEvent *)
    {
            movement=(movement>2)?0:movement+0.006;
          int t=timer0.elapsed()-temp;
          if((t<16)||(t>17))
           qDebug() << t << "milliseconds";
            temp=timer0.elapsed();
        update();
    }
    
    void MainWidget::initializeGL()
    {
    
        QSurfaceFormat format;
        format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
        format.setSwapInterval(1);
    
        setFormat(format);
        initializeOpenGLFunctions();
       glClearColor(1.0f,1.0f,1.0f,1.0f);
        setGeometry(0, 0, 1300, 640);
    
        initShaders();
        initTextures();
    
        glEnable(GL_DEPTH_TEST);
        glEnable(GL_CULL_FACE);
        geometries = new GeometryEngine;
       timer.start(0, this);
    
    }
    
    
    void MainWidget::initTextures()
    {
    
        // Load image
        Image = QImage(800, 640, QImage::Format_RGB888);
        Image = QImage(":/Test.bmp");
        texture = new QOpenGLTexture(Image.mirrored());
       // texture->setFormat(QOpenGLTexture::RGB8U);
    
        // Set nearest filtering mode for texture minification
        //texture->setMinificationFilter(QOpenGLTexture::Nearest);
    
        // Set bilinear filtering mode for texture magnification
        //texture->setMagnificationFilter(QOpenGLTexture::Linear);
    
        // Wrap texture coordinates by repeating
        // f.ex. texture coordinate (1.1, 1.2) is same as (0.1, 0.2)
        //texture->setWrapMode(QOpenGLTexture::Repeat);
    }
    
    void MainWidget::resizeGL(int w, int h)
    {
        // Calculate aspect ratio
        //qreal aspect = qreal(w) / qreal(h ? h : 1);
    
        // Set near plane to 3.0, far plane to 7.0, field of view 45 degrees
        const qreal zNear = 1.0, zFar = 5.5, fov = 28;
    
        // Reset projection
        //projection.setToIdentity();
    
        // Set perspective projection
        projection.perspective(fov, 1, zNear, zFar);
    }
    
    void MainWidget::paintGL()
    {
        texture->bind();
        // Calculate model view transformation
        QMatrix4x4 matrix;
        matrix.translate(movement, 0.0, -5.0);
        //matrix.rotate(rotation);
    
        // Set modelview-projection matrix
        program.setUniformValue("mvp_matrix", projection * matrix);
        // Use texture unit 0 which contains cube.png
        program.setUniformValue("texture", 0);
        // Draw cube geometry
        geometries->drawCubeGeometry(&program);
    
    }
    //your code here
    
    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi! Why do you think this issue is related to Qt? Maybe the GL hardware (or driver) just isn't capable enough.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved