[Development] About QML depends on opengl
Samuel Rødal
samuel.rodal at nokia.com
Tue Sep 4 09:59:48 CEST 2012
On 09/04/2012 09:38 AM, ext song.7.liu at nokia.com wrote:
> Hi,
>
> We are trying to port the mesa. But there is one question related with OpenGL.
>
> In Linux, we can create OpengGL context using glXCreateContextAttribsARB, then glXMakeCurrent will binding this context to a window.
> But we don't understand how does the GL operation such as glClearColor etc. know what's the current context for drawing ?
>
> For example:
> ctx = glXCreateContextAttribsARB( display, bestFbc, 0, True, context_attribs );
> glXMakeCurrent( display, win, ctx );
>
> glClearColor ( 1, 0.5, 0, 1 );
> glClear ( GL_COLOR_BUFFER_BIT );
>
> Thanks,
> Song
The OpenGL driver typically keeps the current context as a static
variable in thread local storage.
glXMakeCurrent() sets this variable, and each of the OpenGL calls will
query it. Read the documentation for glXMakeCurrent:
http://www.opengl.org/sdk/docs/man/xhtml/glXMakeCurrent.xml
The current context can be queried by glXGetCurrentContext().
Qt wraps these APIs with QOpenGLContext::makeCurrent() and
QOpenGLContext::currentContext().
--
Samuel
More information about the Development
mailing list