Updating index buffers can only be done when you lock the buffer for writing; See section 2.4 Locking buffers for details. Locking returns a void pointer, which must be cast to the apropriate type; with index buffers this is either an unsigned short (for 16-bit indexes) or an unsigned long (for 32-bit indexes). For example: