# Extension manager problem

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

## Recommended Posts

Basicly i tried to have a bash at making an extension manager, like GLEE, but 20x crappier. I managed to make one (only with two EXT's), and it gives me no errors when compiling. But when it runs it gives me a standard "send error report" thing. here is the code: Ext.cpp:
PFNGLMULTITEXCOORD2FARBPROC		glMultiTexCoord2fARB;
PFNGLACTIVETEXTUREARBPROC		glActiveTextureARB;

CIrisExt::CIrisExt()
{
//NULLify Pointers
//Multitexturing
glMultiTexCoord2fARB = NULL;
glActiveTextureARB   = NULL;
}

bool CIrisExt::RequestExt(LPSTR Name)
{
//MultiTexturing
//"glActiveTextureARB"
if(Name=="glActiveTextureARB")
{
if(!glActiveTextureARB)
{
IrisLogger.Write("ERROR: Extension: 'glActiveTextureARB' could not be loaded.\n");
return false;
}else{
return true;
}
}
//"glMultiTexCoord2fARB"
if(Name=="glMultiTexCoord2fARB")
{
if(!glMultiTexCoord2fARB)
{
IrisLogger.Write("ERROR: Extension: 'glMultiTexCoord2fARB' could not be loaded.\n");
return false;
}else{
return true;
}
}
}


Ext.h:
extern PFNGLMULTITEXCOORD2FARBPROC		glMultiTexCoord2fARB;
extern PFNGLACTIVETEXTUREARBPROC		glActiveTextureARB;

class CIrisExt
{
public:
CIrisExt();
bool RequestExt(LPSTR Name);

protected:
//Logger
CIrisLogger IrisLogger;
};


Any help would be greatly appreciated... PS: I've probably made a stupid mistake, but im still not that good with extensions, and i dont know how they work very well.

##### Share on other sites
Run it in debug mode and find out where it crashes. I'm guessing the you try to call a function pointer which is set to NULL.

BTW, I didn't make GLee by manually adding every extension, since that would be really painful. I made a program to do that for me. But if all you want is a few select extensions then your approach should be okay.

##### Share on other sites
Thx, ill try to run it in Debug mode. Although i dont really know how to use it. But ill try.

As for manually adding extensions. I cant see other ways of doing it. Do you think you could give me a pointer (sorry for pun) in the right direction.

Thx for help.

PS: what happened to that crazy post bout 3dfx and DOS?

##### Share on other sites
bool CIrisExt::RequestExt(LPSTR Name){    //MultiTexturing    //"glActiveTextureARB"    if(Name=="glActiveTextureARB")

Is LPSTR a char pointer? If so, you can't just use == for the comparison. Use strcmp or use a std::string instead of a char *.

##### Share on other sites
YES!!!
Thats it, thx a lot TomasH. It was not going through that IF statement.

##### Share on other sites
Quote:
 Original post by Kris2456As for manually adding extensions. I cant see other ways of doing it. Do you think you could give me a pointer (sorry for pun) in the right direction.

There are 2 approaches to this. You can parse the GLext.h and wglext.h (assuming you're using windows) files in the GL extension registry - this is what GLee does, or you can parse the extension specification files themselves - GLEW does it like this. The information you'd need to extract is the names of function pointers associated with each extension, the extension names, constants etc, the parameters and return types. There are also a few sections of special case code (data types etc) which you'd need to add manually too. You can then use that data to build a file that defines all the extensions and links them automatically.

Quote:
 PS: what happened to that crazy post bout 3dfx and DOS?

It got deleted.

##### Share on other sites
If your talking about using glext.h thats what the extension manager uses. Basicly, what i wanted was:

You tell the manager what extension you want, and it will use wglGetProcAddress() to make the pointer valid. Then you can use the functions normally.

Is this an OK approach?

EDIT: Oh, about that post about 3DFX. That was my friend, who was trying to be "funny", (it was in its own way).

##### Share on other sites
Quote:
 Original post by Kris2456If your talking about using glext.h thats what the extension manager uses.

What I meant was you should write a program to generate the code for your extension lib, based on the contents of GLext.h or the ext specifications. If you look at GLee, I think it's over 6000 lines long. Writing that manually and updating it would be a major pain, so I used a program to write it for me.

Quote:
 Basicly, what i wanted was:You tell the manager what extension you want, and it will use wglGetProcAddress() to make the pointer valid. Then you can use the functions normally.

Requesting each one you use manually seems a bit painful. Libs such as GLee link everything in one init function. Other libraries link function pointers automatically when they're used, so you don't need an init function at all.

1. 1
Rutin
19
2. 2
3. 3
JoeJ
16
4. 4
5. 5

• 26
• 20
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631700
• Total Posts
3001782
×