Hello, I need to learn the proper usage for glClearBufferData for an application I'm creating. I've looked at the official documentation... which isn't very descriptive, mainly what I don't understand are the internalformat, format, and type parameters.
void glClearBufferData( GLenum target,
GLenum internalformat,
GLenum format,
GLenum type,
const void * data);
I have a buffer with a target and some data, and all the data are in float form. I want to clear it all out to 0. Question is, how? Which one do I specify that it's in floats? Internalformat? What about the format and type? I just want to clear out all the memory. I know to specify NULL for data... but what about format and type?
glClearBufferData- How to Use It?
Started by SHOKWAV, Dec 11 2012 07:24 PM
1 reply to this topic
Sponsor:
#2 Members - Reputation: 297
Posted 13 December 2012 - 11:57 AM
You can look through the http://www.opengl.or...ffer_object.txt document, they got some explanation there:
To fill all or part of an existing buffer object's data store with a constant value, call void ClearBufferSubData(enum target, enum internalformat, enum format, enum type, sizeiptr offset, sizeiptr size, const void * data); with <target> set to the target to which the destination buffer is bound. <target> must be one of the targets listed in Table 2.8. <internalformat> must be set to one of the format tokens listed in Table 3.15, "Internal formats for buffer textures". <format> and <type> specify the format and type of the source data and are interpreted as described in Section 3.7.2. <offset> set to the offset, measured in basic machine units, into the buffer object's data store from which to begin filling, and <size> set to the size, also in basic machine units, of the range to fill. Both <offset> and <range> must be multiples of the number of basic machine units per-element for that internal format specified by <internalformat>, otherwise the error INVALID_VALUE is generated. <data> is a pointer to an array of between one and four components containing the data to be used as the source of the constant fill value. The elements of <data> are converted by the GL into the format specified by <internalformat> in the manner described in section 2.3.1, and then used to fill the specified range of the destination buffer. If <data> is NULL, then the pointer is ignored and the sub-range of the buffer is filled with zeros. If <offset> or <size> is less than zero, or if <offset> + <size> is greater than the value of BUFFER_SIZE for the buffer bound to <target> then the error INVALID_VALUE is generated. The command An INVALID_OPERATION error is generated if any part of the specified range of the buffer bound to <target> is currently mapped. void ClearBufferData(enum target, enum internalformat, enum format, enum type, const void * data); is equivalent to calling ClearBufferSubData with <target>, <internalformat> and <data> as specified, with <offset> set to zero, and <size> set to the value of BUFFER_SIZE for the buffer bound to <target>.






