QGLWidget - how to structure a program with overpainting
===

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