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 4 of 4

Thread: Do I need to "unload" the functions loaded by GL Load?

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2012
    Posts
    8

    Do I need to "unload" the functions loaded by GL Load?

    Hello, I've been tinkering about with GL Load and I'm wondering if I need to "unload" the functions if I want to make another call to LoadFunctions().

    And also, does glload::GetMajorVersion() and glload::GetMinorVersion() return the version of the context or the version supported by the hardware?

    Code :
    HWND GLApp::CreateContext(LPCWSTR szWindowName)
    {
    	WNDCLASSEX wc = {0};
    	wc.cbSize = sizeof(WNDCLASSEX);
    	wc.style = CS_OWNDC;
    	wc.hInstance = GetModuleHandle(NULL);
    	wc.lpfnWndProc = &(Jiggine::WindowProc);
    	wc.lpszClassName = L"GLAPP";
     
    	RegisterClassEx(&wc);
     
    	HWND hWnd = CreateWindowEx(
    		NULL,L"GLAPP",
    		L"GL App",
    		WS_BORDER | WS_SYSMENU | WS_CAPTION,
    		CW_USEDEFAULT,CW_USEDEFAULT,
    		800,600,
    		NULL,NULL,wc.hInstance,NULL);
     
    	HDC hDC = GetDC(hWnd);
     
    	int iPixelFormat = ChoosePixelFormat(hDC,&::gc_pfd);
    	SetPixelFormat(hDC,iPixelFormat,&::gc_pfd);
     
    	HGLRC hDummy = wglCreateContext(hDC);
    	wglMakeCurrent(hDC,hDummy);
     
            glload::LoadFunctions(); // This is the first call to LoadFunctions(), to determine what version we're working with.
     
            int minVer = glload::GetMinorVersion(); //First problem here, will this return the version of the context(hDummy) or what's supported on the machine? I'm guessing the former which makes the following code stupid.
    	int majVer = glload::GetMajorVersion();
     
    	if(majVer < 3 && minVer < 1)
    	{
    		this->context = new GL2_1Context(hDummy);
    		return hWnd;
    	}
     
            //If glload::GetMajorVersion and glload::GetMinorVersion return what I want then we should end up here if there's something greater or equal to 3.1
     
    	PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
     
    	HGLRC hTheRealDeal = wglCreateContextAttribsARB(hDC,0,::gc_attribs);
     
    	wglMakeCurrent(NULL,NULL);
    	wglDeleteContext(hDummy);
     
    	wglMakeCurrent(hDC,hTheRealDeal);
     
            glload::LoadFunctions(); //Will this load the functions valid for the new context?
            glload::LoadWinFunctions();
     
    	this->context = new GL3_1Context(hTheRealDeal);
     
    	return hWnd;
    }

    Any help is appreciated!

  2. #2
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    I'm wondering if I need to "unload" the functions if I want to make another call to LoadFunctions().
    No. No memory is allocated by the loading process, so nothing needs to be undone.

    And also, does glload::GetMajorVersion() and glload::GetMinorVersion() return the version of the context or the version supported by the hardware?
    The context. There is no way to ask the hardware itself what it supports.

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2012
    Posts
    8
    Quote Originally Posted by Alfonse Reinheart View Post
    No. No memory is allocated by the loading process, so nothing needs to be undone.



    The context. There is no way to ask the hardware itself what it supports.
    So, this is not a viable way to check what version of OpenGL is available I take it?

  4. #4
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    So, this is not a viable way to check what version of OpenGL is available I take it?
    It's how you check what version of OpenGL you got. What "is available" means is irrelevant; it's about what you got when you created your context.

    And therefore what core functions you can expect to exist after you load them.

Posting Permissions

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