Why don't I have the WGL_ARB_create_context extension?

I am creating the following code to create the OpenGL context of the main profile.

In particular, I:

  • Creating a dummy window
  • Using this dummy window to request OpenGL context (I assume it will be hardware accelerated, but I'm not sure if it even matters)
  • Using this OpenGL context to load OpenGL function pointers
  • Using these function pointers, I then try to use wglCreateContextAttribsARBto create a second context, in particular, with the kernel profile in the second window.

the code:

WNDCLASSW wcDummy = {0};
wcDummy.lpfnWndProc     = +[](HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){return DefWindowProcW(hWnd, message, wParam, lParam);};
wcDummy.hInstance       = GetModuleHandle(0);
wcDummy.hbrBackground   = (HBRUSH)(COLOR_BACKGROUND);
wcDummy.lpszClassName   = L"Dummy";
wcDummy.style           = CS_OWNDC;

if(!RegisterClassW(&wcDummy))
{
    get_and_print_error();
    return false;
}

HWND windowDummy = CreateWindowW(wcDummy.lpszClassName, title.c_str(), WS_DISABLED, 0, 0, 640, 480, 0, 0, wcDummy.hInstance, NULL);
if(windowDummy == NULL)
{
    get_and_print_error();
    return false;
}

PIXELFORMATDESCRIPTOR pfdDummy =
{
    sizeof(PIXELFORMATDESCRIPTOR),
    1,
    PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
    PFD_TYPE_RGBA,
    32,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    24,
    8,
    0, 0, 0, 0, 0, 0
};

HDC dummyDrawingContext = GetDC(windowDummy);

INT pixelFormatDummy = ChoosePixelFormat(dummyDrawingContext, &pfdDummy);
SetPixelFormat(dummyDrawingContext, pixelFormatDummy, &pfdDummy);

HGLRC dummyContext = wglCreateContext(dummyDrawingContext);
wglMakeCurrent(dummyDrawingContext, dummyContext);

if(wglGetCurrentContext() != NULL)
{
    load_gl_functions();
}
else
    return false;

PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = nullptr;

GLint64 numExtensions;
glGetInteger64v(GL_NUM_EXTENSIONS, &numExtensions);
std::cout << "Available Extensions:\n";
for(GLint64 i = 0; i < numExtensions; ++i)
{
    const GLubyte* extensionName = glGetStringi(GL_EXTENSIONS, i);

    std::cout << "\n\t" << (const char*)extensionName;

    if(std::strcmp((const char*)extensionName, "WGL_ARB_create_context") == 0)
    {
        wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
    }
}
std::cout << std::endl;

wglDeleteContext(dummyContext);
DestroyWindow(windowDummy);

WNDCLASSW wc = {0};
wc.lpfnWndProc      = Window::WndProc;
wc.hInstance        = GetModuleHandle(0);
wc.hbrBackground    = (HBRUSH)(COLOR_BACKGROUND);
wc.lpszClassName    = title.c_str();
wc.style = CS_OWNDC;

if(!RegisterClassW(&wc))
{
    get_and_print_error();
    return false;
}

HWND window = CreateWindowW(wc.lpszClassName, title.c_str(), WS_OVERLAPPED|WS_VISIBLE|WS_SYSMENU ,0,0,640,480,0,0,wc.hInstance,this);
if(window == NULL)
{
    get_and_print_error();
    return false;
}

PIXELFORMATDESCRIPTOR pfd =
{
    sizeof(PIXELFORMATDESCRIPTOR),
    1,
    PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
    PFD_TYPE_RGBA,
    32,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    24,
    8,
    0, 0, 0, 0, 0, 0
};

HDC m_drawingContext = GetDC(window);

INT pixelFormat = ChoosePixelFormat(m_drawingContext, &pfd);
SetPixelFormat(m_drawingContext, pixelFormat, &pfd);

const GLint attribList[] =
{
    WGL_CONTEXT_MAJOR_VERSION_ARB, 4,
    WGL_CONTEXT_MINOR_VERSION_ARB, 4,
    WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
    0
};

m_glRenderContext = wglCreateContextAttribsARB(m_drawingContext, 0, attribList);

wglMakeCurrent(m_drawingContext, m_glRenderContext);

if(wglGetCurrentContext() != NULL)
{
    load_gl_functions();
}
else
    return false;

const GLubyte* driver = glGetString(GL_RENDERER);
const GLubyte* version = glGetString(GL_VERSION);
const GLubyte* glslVersion = glGetString(GL_SHADING_LANGUAGE_VERSION);

std::wcout << "Device:       " << std::wstring(convert_gl_string_to_win32_string(driver)) << std::endl;
std::wcout << "GL Version:   " << std::wstring(convert_gl_string_to_win32_string(version)) << std::endl;
std::wcout << "GLSL Version: " << std::wstring(convert_gl_string_to_win32_string(glslVersion)) << std::endl;
std::wcout << std::endl;

The problem is that the extension WGL_ARB_create_contextdoes not exist.

However, if I forgot about checking the list of extensions, i.e. interrupt the loop and simply:

wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");

I get a pointer to a function and everything works correctly.

WGL_ARB_create_context, ?

EDIT AMD Radeon HD 7900 seriesY

+4
3

WGL_ARB_create_context, ?

WGL GL. WGL_ARB_extension_string, WGL. :

wglGetProcAddress, , wglGetExtensionsStringARB. , , WGL .

, - , , NULL.

, WGL GL: . 1 extenstion:

, ,       glGetString (, )       , . O       wglGetExtensionsStringARB,       , , WGL      .

:

GL glGetStringi GL 3.0. glGetInteger64v, glGetStringi , , , , - Microsoft GL 1.1.

+7

, WGL_ARB_create_context , , OpenGL, WGL. glGetStringi OpenGL, WGL 1.

WGL, WGL_ARB_extensions_string, wglGetExtensionsStringARB. , , - wglGetExtensionsStringARB , 0.

wglGetProcAddress, ,      wglGetExtensionsStringARB.

, , WGL_ARB_create_context, wglCreateContextARB .


1 - . :

, ,      glGetString (, )       , . O       wglGetExtensionsStringARB ,       , , WGL      .

+3

glGetInteger64v . Windows, gl OpenGL 1.1
glGetStringi. OGL >= 3.0. , . , . , , .

wglCreateContextAttribsARB Windows, .

, Windows, - wglGetExtensionsStringARB wglGetExtensionsStringEXT. wglGetProcAddress.

-1

Source: https://habr.com/ru/post/1684668/


All Articles