c++ - Where to use the makeCurrent() in QGLWidget? -


the qt's documentation said:

your widget's opengl rendering context made current when paintgl(), resizegl(), or initializegl() called. if need call standard opengl api functions other places (e.g. in widget's constructor or in own paint functions), must call makecurrent() first.

for following case:

paintgl() {     drawsomething(); } ... drawsomething() {     glclearcolor()...     //many other gl calls... } 

do have makecurrent inside drawsomething() function.

and if make qpainter call in stead of standard opengl api functions. have use makecurrent?

do have makecurrent inside drawsomething() function.

if function called paintgl, no, qt call paintgl context current.

as docs say, you'll need whenever need gl context current in other function.

// called other code, context may not current void myglwidget::setbackgroundcolor(const qcolor &color) {      makecurrent();      glclearcolor(color.redf(), color.greenf(), color.bluef(), color.alphaf()); } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -