Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly is a Graphic Context?

What exactly is encapsulated by a Graphic Context (or Device Context in Windows)?

The various definitions across the net agree that a context encapsulates the parameters for the various graphics operations. See: X11, Mac OS, Windows

What is not clear is whether a context also encapsulates the memory buffer upon which the graphics operations are performed.

In the X11 entry there is a mention about separate Drawable objects, Window and Pixmap, which represent the drawing surfaces. Going a bit further, into the OpenGL GLX documentation, there is a clear separation between Rendering Contexts and Drawing Surfaces. Interestingly it is also said that "applications can render into the same surface, using different contexts" and that "it is also possible to use a single context to render into multiple surfaces".

like image 739
Dimitrios Menounos Avatar asked Jul 25 '11 15:07

Dimitrios Menounos


1 Answers

An X11 GC does not contain the memory buffer, both the Drawable and the GC are passed in to all the drawing operations, and the GC can be use with all "like" Drawables (drawables on the same screen with same bit depth).

However drawing in X11 these days is normally done client-side using a library such as Cairo, so the "real" answer depends on that library. In Cairo's case the Cairo context does include a current target surface, though you can change the target surface.

OpenGL also has a "current target" kind of concept, though again you can change the current target.

If you want to generalize I'd say that conceptually a context is separate from the buffer, though to save typing people may have a current buffer you can set on the context.

like image 134
Havoc P Avatar answered Oct 05 '22 07:10

Havoc P