当前位置: 动力学知识库 > 问答 > 编程问答 >

C & X11 : how to use graphic contexts

问题描述:

I am confused about "graphic context"s, using the xcb library.

There are some examples around the www, they all show creating one single window with one single graphic context.

Of course when setting up several windows, each will have its own graphicx context, or perhaps several.

Could or should I create several graphic contexts for one and the same window? For example one for drawing flowers, another for rivers, a third for text labels? Or is it better to use only one and adapt it to the job at hand?

What is considered good programming style, in this respect?

网友答案:

You can create as many contexts as you want. The rule of thumb is:

  • If you draw everything in the same style use one context.
  • If you change the style, but not very often, use one context.
  • If you change styles frequently, follow your senses and either use one content (and change its attributes as needed) or create several contents. The latter approach is faster, but if you have too many GCs, you may run out of them (there is a limit on how many GCs a window may have).
分享给朋友:
您可能感兴趣的文章:
随机阅读: