GL extension checking/loading
tigital
tigital at mac.com
Thu Oct 30 13:18:45 EST 2003
me again,
...at the moment, freespace1/2 doesn't seem to take advantage of any
opengl extensions, and there are several possible things that should
give appreciable speed ups, at least on OSX (I'm thinking specifically
of replacing GL_TEXTURE_2D with GL_TEXTURE_RECTANGLE_EXT, adding
glTextureRangeAPPLE(), and using GL_UNPACK_CLIENT_STORAGE_APPLE: all
of these can select a cpu bypass for direct AGP texture uploads)...all
of this could easily be #ifdef __APPLE__, but I'd like to set it up so
that at least future addition of extension-enabled graphic improvements
is easier...
...here's the code I've used before for cross platform extension
checking (but also for checking that a particular capability is
available on a OSX graphic card):
/*
This is SGI sample code taken directly from OpenGL.org:
http://www.opengl.org/developers/code/features/OGLextensions/
OGLextensions.html
*/
int OpenGLExtensionIsSupported(const char* extension) {
const GLubyte *extensions = NULL;
const GLubyte *start;
GLubyte *where, *terminator;
/* Extension names should not have spaces. */
where = (GLubyte *) strchr(extension, ' ');
if (where || *extension == '\0')
return 0;
extensions = glGetString(GL_EXTENSIONS);
/* It takes a bit of care to be fool-proof about parsing the
OpenGL extensions string. Don't be fooled by sub-strings,
etc. */
start = extensions;
for (;;) {
where = (GLubyte *) strstr((const char *) start, extension);
if (!where)
break;
terminator = where + strlen(extension);
if (where == start || *(where - 1) == ' ')
if (*terminator == ' ' || *terminator == '\0')
return 1;
start = terminator;
}
return 0;
}
...so, anyone have thoughts, pro/con? I know that the prevailing
opinion of the icculus port is to maintain the basic integrity of the
code (meaning no specific changes for mod support, or features that
break compatibility with the basic campaigns), but I don't think the
above texture speedups are anything but performance enhancers...
l8r,
jamie
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 3443 bytes
Desc: not available
URL: <http://icculus.org/pipermail/freespace2/attachments/20031030/3363e652/attachment.bin>
More information about the freespace2
mailing list