Unanswered wglCreateContext and ERROR_INSUFFICIENT_BUFFER

  • Wednesday, June 20, 2012 9:43 PM
     
      Has Code

    I have an application that uses three separate OpenGL contexts embedded in Windows forms.  The first two are of identical size and initialize and run normally.  The third is smaller and I cannot create a context on Windows XP SP3.  All three use identical context creation method.

    	PIXELFORMATDESCRIPTOR pfd = { 
    		sizeof(PIXELFORMATDESCRIPTOR),   // size of this pfd  
    		1,                     // version number  
    		PFD_DRAW_TO_WINDOW |   // support window  
    		PFD_SUPPORT_OPENGL |   // support OpenGL  
    		PFD_DOUBLEBUFFER,      // double buffered  
    		PFD_TYPE_RGBA,         // RGBA type  
    		24,                    // 24-bit color depth  
    		0, 0, 0, 0, 0, 0,      // color bits ignored  
    		0,                     // no alpha buffer  
    		0,                     // shift bit ignored  
    		0,                     // no accumulation buffer  
    		0, 0, 0, 0,            // accum bits ignored  
    		32,                    // 32-bit z-buffer  
    		0,                     // no stencil buffer  
    		0,                     // no auxiliary buffer  
    		PFD_MAIN_PLANE,        // main layer  
    		0,                     // reserved  
    		0, 0, 0                // layer masks ignored  
    	}; 
    
    
    	GLuint pixelFormat = ::ChoosePixelFormat(mDc, &pfd);
    	if (!pixelFormat)
    	{
    		CxDebugLastError();
    		CxThrow(CxErrorOpenGL);
    	}
    	
    	bool validPixelFormat = ::SetPixelFormat(mDc, pixelFormat, &pfd);
    	if (!validPixelFormat)
    	{
    		CxDebugLastError();
    		CxThrow(CxErrorOpenGL);
    	}
    	
    	mContext = ::wglCreateContext(mDc);
    	if (!mContext)
    	{
    		CxDebugLastError();
    		CxThrow(CxErrorOpenGL);
    	}
    

    mDc is fetched from an HWND passed into the method, and is valid. 

    mContext is a HGLRC stored in the class.  It has the address of 0x00010002 after the call to wglCreateContext for the aforementioned issue, thus the "if (!mContext)" fails.  I had to move "CxDebugLastError()" outside the if-check to see that I was getting ERROR_INSUFFICIENT_BUFFER.

    1) Why is this failing on Windows XP SP3, but working fine on Windows 7?

    2) Why does wglCreateContext not return NULL when it fails in this case as the documentation states it should?

All Replies

  • Thursday, June 21, 2012 5:24 AM
     
     

    Your question is very OpenGL specific and not really on topic here. You should ask your question in a more OpenGL related forum

    Regarding your question why your code works on Windows 7 but not XP SP3, my question is, is is the identical hardware? At all it is not a good idea to keep too much open contexts at the same time alive. It is the same with the normal Windows DC's.

  • Thursday, June 21, 2012 4:59 PM
     
     
    I'm using Parallels desktop with identical memory, CPU, and video memory settings between the Win7 and WinXP machines, so yes, the hardware could be considered more or less identical.
  • Friday, June 22, 2012 7:54 AM
     
     

    Hi Vortmax,

    Welcome here.

    According to your description, I'd like to move this thread to off-topic, I suggest you go to "OpenGL Forum" for better support.

    Thanks for your understanding and active participation in the MSDN Forum.

    Regards,

    Elegentin


    Elegentin Xie [MSFT]
    MSDN Community Support | Feedback to us