Sign in to follow this  
Kris2456

Extension manager problem

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")
    {
        glActiveTextureARB	= (PFNGLACTIVETEXTUREARBPROC)		wglGetProcAddress("glActiveTextureARB");
        if(!glActiveTextureARB)
        {
            IrisLogger.Write("ERROR: Extension: 'glActiveTextureARB' could not be loaded.\n");
            return false;
        }else{
            IrisLogger.Write("Extension: 'glActiveTextureARB' loaded successfully.\n");
            return true;
        }
    }
    //"glMultiTexCoord2fARB"
    if(Name=="glMultiTexCoord2fARB")
    {
        glMultiTexCoord2fARB	= (PFNGLMULTITEXCOORD2FARBPROC)		wglGetProcAddress("glMultiTexCoord2fARB");
        if(!glMultiTexCoord2fARB)
        {
            IrisLogger.Write("ERROR: Extension: 'glMultiTexCoord2fARB' could not be loaded.\n");
            return false;
        }else{
            IrisLogger.Write("Extension: 'glMultiTexCoord2fARB' loaded successfully.\n");
            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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by Kris2456
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.

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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by Kris2456
If 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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this