Re: OSX arbitrary sequences at frame rate with OpenGL ?




I'm trying to display an arbitrary sequence of frames under Mac
OSX 10.4.2 using OpenGL to achieve maximum speed. I've been
trying to test different methods as suggested by posters on this
group.

We've successfully written code to do this using glDrawPixels()
but would like to try using textures.

Have been successful using GLUT and a callback function for
display. This allows 60 frames at maximum speed on my Radeon
9600 Pro 256 MB card. More than 60 frames slows down
tremendously, consistent with 4 MB/frame.

However, to display much longer sequences, we want to to remove
glutmainloop(). We need to synchronize the interpretation of each
frame with the binding and flush of the texture for screen
display. I'm trying therefore to bind each frame and display it
immediately instead of binding all the frames in advance of
display time. This should allow me to display arbitrarily long
sequences like the glDrawPixels() code that was successful.

My code looks something like this (below) but it does not work.
The screen is blank and I imagine that there are some GL calls
that I have left out, possibly AGL to replace the GLUT
initialization calls that I have removed. The "init()" proc is
copied from my successful code that uses glDrawPixel().

I have heard that using textures can be faster than other methods
to write RAM to VRAM, but that I will need to test different
alternatives to find the one that works the best for my
conditions.


Can someone tell me

a) is there something obvious (or not so obvious) missing?

b) assuming I can get it to work, how much faster can this method
be than using "glDrawPixels()" (assuming that the code that
interprets the frames into RGB is fast) ?

c) is there a better (faster) way to write individual frames from
RAM to VRAM ?

Sincerely,

Rob Smith


/*-------------------*/

init()

{
CGGetOnlineDisplayList(MAXDSPYS,activeDisplays,&dspyCnt);
display = activeDisplays[1]; // find second screen
CGDisplayCapture(display); // capture screen

displayMask = CGDisplayIDToOpenGLDisplayMask(display);
CGLPixelFormatAttribute attribs[] = { // Choose the pixel format
kCGLPFAFullScreen,
kCGLPFAAccelerated,
kCGLPFADoubleBuffer,
kCGLPFADisplayMask,
((CGLPixelFormatAttribute)displayMask),
((CGLPixelFormatAttribute)NULL)
};
e = CGLChoosePixelFormat(attribs, &pixelFormatObj, &numPixelFormats);
CGLCreateContext(pixelFormatObj, NULL, &contextObj);
CGLDestroyPixelFormat(pixelFormatObj);
CGLSetCurrentContext(contextObj);
CGLSetFullScreen(contextObj);
glOrtho(0.0, win_width, 0.0, win_height, -1.0, 1.0);

// set copy on vert retrace
CGLSetParameter(contextObj, kCGLCPSwapInterval, &swapInterval);
}


display_frame()

/* called once for each frame */

{

.
.
[ code to interpret frame into RGBA ]
.
.
.

glBindTexture(GL_TEXTURE_RECTANGLE_EXT, 1);
glTextureRangeAPPLE(GL_TEXTURE_RECTANGLE_EXT,
fr_widthlg*fr_heightlg*sizeof(int), mptr);
glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_STORAGE_HINT_APPLE,
GL_STORAGE_CACHED_APPLE);
//glTexParameteri(GL_TEXTURE_RECTANGLE_EXT,
//GL_TEXTURE_STORAGE_HINT_APPLE,
// GL_STORAGE_SHARED_APPLE); // tried this with
// glut, no obvious diff from CACHED
glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, 1);
glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_S, GL_REPEAT);
//GL_CLAMP stops any wrapping from
//occuring.
glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_T, GL_REPEAT);

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
//MAG_FILTER magnifies a texel to several pixels,
//GL_NEAREST is fastest
glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D( GL_TEXTURE_RECTANGLE_EXT,
0, // Detail level 0 is most detailed
GL_RGBA, // Components used for modulating
// and blending 3 uses
// all three components
fr_widthlg, // Width and height
fr_heightlg,
0, // Border size
GL_RGBA, // m_PixelFormat GL_RGB or GL_RGBA
GL_UNSIGNED_BYTE, // Data type of pixel values
mptr // Pixel values
);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBindTexture(GL_TEXTURE_RECTANGLE_EXT, 1);
glBegin(GL_QUADS); //draws a square
glTexCoord2f(fr_xorigin, fr_yorigin);
glVertex3f(-1.0*asp, 1.0, 0.0);
glTexCoord2f(fr_xorigin, fr_yorigin+fr_height);
glVertex3f(-1.0*asp, -1.0, 0.0);
glTexCoord2f(fr_xorigin+fr_width, fr_yorigin+fr_height);
glVertex3f( 1.0*asp, -1.0, 0.0);
glTexCoord2f(fr_xorigin+fr_width, fr_yorigin);
glVertex3f( 1.0*asp, 1.0, 0.0);
glEnd();
glMatrixMode(GL_TEXTURE);//set current matrix
glFlush();
}




Robert G. Smith <rob@xxxxxxxxxxxxxxxxxxxxx> wrote:
: The advice we've received on this topic from recent posts
: has been very helpful and I have made some progress.

: I got a sample display program going on Mac OSX 10.4.2
: with a Radeon 9600 Pro 256 MB, with OpenGL calls to

: generate textures:
: glGenTextures();
: glBindTexture()
: glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE,1)
: glTexParameteri(GL_TEXTURE_RECTANGLE_EXT,
: GL_TEXTURE_STORAGE_HINT_APPLE,
: GL_STORAGE_CACHED_APPLE);
: glTexImage2d()

: display:
: glBindTexture()
: glBegin()
: glTexCoord2f()
: glVergex3f()
: ...
: glutSwapBuffers();
: etc.

: With this code I have been able to display short frame sequences
: at 60 Hz frame rates. But when I give more than 60 frames, the
: rate drops to ~1 Hz, as if VRAM is limiting the number of frames
: that can be fast-swapped. For many sequences this is not a
: problem because the patterns to display only require 20-30
: frames.

: However, for some of the frame sequences, it is necessary have a
: very long list (~50,000) of different frames. In the past
: we have used the color lookup table to change colors so that the
: frames can be swapped very quickly without requiring a full RAM
: to VRAM copy. This an elegant solution but limits the number of
: colors to 8 bits.

.



Relevant Pages

  • Re: Can you tell the difference between 720 and 1080? I cant.
    ... 32"-720P which was at my summer cottage which was OTA only. ... frames per second) and 1080p. ... display and a 1920x1080 display ...
    (alt.tv.tech.hdtv)
  • Re: Do I need a database?
    ... plain text file into the page that matches the faq name. ... > You are thinking about static pages with a frames mindset. ... >> how to get the right hand side bit to display. ... >>>> would like the information relating to this topic to be displayed on ...
    (microsoft.public.frontpage.client)
  • Re: Survivor going HD!
    ... be a waste to get a 1080p display that can do 3:2 inverse telecine. ... I LOVE the 5:5 pulldown. ... When a show is filmed on film, it's shot at 24 frames per second. ... When a show is recored on video tape it's recored at 30 frames ...
    (alt.tv.survivor)
  • Re: OE6 - - problem ( screenshot photo)
    ... resolution) that show precisely Internet Explorer's Print Preview with ... is constructed from frames ... to be willing to change their display resolutions down to VGA mode ... And as I replied to Steve Cochran's response. ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: OE6 - - problem ( screenshot photo)
    ... resolution) that show precisely Internet Explorer's Print Preview with ... is constructed from frames ... to be willing to change their display resolutions down to VGA mode ... And as I replied to Steve Cochran's response. ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)