Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>With regards to your questions:</p> <blockquote> <ol> <li>OpenGL have Buffers, so, it is usefull to store geometry's data in a class? I can edit in live OpenGL buffers, right?</li> </ol> </blockquote> <p>This depends on how often you intend to update the data, and the type of GPU you're using. If you're using a discrete "desktop" GPU (e.g., NVIDIA or ATI/AMD), OpenGL buffers are allocated on the graphics card's memory, and editing (by calling <code>glMapBuffer</code> or vairants) a buffer usually requires either copying the data from the GPU back to the CPU's memory, or keeping a "shadow copy" of your data in the CPU which is sent to the GPU after editing. Either way, you will likely incur a delay by editing the data in the buffer.</p> <p>An alternative &mdash; and usually better &mdash; way to edit the data is to replace a portion of the buffer using <code>glBufferSubData</code>, which may help reduce the effects of mapping and unmapping the buffer for interactive editing. This call requires an array of data in CPU memory which will be copied to the GPU to replace the data in the buffer. The amount of data you can send with <code>glBufferSubData</code> must be less than the size of the original buffer.</p> <p>With respect to keeping data in a class, if you'll be changing the data often, then your best approach is probably to keep a local copy, and then <code>glBufferSubData</code> to send it to the GPU. </p> <blockquote> <ol> <li>OpenGL index buffers can handle GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT and GL_UNSIGNED_INT, in my class how can I manage this different types? Did I need to create one vector of unsigned int, one vector of short, …?</li> </ol> </blockquote> <p>No, you only need one buffer of the most appropriate type based on how many vertices you need to index. For example, you can only access 256 vertices using <code>GL_UNSIGNED_BYTE</code> indices.</p> <blockquote> <ol> <li>Is it useful to manage unsigned int, unsigned byte and unsigned short for indices? I'm asking that because storing just unsigned short would be less painfull and could allow small and big models.</li> </ol> </blockquote> <p>Once again, the data type you use for indices is really only important for how many vertices you want to access, so if <code>GLushort</code> is the best storage format, go for it. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload