Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8263289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:02:50+00:00 2026-06-08T04:02:50+00:00

This should be simple: I’m using a QGLWidget to draw some openGL graphics and

  • 0

This should be simple: I’m using a QGLWidget to draw some openGL graphics and I want to be able to write something on the openGL graphics rendered, so I’m using overpainting as in the Qt demo with QPainter.

Here are my two working choices of structuring my program:

// This works but it's probably stupid
paintEvent()
{

    makeCurrent();

    glewInit();

    loadShaders();

    loadTextures();

    loadBuffers();

    ... actually paint something with openGL ...

    QPainter painter(this);

    ... overpainting ...
}

------------------------------------------------------------------------------------

// This works and may probably be better
paintEvent()
{

    QGLWidget::paintEvent(event); // Base class call, this calls initializeGL ONCE and then paintGL each time it's needed

    QPainter painter(this);

    ... overpainting ...
}

initializeGL()
{
    glewInit();
}

paintGL()
{
    loadShaders();

    loadTextures();

    loadBuffers();

    ... actually paint something with openGL ...
}

Considering that textures and shaders aren’t going to be always the same, is any of these options acceptable (in performances and reasonably)?

If not: how would you structure the program?

Thank you for any help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T04:02:55+00:00Added an answer on June 8, 2026 at 4:02 am
    1. load/compile/link shaders in the initializeGL() method, because that is relatively slow operation (specially if it is read from the disk)
    2. load textures in the initializeGL() method

    Not sure what are buffers, but sounds like it should be done in the initialization, since it is done only once.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This should be simple task but i am not been able to find the
I think this should be simple but I am having some difficulty implementing it.
This should be simple, but I'm stupid so... I want to do a simple
This should be simple, but I am having problems. Using the eBay .Net library,
This should be simple, Is there a way to apply .patch files using perl?
I feel this should be simple but I can't find an answer. I want
This should be simple, but i can't get it to work. I want to
This should be simple, but I guess I'm missing something. I have a simple
This should be simple. I want to get an absolute Uri given the controller,
This should be simple but is boggling me for some reason. I'm sure it's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.