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?
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!