简体   繁体   中英

How to render only a part of EBO in OpenGL?

I have VAO with bound VBO and EBO. Previously I've just been rendering it with glDrawElements( GL_TRIANGLES, EBO_size, GL_UNSIGNED_INT, 0 ) . But now I wanna draw it in parts, changing some uniforms in-between. Aka if I have 36 indices in EBO; I might wanna draw 18, change the uniform, and draw the remaining 18.

I tried glDrawRangeElements , but its start and end parameters are just hints for which indices will be used. glDrawArrays ignores the EBO and draws from the VBO directly.

glDrawElements void* indices parameter is actually a starting offset in bytes. And as you know, GLsizei count is the amount of elements to draw (not in bytes!)

For example, this would draw an EBO of 36 indices in two parts:

glDrawElements( GL_TRIANGLES, 18, GL_UNSIGNED_INT, (void*)(0) )
glDrawElements( GL_TRIANGLES, 18, GL_UNSIGNED_INT, (void*)(18*sizeof(unsigned int)) )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM