> : > I've looked at OpenGL and understand the promise. However I
> : > imagine that even OpenGL on Mac OSX must use calls to Core
[quoted text clipped - 5 lines]
> Thanks, both of you -- a very interesting model for an API.
> I'll certainly need to try OpenGL.

Signature
Michael Ash
Rogue Amoeba Software
This is very helpful. I have tried to absorb the
"advice for programmers" on developer.apple.com about
how to use the new OSX APIs. As you've made clear,
although OpenGL is highly optimized, it is sometimes
not always intuitive which operations will run the
fastest.
My application is strictly pixels, for a scientific
display program, where what is important is not what
the screen looks approximately like, but what it exactly,
precisely is. The code and its performance needs to be
verifiable by anyone, even a beginner.
This is the basis for my preference for simple calls that
are easy to understand yet run very fast.
I am hoping now that someone can point out which calls
would accomplish what you have advised: to write pixels
into a buffer, then get them to the video card as
quickly as possible.
I don't think I need Cocoa but don't know whether my
category is Carbon or Miscellaneous. I do know that
with just a few simple calls (see below), I've been able
to get quite good performance, evidently now only limited
(besides the graphics interpretation) by the bandwidth
for copying from RAM to VRAM.
Will try the OpenGL code posted earlier to my query
by Phil. However, am still very much confused as to
what API is really going to be best here. I don't know
whether my application is best rewritten to use GLUT or
something else. As you may understand from my words
above, it is absolutel necessary to make the code simple
and easy to understand as well as high performance.
Therefore I'm still hoping that there is a way to
use these calls (from my existing code):
CGGetOnlineDisplayList(MAXDSPYS,activeDisplays,&dspyCnt);
display = activeDisplays[1];
CGDisplayCapture(display);
display_address = CGDisplayBaseAddress(display);
along with another to set up a fast RAM to VRAM call.
Otherwise it appears I'll be testing different GL calls
for months trying to figure out how they work.
Rob Smith
Research Associate Professor
University of Pennsylvania
: > : > I've looked at OpenGL and understand the promise. However I
: > : > imagine that even OpenGL on Mac OSX must use calls to Core
[quoted text clipped - 5 lines]
: > Thanks, both of you -- a very interesting model for an API.
: > I'll certainly need to try OpenGL.
: Isn't it? I think it's a wonderful choice. The lowest-level graphics API
: is an industry standard, a great one at that, and something that's
: chock-full of hardware acceleration.
: > : > One might think that DMA could
: > : > help to speed things up. This is true with double buffering
[quoted text clipped - 23 lines]
: > is the fraction of the frame interval currently taken by the
: > buffer copy. Not an enormous increase, but measurable.
: Well, for example, with OpenGL DMA but no page flipping, you could write
: to one buffer, then make OpenGL pull it onto the video card via DMA while
: you're busy writing to the second buffer, giving you a similar effect in
: this case.
: > Of course there are other methods to increase speed, like using a
: > triple-buffering scheme, then having the back to front buffer
[quoted text clipped - 11 lines]
: > buffers and drawing methods. Sounds like that's pretty much what
: > OpenGL promises -- so I'll check it out.
: The good news is that OpenGL abstracts a lot of this stuff for you. The
: bad news is that it makes few guarantees about exactly what will be
: accelerated or how things will be copied.
: The first important thing to know is what kind of app you're writing
: (Carbon, Cocoa, Miscellaneous), and whether you can change it. If you can
: change it, I might recommend creating a GLUT app. GLUT is an extremely
: bare-bones GUI toolkit which is specifically designed for use with OpenGL,
: and so it takes care of a lot of things for you.
: With GLUT, you'd set up a window an OpenGL stuff (which I won't cover, but
: there's tons of sample code out there), then you'd call glutFullScreen()
[quoted text clipped - 6 lines]
: page flip, just some kind of operation to show the current contents of the
: back buffer.
: If GLUT is not an option, your choices are AGL and NSOpenGL. If you're
: used to Cocoa, NSOpenGL is probably the way to go.
: With NSOpenGL, you'd set up a full screen context, and then use the
: -flushBuffer message when you finish drawing, which is like
: glutSwapBuffers() except for Cocoa.
: You probably have similar things for AGL, but I'm not familiar with it.
: To actually draw your pixel data, you have a couple of choices. One is to
: put your pixel data into a texture, then draw a rectangle textured with
: that texture. Use the GL_TEXTURE_RECTANGLE_EXT texture type; this is an
: OpenGL extension supported by any decent card which allows you to have
: textures with sizes that are not powers of two.
: Another choice would be to draw the pixel data directly using
: glDrawPixels().
: Note, don't assume that glDrawPixels() is faster just because it sounds
: like vastly simpler operation (which it is). OpenGL often has unintuitive
[quoted text clipped - 6 lines]
: uses. Of course, don't assume that it's slower either; testing is the only
: way to be sure.
: Hopefully this was more helpful than confusing. :)
Michael Ash - 11 Nov 2005 10:58 GMT
> This is very helpful. I have tried to absorb the
> "advice for programmers" on developer.apple.com about
[quoted text clipped - 31 lines]
> above, it is absolutel necessary to make the code simple
> and easy to understand as well as high performance.
GLUT is probably the best. It's normally used as a Hollywood-style
application framework (i.e. Don't call us, we'll call you), but you may be
able to bypass that if all you care about is drawing.
> Therefore I'm still hoping that there is a way to
> use these calls (from my existing code):
[quoted text clipped - 5 lines]
>
> along with another to set up a fast RAM to VRAM call.
This is doubtful. You'll need to switch entirely to OpenGL, as the calls
above aren't very useful in this case.
> Otherwise it appears I'll be testing different GL calls
> for months trying to figure out how they work.
Or you could, I dunno, do some reading and research. If you know how to
program and how to read docs (and sample code), it should not take you
months, particularly as I've already outlined the basic plan of attack
for you.
Find some GLUT sample code (this is trivial). Borrow its main() function.
Add a call to glutFullScreen() to go fullscreen. Kill the call to
glutMainLoop() if you don't want Hollywood-style operation, and instead do
your own main loop. Write your graphics to an internal buffer, then use
one of the techniques already discussed to write it into your OpenGL
context, then glutSwapBuffers() and repeat.

Signature
Michael Ash
Rogue Amoeba Software