Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Does drawing a partially empty GL_ELEMENT_ARRAY_BUFFER work?

I create a GL_ARRAY_BUFFER and GL_ELEMENT_ARRAY_BUFFER and allocated space in both with glBufferData(null), then I glBufferSubData() some data into certain sections of the buffers, leaving some sections (not just at the end) null. Then I draw the entire GL_ELEMENT_ARRAY_BUFFER with glDrawElements(). Is leaving certain sections null like that allowed or does it have downsides?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

There’s no such thing as "partially empty". Those bytes exist and they have values. Those values are either undefined (aka: could be any value) or 0, depending on your drivers and the robust memory settings you may have used when creating your context.

Using undefined values is probably not helpful, as they could read past where you have meaningful buffer data. Or past the end of the buffer, which could straight-up crash the GPU.

So basically don’t do that. If you tell OpenGL to read some data, make sure that there is valid data to be read. There’s nothing wrong with issuing multiple draw commands that draw from sub-sections of the same buffer. Draw commands are only a performance problem if you make state changes between them.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading