Draw to Offscreen Bitmap in Cocoa???
Draw to Offscreen Bitmap in Cocoa???
- Subject: Draw to Offscreen Bitmap in Cocoa???
- From: Carlos Weber <email@hidden>
- Date: Sat, 9 Jun 2001 07:28:39 -1000
As a relative newcomer to Cocoa from the world of classic Mac
programming, I have hit a mental roadblock trying to figure out the
"Cocoa way" to accomplish this task:
I am trying to draw a simple image (some rectangles and text) which I
will ultimately use to create an OpenGL texture. In the old world this
would involve the following steps:
1. Create an offscreen GWorld
2. Draw your stuff into it.
3. Get the bits you just drew, by getting the PixMap of the offscreen
GWorld and getting its base address (and some other ugly stuff).
4. Swizzle the bits so that they are in the RGBA format OpenGL wants.
5. Stick them in a buffer and tell OpenGL to make a texture therefrom.
I can't seem to get a handle on how to do the Cocoa equivalent of steps
1 thru 3... I need to draw (but I don't want to REALLY draw on the
screen), then obtain the "bits" I just drew in some definable format
that I can massage and send to OpenGL.
From what I do know of Cocoa I feel certain there is a straightforward,
even elegant way of doing this... Any suggestions?