ADC Home > Reference Library > Technical Q&As > Legacy Documents > Graphics & Imaging >
Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.
Current information on this Reference Library topic can be found here:
|
Q: How does one share textures between mulitple OpenGL contexts? A: Textures can be easily shared between OpenGL contexts on Mac OS X and Mac OS 9.
First, create all contexts as shared contexts (see below). The requirement to create all contexts first maybe lifted in future versions of Mac OS X. Once all contexts are created, create the texture(s) and texture to any one context. All other contexts will share the texture that is current or one that you can bind via glBindTexture. The specifics: - Create shared contexts: The first part of the code in listing 1 shows the creation of shared contexts. Where the global/static variable aglShareContext is the context to share. aglShareContext is initially set globally to NULL and then set to the first context created for all other contexts. This will, in effect, share all contexts. - Load and share textures: The second half of the code in listing 1 shows how to load a texture for the first context and then just bind this for use with the other contexts. This technique is illustrated completely in the "Carbon SetupGL" sample on the sample code web site at <http://developer.apple.com/samplecode/>. [May 01 2001] |
|