Extension manager problem

Started by
6 comments, last by benjamin bunny 19 years, 7 months ago
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.
------------ "Here lies a toppled God,His fall was not a small one,We but built his pedastle,A narrow, and a tall one" Frank Herbert (Dune:Messiah)
Advertisement
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.

____________________________________________________________www.elf-stone.com | Automated GL Extension Loading: GLee 5.00 for Win32 and Linux

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?
------------ "Here lies a toppled God,His fall was not a small one,We but built his pedastle,A narrow, and a tall one" Frank Herbert (Dune:Messiah)
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 *.
YES!!!
Thats it, thx a lot TomasH. It was not going through that IF statement.


------------ "Here lies a toppled God,His fall was not a small one,We but built his pedastle,A narrow, and a tall one" Frank Herbert (Dune:Messiah)
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.

____________________________________________________________www.elf-stone.com | Automated GL Extension Loading: GLee 5.00 for Win32 and Linux

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).
------------ "Here lies a toppled God,His fall was not a small one,We but built his pedastle,A narrow, and a tall one" Frank Herbert (Dune:Messiah)
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.

____________________________________________________________www.elf-stone.com | Automated GL Extension Loading: GLee 5.00 for Win32 and Linux

This topic is closed to new replies.

Advertisement