Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Juicy

Extention paths

This topic is 5744 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was wondering if anyone had some useful tips on coding various extention paths. Perhaps a good tutorial on NeHe would be worthwhile. While I understand the principal of extentions, I wanted some tips or warnings of common pitfalls when implementing them.

Share this post


Link to post
Share on other sites
Advertisement
the simplest extension path:


if (extensionSupported)
glExtension()...
else
glBogStandard()...


common pitfall:
assuming an extension is supported..

| - Project-X - my mega project.. big things comming soon - | - adDeath - an ad blocker I made - | - email me - |

[edited by - RipTorn on January 23, 2003 4:36:00 PM]

Share this post


Link to post
Share on other sites
Heres a handy dandy thing I noticed (other people may of noticed too but I''ll say it anyway)

Instead of having to keep track of a IsXXXExtension supported variable, just initialize your function pointer to NULL, and before actually using it, do

if(glExtension)
glExtension();

You can do this because FALSE and NULL = 0 and any nonzero value is true. So, if the function was found the pointer won''t be NULL, and the statement will evaluate to true. Got it?

Share this post


Link to post
Share on other sites
Hawkeye3, I'm not 100% sure I understand you.
I get the idea that a non NULL pointer will evaluate to TRUE, but I'm unsure about the way you'd use a pointer to a function to support multiple extentions.

The reason I ask is that I'm planning on getting my grubby hands on a GeForce FX when they show up and I'll be making my engine take advantage of the obviously better shaders and a whole load of other tricks while still supporting older cards and extentions.

[Edit] Correcting terrible spelling mistakes

[edited by - Juicy on January 24, 2003 5:37:25 AM]

Share this post


Link to post
Share on other sites
The only real problem I see with my logic is that if you don''t want the person to use the extension, even if it is supported.

Remember when you call wglGetProcAddress? That returns the address that your function pointer points to if the procedure is found, otherwise it is NULL(0).

Perhaps I wasn''t clear enough with my example...

// During Init
// These return NULL if the function isn''t found
glLockArraysEXT = (PFNGLLOCKARRAYSEXTPROC)wglGetProcAddress("glLockArraysEXT");
glUnlockArraysEXT = (PFNGLUNLOCKARRAYSEXTPROC) wglGetProcAddress ("glUnlockArraysEXT");

// When you want to use them

if(glLockArraysEXT) // If the function is valid (not NULL)
glLockArraysEXT(x, GL_x) // Its safe to use it

...

if(glUnlockArraysEXT)
glUnlockArraysEXT()

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
ahha. I get it now.
Thankyou Hawkeye3.

Share this post


Link to post
Share on other sites
It''s not always that simple.
The EXT_compiled_vertex_array is pretty easy for that, but almost all extensions really need different path, not *just* forgetting the function call.

Generally, in the initialization function, you get which extensions are available, for instance :


  
bool is_multitexture_supported = false; /* global */

void initGL()
{
...
is_multitexture_supported = strstr((const char*)glGetString(GL_EXTENSIONS), "GL_ARB_multitexture") != 0;
...
}



Then use different path for either case :

  
void renderGL()
{
...
if (is_multitexture_supported)
{
/* path #1 : multitexture is supported : we can use all texture units available */
}
else
{
/* path #2 : multitexture is not supported : we have to do it in multipass or forget the nice effect that multitexture could perform */

}
...
}

Share this post


Link to post
Share on other sites
Eh I don''t get what your saying? I can just slap an else on my if statement and it works exactly like your code.

if(glxxxExt) // Valid to use
// Use it
else
// Do some work-around

It was just meant to be pseudo code anyway :|

Share this post


Link to post
Share on other sites
quote:

if(glxxxExt) // Valid to use
// Use it
else
// Do some work-around



yup. thats the way.


quote:
Original post by Juicy
The reason I ask is that I'm planning on getting my grubby hands on a GeForce FX when they show up and I'll be making my engine take advantage of the obviously better shaders and a whole load of other tricks while still supporting older cards and extentions.


hehe. geforce FX. hmm. Course a month or so later ati will release their next semi-secret chip, putting nvidia in their place again. hehe.

| - Project-X - my mega project.. big things comming soon - | - adDeath - an ad blocker I made - | - email me - |

[edited by - RipTorn on January 27, 2003 7:19:17 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!