OpenGL forward-compatible context creation on Windows Is this the proper method for creating an OpenGL 3.3+ forward-compatible context?

// Create window
WNDCLASSEX wc;
ZeroMemory( &amp;wc, sizeof( wc ) );
wc.cbSize = sizeof( wc );
wc.lpfnWndProc = _eventHandler;
wc.hInstance = GetModuleHandle( NULL );
wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
wc.hIconSm = LoadIcon( NULL, IDI_APPLICATION );
wc.hCursor  = LoadCursor( NULL, IDC_ARROW );
wc.lpszClassName = "OpenGL 3.3";
if ( !RegisterClassEx( &amp;wc ) ) Error( "Failed to register window class!" );
if ( !( _window = CreateWindowEx( WS_EX_CLIENTEDGE, "OpenGL 3.3", "OpenGL 3.3", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, GetModuleHandle( NULL ), NULL ) ) )
    Error( "Failed to create the window!" );
if ( !( _hdc = GetDC( _window ) ) ) Error( "Failed to retrieve device context!" );

// Choose pixel format
int pixelFormat;
PIXELFORMATDESCRIPTOR pfd;
ZeroMemory( &amp;pfd, sizeof( pfd ) );
pfd.nSize = sizeof( pfd );
pfd.nVersion = 1; 
pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;  
pfd.iPixelType = PFD_TYPE_RGBA; 
pfd.cColorBits = 32;
pfd.cDepthBits = 32; 
pfd.iLayerType = PFD_MAIN_PLANE;
if ( !( pixelFormat = ChoosePixelFormat( _hdc, &amp;pfd ) ) ) Error( "Failed to find suitable pixel format!" );
if ( !SetPixelFormat( _hdc, pixelFormat, &amp;pfd ) ) Error( "Failed to set pixel format!" );

// Create temporary context and make sure we have support
HGLRC tempContext = wglCreateContext( _hdc );
if ( !tempContext ) Error( "Failed to create temporary context!" );
if ( !wglMakeCurrent( _hdc, tempContext ) ) Error( "Failed to activate temporary context!" );

int major, minor; glGetIntegerv( GL_MAJOR_VERSION, &amp;major ); glGetIntegerv( GL_MINOR_VERSION, &amp;minor );
if ( major &lt; 3 || minor &lt; 2 ) Error( "OpenGL 3.2 is not supported!" );

// Create forward compatible context
int attribs[] =
{
    WGL_CONTEXT_MAJOR_VERSION_ARB, major,
    WGL_CONTEXT_MINOR_VERSION_ARB, minor, 
    WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
    WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
    0
};
PFNWGLCREATEBUFFERREGIONARBPROC wglCreateContextAttribsARB = (PFNWGLCREATEBUFFERREGIONARBPROC)wglGetProcAddress( "wglCreateContextAttribsARB" );
if ( !wglCreateContextAttribsARB ) Error( "Failed to find pointer to wglCreateContextAttribsARB function!" );
if ( !( _context = wglCreateContextAttribsARB( _hdc, 0, (UINT)attribs ) ) ) Error( "Failed to create forward compatible context!" );

// Remove temporary context and activate forward compatible context
wglMakeCurrent( NULL, NULL );
wglDeleteContext( tempContext );
if ( !wglMakeCurrent( _hdc, (HGLRC)_context ) ) Error( "Failed to activate forward compatible context!" );

// Show window
ShowWindow( _window, SW_SHOW );
UpdateWindow( _window );


It seems to work (gives GL_INVALID_OPERATION when using glBegin), but I just want to make sure this is the right way to go about it.
This looks right to me. I am a bit tired right now and usually use GLFW.

You might be interested in this page on the OpenGL wiki describing setting up the context after 3.1 which is essentially the same work.