HP SVA V2.1 Parallel Compositing Reference Guide

if(err != PC_NO_ERROR) reportError(err);
/* Decide the pixel format to use with GL from the channel structure
The code below is just intended to show how to handle the general case */
switch(channel.pixelFormat){
case PC_PF_BGRA8:
format = GL_BGRA; break;
case PC_PF_BGR8:
format = GL_BGR; break;
case PC_PF_RGBA8:
format = GL_RGBA; break;
default:
assert(!"Invalid pixel format - this can't happen");
}
/* Setup the proper alignment for glDrawPixels to work cleanly */
glPixelStorei(GL_UNPACK_ALIGNMENT, channel.alignment);
/* Setup ROW_LENGTH if needed, again needed for glDrawPixels */
if(channel.rowLength != channel.width){
glPixelStorei(GL_UNPACK_ROW_LENGTH, channel.rowLength);
}
else {
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); /* this is also the default */
}
/* Setup the raster position to the bottom left of the window */
glWindowPos2iARB(0,0);
/* Draw the results */
glDisable(GL_DEPTH_TEST);
glDrawPixels(channel.width, channel.height, format, type, channel.address);
The part of this sequence that is most often overlooked is the alignment. OpenGL may default
to buffers where rows are aligned with the memory data on 4 byte boundary or 8 byte
boundary. OpenGL default alignment is 4.
GLUT Use in an Application
GLUT is a convenient toolkit to use when writing OpenGL applications. It can be used with
the Library; however, certain sequences that work on a single node need to be modified for
a distributed application. Many of the samples included as part of the HP Library Kit use
GLUT.
This tip outlines restrictions on using GLUT and suggests the use of techniques from the
samples.
GLUT lets a program supply a display function, an idle function, reshape function, and a
keyboard function. For a distributed application, GLUT calls the idle function a different
number of times on each node. So you should be careful about using the idle function as a
means of tracking the progression of time.
The samples vary their use of GLUT; however, it is generally based on one host (frequently
the master) getting user input events. This host processes these events. It then communicates
to the remaining hosts any actions they need to take as a result of the input events.
To get input events, a host needs to have a window manager running. By default, SVA job
launch scripts only start the Xserver; they do not start a window manager. In the scripts
provided with the samples, a window manager is explicitly started for the master. It is not
started for the slaves because they do not receive input from input events.
The samples use different techniques for communicating. Several take advantage of the fact
that pcBeginFrame is a natural sync point. Slaves can be free-running and block on this
call. Several take advantage of using the PCcontext to communicate information, such as
the size of the their framelet which matches the size of the frame. The master can set this
before pcFrameBegin and the slaves can get this value after pcFrameBegin. In the
intermediate samples, a socket is introduced for the master to communicate with the slaves.
22 Main Areas of the Parallel Compositing Library