OpenGL wglCreateContext fails when rendering onto a bitmap


I’m having a frustrating problem with the wglCreateContext call. I’m using DirectX for rendering on screen, and I’m using OpenGL to render the same thing onto a bitmap (for printing). When not using DirectX, the OpenGL bitmap creation works fine, but when using DirectX, the wglCreateContext call fails and GetLastError returns 8 (“Not enough storage is available to process this command”). Anybody got any thoughts on this? A number of calls are succeeding before this call fails: getting the screen DC, CreateDIBSection, SetPixelFormat all succeed.

All help is appreciated!


I don’t know what could be the cause, but you should probably add information about your operating system and graphics card you’re using when asking such question.

You’re absolutely right, here are some more details:
OS: Windows XP Pro, graphics card NVIDIA GeForce 7600 Go (512 Mb memory). It might indeed very well be a problem related to the nvidia driver. If it only would give decent error messages, the memory really cannot be the actual problem.

Edit: I’m just getting more insight in what the problem is. It doesn’t have to do anything with DirectX, the problem seems to be trying to render on a bitmap, without having used OpenGL for rendering on the screen. I just created a small test console program to try and do OpenGL rendering on a bitmap, and it gives the same error.

Digging further!!!


Try using glIntercept. It often saves some time and trouble :slight_smile:

Bwegh, but I should just be able to render to a bitmap without even having even a Window, right? Seems like I’m doing something that very few people do (although I would have expected this is quite a common scenario!). I’m gonna give it one more try getting it resolved!

I appreciate the help! (If you get it resolved for me we can discuss some compensation for you).


I’m gonna give it one more try getting it resolved!
That’s the spirit, wout.

Rendering to HBITMAP is not hw accelerated. OpenGL will choose MS implementation (v1.1).

Workaround is to create real GL context (attached to window), then create FBO or PBUFFER, do render and readbeck result in sys mem. Convert that result to Bitmap. Never call SwapBuffers and window content will stay unchanged.

Thanks for the answer yooyo. OpenGL 1.1 software rendering is quite fine for my purposes, so as a work around, I create an OpenGL window first, render something on a one by one pixel, dispose of it, and then do the bitmap rendering. Once I’ve done one rendering to a window, the OpenGL rendering to bitmap is working. It sounds like a bug in the NVIDIA drivers to me, I’ll have to post a message on the NVIDEA developer site.


Thats fine… btyw… keep in mind to call SetPixelFormat only ONCE per window.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.