Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: wglGetProcAddress compilation errors...

  1. #1
    Junior Member Regular Contributor
    Join Date
    Aug 2001
    Location
    England
    Posts
    174

    wglGetProcAddress compilation errors...

    Hi, I'm having some problems compiling my code using wglGetProcAddress...
    I'm using VC++ 6 SP5 on Win2k for reference.
    Whenever I assign the function pointer, it gives me an error:
    error C2440: '=' : cannot convert from 'int (__stdcall *)(void)' to 'void (__stdcall *)(unsigned int,float)

    I get similar (the parameters vary with the GL call I'm assigning) errors for EVERY assignment I do (loading each OpenGL function from the library).

    Now, this is with the file haivng a .cpp extension, if I change it to a .c extension, the compiler just gives a warning (number #4113 I think) and carries on happily.
    While I'd like to say it's a solution just to have it as a .c file, I'd like to know if anybody else has encountered such a problem and what can be done to resolve it short of changing the file extension.

    Thanks for any help,

    -Mezz

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,797

    Re: wglGetProcAddress compilation errors...

    Sounds like you are trying to cast to the wrong function pointer types, or possibly are not casting at all.

    Here's an example of how it should be used..

    Code :
    // This line is from glext.h
    typedef void (APIENTRY * PFNGLFOGCOORDFEXTPROC) (GLfloat coord);
     
     
    PFNGLFOGCOORDFEXTPROC glFogCoordfEXT;
     
     
    glFogCoordfEXT = (PFNGLFOGCOORDFEXTPROC)wglGetProcAddress("glFogCoordfEXT");
     
     
    // then just use like a function
    glFogCoordfEXT(0.0);
    Hope that helps.

    [This message has been edited by Deiussum (edited 07-03-2002).]
    Deiussum
    Software Engineer and OpenGL enthusiast

  3. #3
    Junior Member Regular Contributor
    Join Date
    Aug 2001
    Location
    England
    Posts
    174

    Re: wglGetProcAddress compilation errors...

    Thanks Deiussum - I wasn't casting at all

    That was partly because I hadn't typedef'd the function pointers but anyway...

    I've re-organised everything and am casting like you said, it works OK now.

    Thankyou again.

    -Mezz

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •