Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GL_APPLE_pixel_buffer (pt2)



Preliminary PBuffer Documentation (Pt2):

Usage Outline:

The following is a simple outline of creating and using a pbuffer that
has its own pixel format and context.

--- Setup PBuffer's Context ---
Create pixel format (CGLChoosePixelFormat)
Create context (CGLCreateContext)

--- Setup PBuffer Drawable ---
Create PBuffer (CGLCreatePBuffer)
Set pbuffer as drawing target for the context (CGLSetPBuffer)

--- Draw into pbuffer ---
Set current context as the PBuffer's context (CGLSetCurrentContext)
Draw with OpenGL (glBegin/glEnd, etc.)

--- Set up texturing ---
Create texture object (glGenTextures)
Bind the texture object (glBindTexture)
Set texture parameters (glTexEnvParameter)
Create PBuffer texture (CGLTexImagePBuffer)

--- Drawing with PBuffer texture ---
Bind PBuffer texture object (CGLSetPBuffer)
Enable appropriate texture target (glEnable)
Draw primitives with appropriate texture coordinates (glBegin/glEnd,
etc.)

-- Destruction ---
Delete texture object (glDeleteTextures)
Set current context (CGLSetCurrentContext)
Destroy pbuffer (CGLDestroyPBuffer)
Destroy context (CGLDestroyContext)
Destroy pixel format (CGLDestroyPixelFormat)
Set current context to NULL (CGLSetCurrentContext)


Special Cases:

Single Shared Context:
Using single context with with an on-screen drawable and a PBuffer
drawable requires careful set up and understanding of the issues and
limitations involved. Since both drawables will have the same context
attached to them the pixel format used to create the context has to
compatible with both drawables. In real terms this means that a client
cannot, at this time, use a single pixel format and context with a full
screen drawable and a PBuffer since the PBuffer is considered a
windowed drawable in all cases.

Second, an understanding of Mac OS X surface handling is key in
understanding the steps required to successfully use a single context.
Mac OS X creates a hardware accelerated drawing surface when the client
actually attaches an OpenGL context to a drawable. This is true for
windows, views and PBuffers. When detaching an OpenGL context from a
drawable what happens depends upon the type of drawable. For PBuffers
the hardware surface remains intact until destruction of the PBuffer,
though one can only draw to it when it has a context attached. For
Carbon windows the hardware surface is torn down immediately if there
are no other OpenGL contexts attached to it. AGL provides methods to
attach a second "dummy" context to a window and thus ensure the
hardware surface remains intact until both all contexts are detached.
The following code snippet illustrates this setup.

OpenGL Profiler Interaction:
Since the OpenGL profiler is hooked into the OpenGL (gl...) texturing
APIs it does not currently show PBuffers as textures. This does not
mean the texturing operation has failed. Additionally, failure in the
PBuffer API does not set an OpenGL error (glError) but an error in the
specific parent API (CGL, AGL, AppKit) so also cannot be caught with
the OpenGL profiler's break on error.

AGL Drawable Setting:
When change the drawable from a PBuffer to some other drawable in AGL
one must first set the drawable to NULL (aglSetDrawable) then set the
drawable to the desired drawable. This is required for Mac OS X
v10.3.0 through v10.3.4, only applies when changing drawables FROM the
PBuffer to a non-PBuffer drawable and only for the AGL API. This issue
is fixed in Mac OS X v10.3.4 and later.
---
Geoff Stahl
3D Software Engineer
Apple
_______________________________________________
mac-opengl mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/mac-opengl
Do not post admin requests to the list. They will be ignored.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.