Results 1 to 7 of 7

Thread: problem with glut concerning resources

  1. #1
    Member Newbie
    Join Date
    Aug 2002
    Location
    Germany
    Posts
    35

    problem with glut concerning resources

    I am using glut and want to combine some data with the exe file. Normally (that means with Win Api) i would try something like 1. hres = LoadResource(hInstance,...
    2.pData = LockResource(hres);
    Of course the problem is that i dont know how to get the hInstance - handle...but many win api functions need this handle. Is it possible to connect WinMain with GLUT or is there another method to access resources ?
    Maybe there is a function that returns me this handle ??
    Greetings,Martin

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: problem with glut concerning resources

    You can get the hInstance of the module with GetModuleInstance().

    Or you can create a regular WinMain in your code (and setup your project to use the WinMain as entry point instead of main, assuming you use MSVC), and then call main from there. No modifications needed, only add this after your existing main function.
    Code :
    ... WinMain(...) // don't know the protoype for WinMain
    {
        // Get hInstance from WinMain here
     
        int argc = 1;
        char *argv = "myprogram.exe";
        main(argc, &argv);
    }

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

    Re: problem with glut concerning resources

    Are you sure it's GetModuleInstance()? MSDN has that function as a method on the CComModule class.

    I know there is a Win32 API function that will get the HINSTANCE for you, but I just can't seem to find it right now. If I remember right it was some name that didn't really make sense for what it did.
    Deiussum
    Software Engineer and OpenGL enthusiast

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: problem with glut concerning resources

    Well, was a little bit too fast with the documentation when I looked it up. Seems to be GetModuleHandle() instead.

    Here's a piece of code I found in one of my programs.
    Code :
    HINSTANCE instance = GetModuleHandle(NULL);
    I hope that one is right

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

    Re: problem with glut concerning resources

    Ahh... yes. That is the one! I kept searching for something like GetGlobalModuleHandle or GetGlobalWhatever... I haven't used that API function in a long time and my memory was a bit hazy.
    Deiussum
    Software Engineer and OpenGL enthusiast

  6. #6
    Member Contributor
    Join Date
    Aug 2001
    Posts
    62

    Re: problem with glut concerning resources

    int WINAPI WinMain(HINSTANCE hInst,HINSTANCE hPrevInstance,LPSTR lpCmpLine,int nShowCmd);

    the instance is passed a paramater to winmain apon entry...

  7. #7
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: problem with glut concerning resources

    ... but the problem occurs when you don't have a WinMain() entry point in your code.

Similar Threads

  1. Replies: 7
    Last Post: 07-02-2013, 05:14 PM
  2. Out of resources problem
    By GankevichIvan in forum OpenCL
    Replies: 5
    Last Post: 07-08-2010, 05:49 AM
  3. Out of resources problem
    By grimm in forum OpenCL
    Replies: 9
    Last Post: 03-03-2010, 02:40 PM
  4. Texturing problem, already tried resources
    By feeraflym in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 01-02-2009, 10:31 AM
  5. problem with glut concerning resources
    By Tresher in forum OpenGL: General
    Replies: 1
    Last Post: 08-07-2002, 06:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean