View Full Version : OUT_OF_MEMORY error on glDrawArrays

01-03-2014, 04:37 PM
Hi there.

I know, this is not supposed to happen, but for some reason I get an OUT_OF_MEMORY error when calling glDrawArrays. Yes I know, it doesnt say anything about that in the reference pages...

I am checking for gl errors each frame (for debugging purposes) just in case I missed to check after any openGL command. There are no errors at all, unless I insert this line in my program:

glDrawArrays(GL_QUADS, 0, 4);
If I comment that line out nothing happens, everything works fine. But when its uncommented I get the error.

Can anybody explain to me why this could happen? Its not even a heavy application or anything, its just a small little test program doing almost nothing.

Thanks in advance.

01-06-2014, 07:11 AM
Does this problem occurs even at FIRST function call or only after few/many of these calls? I'm asking this because if you pass ARRAY(s) by value (and not by reference, to a sub function which will execute glDrawArrays) in some languages it could generates out_of_memory error.

However please check OpenGL reference: http://www.opengl.org/sdk/docs/man4/xhtml/glDrawArrays.xml GL_QUADS is not more a supported value. Triangles are always preferred for the most of VGA/GPU architectures....

01-06-2014, 10:12 AM
Thank you for the reply. The error is generated the very first time I called glDrawArrays.
It has been fixed by now, but I did change quite a bit about the program, so I can not tell for sure what change fixed this behavior.
But I know for sure, that the error was only generated after the call to glDrawArrays since I was checking for errors after each and every gl method call.

When I use GL_QUADS the driver automatically splits the quad into 2 triangles. I know it would be better to use triangles directly, but this was just a short test program so I didnt care much about the performance.

01-06-2014, 02:50 PM
I think it would be useful to read more lines of code, especially those concerning VBO/Array creation.

Are you using VBOs? If yes: are you using interleaved vertices attributes (PositionNormalTexcoordColor|PositionNormalTexture Color|....etc...) in one single Array or one array for each attrib (Position, Normals, etc)?

Using VBO it's easy to get errors during glDraw*() functions if attrib arrays have different lengths/counts or if glVertexAttribPointer points to a null/invalid buffer position...