First and foremost your error checking code is wrong. You must call glGetError
in a loop until it returns GL_NO_ERROR
.
Regarding the GL_OUT_OF_MEMORY
error code: It can also mean out of address space, which can easily happen if a large contiguous area of virtual address space is requested from the OS, but the process' address space is so much fragmented that no chunk that size is available (even if the total amount of free address space would suffice).
This has become the bane of 32 bit systems. A simple remedy is to use a 64 bit system. If you're stuck with a 32 bit plattform you'll have to defragment your address space (which is not trivial).