Philip Nemec (nemec++at++sgi.com)
Wed, 26 Nov 1997 12:31:53 -0800
Using the C++ perfly just stick this at the beginning of your localPreDraw:
// There are a variety of possible sizes of TLUTS - but they're interpolated
// nicely so you may not need a very big table...
#define COLOR_TABLE_SIZE 256
static int first = 1;
static GLubyte table[COLOR_TABLE_SIZE][3];
int i;
if (first) {
pfNotify(PFNFY_WARN, PFNFY_PRINT, "computing table...\n");
// This is just an identity TLUT - just load it in from a file
// or something...
for (i = 0; i < COLOR_TABLE_SIZE; i++) {
table[i][0] = i;
table[i][1] = i;
table[i][2] = i;
}
pfNotify(PFNFY_WARN, PFNFY_PRINT, "downloading table...\n");
glColorTableSGI(GL_TEXTURE_COLOR_TABLE_SGI, GL_RGB8_EXT,
COLOR_TABLE_SIZE, GL_RGB,
GL_UNSIGNED_BYTE, table);
first = 0;
}
if (ViewState->tlut)
glEnable(GL_TEXTURE_COLOR_TABLE_SGI);
else
glDisable(GL_TEXTURE_COLOR_TABLE_SGI);
-------------------------------
This assumes you want the TLUT enabled for everything. If you only want it for
certain objects just stick in draw callbacks to enable or disable TLUTs. You
don't need to keep reloading the table though. If you different tables this
shows how to do it, but I have no idea on the performance hit. For one thing
make sure you do it at the end of the frame so you don't clog up the pipe.
On infiniteReality TLUTs are basically free (there is barely any slowdown from
enabling TLUTs).
Something to beware of - the TLUT filtering happens *after* the texture
filtering. That means that if you're using mipmapping there a a bunch of
samples that get blended together first, then that result goes through the
TLUT. So if you have a highly discontinuous TLUT you may get weird color
smearing as you move an object around.
If you want to use pixels as the TLUT the call you want is
glCopyColorTableSGI... I have no idea how the performance compares to "normal"
TLUT downloads - although if you burn a little bit of texture memory to store
the TLUT I imagine that could be much faster. However TLUTs are pretty small
so it may not be worth the trouble.
If you can limit yourself to changing the scale and bias of the table (rather
than downloading a new one) check out glColorTableParameterSGI.
Regarding sizes - remember that you can have a table *per channel* - but the
channels are indexed independantly. The example I gave above is a 256*3 entry
table. I think you can get a max of 4096*4 entry table - although I think this
memory is shared with some other features, so in a fully loaded app you may
have to shrink things down some. These entries are 12 bit - so any smaller
size tables are expanded to 12 bits.
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
Submissions: info-performer++at++sgi.com
Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:56:15 PDT