views:

54

answers:

1

I have built an OpenGL Viewer control that can simply be dropped onto a windows form (at design time) and assigned an OpenGL display list (at run time).

The viewer control handles navigation, display options (e.g. background color), etc. It is also responsible for creating and destroying rendering and device contexts as necessary.

Obviously, each viewer control instance has its own device context, the 'window' where the image is drawn.

Questions:

  • How should each viewer control instance manage rendering contexts?
  • Should each instance have it's own context or share a global rendering context?

I'm particularly concerned with how this affects WGL font creation (wglUseFontBitmaps and wglUseFontOutlines), which requires a rendering context (whatever the current context is) and a device context.

  • Do I need to create each WGL font for each rendering/device context combination?

Perhaps my approach is flawed.

+1  A: 

I would go with the context per control approach. You do have to remember that extensions are context based so you'll have to bind them for each one you make (I use glew_MX to handle this).

Also, you can share display lists across contexts (as long as they are on the same gpu) and the wgl font creation creates display lists so you should be fine.

Jose