<ahref="#pub-methods">Public Member Functions</a>|
<ahref="#pub-static-methods">Static Public Member Functions</a>|
<ahref="#pri-static-methods">Static Private Member Functions</a>|
<ahref="classsf_1_1VertexBuffer-members.html">List of all members</a></div>
<divclass="headertitle">
<divclass="title">sf::VertexBuffer Class Reference<divclass="ingroups"><aclass="el"href="group__graphics.html">Graphics module</a></div></div></div>
</div><!--header-->
<divclass="contents">
<p><aclass="el"href="classsf_1_1Vertex.html"title="Define a point with color and texture coordinates. ">Vertex</a> buffer storage for one or more 2D primitives.
<areahref="classsf_1_1Drawable.html"title="Abstract base class for objects that can be drawn to a render target. "alt="sf::Drawable"shape="rect"coords="0,0,100,24"/>
<areahref="classsf_1_1GlResource.html"title="Base class for classes that require an OpenGL context. "alt="sf::GlResource"shape="rect"coords="110,0,210,24"/>
<trclass="memdesc:a3f51dcd61dac52be54ba7b22ebdea7c8"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Construct a <aclass="el"href="classsf_1_1VertexBuffer.html"title="Vertex buffer storage for one or more 2D primitives. ">VertexBuffer</a> with a specific PrimitiveType. <ahref="#a3f51dcd61dac52be54ba7b22ebdea7c8">More...</a><br/></td></tr>
<trclass="memdesc:af2dce0a43e061e5f91b97cf7267427e3"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Construct a <aclass="el"href="classsf_1_1VertexBuffer.html"title="Vertex buffer storage for one or more 2D primitives. ">VertexBuffer</a> with a specific usage specifier. <ahref="#af2dce0a43e061e5f91b97cf7267427e3">More...</a><br/></td></tr>
<trclass="memdesc:a326a5c89f1ba01b51b323535494434e8"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Construct a <aclass="el"href="classsf_1_1VertexBuffer.html"title="Vertex buffer storage for one or more 2D primitives. ">VertexBuffer</a> with a specific PrimitiveType and usage specifier. <ahref="#a326a5c89f1ba01b51b323535494434e8">More...</a><br/></td></tr>
<trclass="memdesc:aa68e128d59c7f7d5eb0d4d94125439a5"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Create the vertex buffer. <ahref="#aa68e128d59c7f7d5eb0d4d94125439a5">More...</a><br/></td></tr>
<trclass="memdesc:a6c534536ed186a2ad65e75484c8abafe"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Return the vertex count. <ahref="#a6c534536ed186a2ad65e75484c8abafe">More...</a><br/></td></tr>
<trclass="memdesc:ad100a5f578a91c49a9009e3c6956c82d"><tdclass="mdescLeft"> </td><tdclass="mdescRight">ServerUpdate the whole buffer from an array of vertices. <ahref="#ad100a5f578a91c49a9009e3c6956c82d">More...</a><br/></td></tr>
<trclass="memdesc:ae6c8649a64861507010d21e77fbd53fa"><tdclass="mdescLeft"> </td><tdclass="mdescRight">ServerUpdate a part of the buffer from an array of vertices. <ahref="#ae6c8649a64861507010d21e77fbd53fa">More...</a><br/></td></tr>
<trclass="memdesc:a41f8bbcf07f403e7fe29b1b905dc7544"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Copy the contents of another buffer into this buffer. <ahref="#a41f8bbcf07f403e7fe29b1b905dc7544">More...</a><br/></td></tr>
<trclass="memdesc:a812f98083da8f10361d457008bf9fa79"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Overload of assignment operator. <ahref="#a812f98083da8f10361d457008bf9fa79">More...</a><br/></td></tr>
<trclass="memdesc:a3954d696848dc4c921c15a6b4459c8e6"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Swap the contents of this vertex buffer with those of another. <ahref="#a3954d696848dc4c921c15a6b4459c8e6">More...</a><br/></td></tr>
<trclass="memdesc:a343fa0a240c91bc4203a6727fcd9b920"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Get the underlying OpenGL handle of the vertex buffer. <ahref="#a343fa0a240c91bc4203a6727fcd9b920">More...</a><br/></td></tr>
<trclass="memdesc:a7c429dbef94224a86d605cf4c68aa02d"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Set the type of primitives to draw. <ahref="#a7c429dbef94224a86d605cf4c68aa02d">More...</a><br/></td></tr>
<trclass="memdesc:a02061d85472ff69e7ad14dc72f8fcaa4"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Get the type of primitives drawn by the vertex buffer. <ahref="#a02061d85472ff69e7ad14dc72f8fcaa4">More...</a><br/></td></tr>
<trclass="memdesc:ace40070db1fccf12a025383b23e81cad"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Set the usage specifier of this vertex buffer. <ahref="#ace40070db1fccf12a025383b23e81cad">More...</a><br/></td></tr>
<trclass="memdesc:a5e36f2b3955bb35648c17550a9c096e1"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Get the usage specifier of this vertex buffer. <ahref="#a5e36f2b3955bb35648c17550a9c096e1">More...</a><br/></td></tr>
<trclass="memdesc:a1c623e9701b43125e4b3661bc0d0b65b"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Bind a vertex buffer for rendering. <ahref="#a1c623e9701b43125e4b3661bc0d0b65b">More...</a><br/></td></tr>
<trclass="memdesc:a6304bc4134dc0164dc94eff887b08847"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Tell whether or not the system supports vertex buffers. <ahref="#a6304bc4134dc0164dc94eff887b08847">More...</a><br/></td></tr>
<trclass="memdesc:ab171bdaf5eb36789da14b30a846db471"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Register a function to be called when a context is destroyed. <ahref="#ab171bdaf5eb36789da14b30a846db471">More...</a><br/></td></tr>
<divclass="textblock"><p><aclass="el"href="classsf_1_1Vertex.html"title="Define a point with color and texture coordinates. ">Vertex</a> buffer storage for one or more 2D primitives. </p>
<p><aclass="el"href="classsf_1_1VertexBuffer.html"title="Vertex buffer storage for one or more 2D primitives. ">sf::VertexBuffer</a> is a simple wrapper around a dynamic buffer of vertices and a primitives type.</p>
<p>Unlike <aclass="el"href="classsf_1_1VertexArray.html"title="Define a set of one or more 2D primitives. ">sf::VertexArray</a>, the vertex data is stored in graphics memory.</p>
<p>In situations where a large amount of vertex data would have to be transferred from system memory to graphics memory every frame, using <aclass="el"href="classsf_1_1VertexBuffer.html"title="Vertex buffer storage for one or more 2D primitives. ">sf::VertexBuffer</a> can help. By using a <aclass="el"href="classsf_1_1VertexBuffer.html"title="Vertex buffer storage for one or more 2D primitives. ">sf::VertexBuffer</a>, data that has not been changed between frames does not have to be re-transferred from system to graphics memory as would be the case with <aclass="el"href="classsf_1_1VertexArray.html"title="Define a set of one or more 2D primitives. ">sf::VertexArray</a>. If data transfer is a bottleneck, this can lead to performance gains.</p>
<p>Using <aclass="el"href="classsf_1_1VertexBuffer.html"title="Vertex buffer storage for one or more 2D primitives. ">sf::VertexBuffer</a>, the user also has the ability to only modify a portion of the buffer in graphics memory. This way, a large buffer can be allocated at the start of the application and only the applicable portions of it need to be updated during the course of the application. This allows the user to take full control of data transfers between system and graphics memory if they need to.</p>
<p>In special cases, the user can make use of multiple threads to update vertex data in multiple distinct regions of the buffer simultaneously. This might make sense when e.g. the position of multiple objects has to be recalculated very frequently. The computation load can be spread across multiple threads as long as there are no other data dependencies.</p>
<p>Simultaneous updates to the vertex buffer are not guaranteed to be carried out by the driver in any specific order. Updating the same region of the buffer from multiple threads will not cause undefined behaviour, however the final state of the buffer will be unpredictable.</p>
<p>Simultaneous updates of distinct non-overlapping regions of the buffer are also not guaranteed to complete in a specific order. However, in this case the user can make sure to synchronize the writer threads at well-defined points in their code. The driver will make sure that all pending data transfers complete before the vertex buffer is sourced by the rendering pipeline.</p>
<p>It inherits <aclass="el"href="classsf_1_1Drawable.html"title="Abstract base class for objects that can be drawn to a render target. ">sf::Drawable</a>, but unlike other drawables it is not transformable.</p>
<p>Example: </p><divclass="fragment"><divclass="line"><aclass="code"href="classsf_1_1Vertex.html">sf::Vertex</a> vertices[15];</div><divclass="line">...</div><divclass="line">sf::VertexBuffer triangles(<aclass="code"href="group__graphics.html#gga5ee56ac1339984909610713096283b1ba880a7aa72c20b9f9beb7eb64d2434670">sf::Triangles</a>);</div><divclass="line">triangles.create(15);</div><divclass="line">triangles.update(vertices);</div><divclass="line">...</div><divclass="line">window.draw(triangles);</div></div><!-- fragment --><dlclass="section see"><dt>See also</dt><dd><aclass="el"href="classsf_1_1Vertex.html"title="Define a point with color and texture coordinates. ">sf::Vertex</a>, <aclass="el"href="classsf_1_1VertexArray.html"title="Define a set of one or more 2D primitives. ">sf::VertexArray</a></dd></dl>
<pclass="definition">Definition at line <aclass="el"href="VertexBuffer_8hpp_source.html#l00046">46</a> of file <aclass="el"href="VertexBuffer_8hpp_source.html">VertexBuffer.hpp</a>.</p>
<p>If data is going to be updated once or more every frame, set the usage to Stream. If data is going to be set once and used for a long time without being modified, set the usage to Static. For everything else Dynamic should be a good compromise. </p>
<pclass="definition">Definition at line <aclass="el"href="VertexBuffer_8hpp_source.html#l00060">60</a> of file <aclass="el"href="VertexBuffer_8hpp_source.html">VertexBuffer.hpp</a>.</p>
</div>
</div>
<h2class="groupheader">Constructor & Destructor Documentation</h2>
<p>Construct a <aclass="el"href="classsf_1_1VertexBuffer.html"title="Vertex buffer storage for one or more 2D primitives. ">VertexBuffer</a> with a specific PrimitiveType. </p>
<p>Creates an empty vertex buffer and sets its primitive type to <code>type</code>.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">type</td><td>Type of primitive </td></tr>
<p>Construct a <aclass="el"href="classsf_1_1VertexBuffer.html"title="Vertex buffer storage for one or more 2D primitives. ">VertexBuffer</a> with a specific usage specifier. </p>
<p>Creates an empty vertex buffer and sets its usage to <code>usage</code>.</p>
<p>Construct a <aclass="el"href="classsf_1_1VertexBuffer.html"title="Vertex buffer storage for one or more 2D primitives. ">VertexBuffer</a> with a specific PrimitiveType and usage specifier. </p>
<p>Creates an empty vertex buffer and sets its primitive type to <code>type</code> and usage to <code>usage</code>.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">type</td><td>Type of primitive </td></tr>
<p>This function is not part of the graphics API, it mustn't be used when drawing SFML entities. It must be used only if you mix <aclass="el"href="classsf_1_1VertexBuffer.html"title="Vertex buffer storage for one or more 2D primitives. ">sf::VertexBuffer</a> with OpenGL code.</p>
<divclass="fragment"><divclass="line"><aclass="code"href="classsf_1_1VertexBuffer.html">sf::VertexBuffer</a> vb1, vb2;</div><divclass="line">...</div><divclass="line">sf::VertexBuffer::bind(&vb1);</div><divclass="line"><spanclass="comment">// draw OpenGL stuff that use vb1...</span></div><divclass="line"><aclass="code"href="classsf_1_1VertexBuffer.html#a1c623e9701b43125e4b3661bc0d0b65b">sf::VertexBuffer::bind</a>(&vb2);</div><divclass="line"><spanclass="comment">// draw OpenGL stuff that use vb2...</span></div><divclass="line"><aclass="code"href="classsf_1_1VertexBuffer.html#a1c623e9701b43125e4b3661bc0d0b65b">sf::VertexBuffer::bind</a>(NULL);</div><divclass="line"><spanclass="comment">// draw OpenGL stuff that use no vertex buffer...</span></div></div><!-- fragment --><dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">vertexBuffer</td><td>Pointer to the vertex buffer to bind, can be null to use no vertex buffer </td></tr>
<p>Creates the vertex buffer and allocates enough graphics memory to hold <code>vertexCount</code> vertices. Any previously allocated memory is freed in the process.</p>
<p>In order to deallocate previously allocated memory pass 0 as <code>vertexCount</code>. Don't forget to recreate with a non-zero value when graphics memory should be allocated again.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">vertexCount</td><td>Number of vertices worth of memory to allocate</td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>True if creation was successful </dd></dl>
<tdclass="memname">unsigned int sf::VertexBuffer::getNativeHandle </td>
<td>(</td>
<tdclass="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</div><divclass="memdoc">
<p>Get the underlying OpenGL handle of the vertex buffer. </p>
<p>You shouldn't need to use this function, unless you have very specific stuff to implement that SFML doesn't support, or implement a temporary workaround until a bug is fixed.</p>
<dlclass="section return"><dt>Returns</dt><dd>OpenGL handle of the vertex buffer or 0 if not yet created </dd></dl>
<p>Tell whether or not the system supports vertex buffers. </p>
<p>This function should always be called before using the vertex buffer features. If it returns false, then any attempt to use <aclass="el"href="classsf_1_1VertexBuffer.html"title="Vertex buffer storage for one or more 2D primitives. ">sf::VertexBuffer</a> will fail.</p>
<dlclass="section return"><dt>Returns</dt><dd>True if vertex buffers are supported, false otherwise </dd></dl>
<p>Set the usage specifier of this vertex buffer. </p>
<p>This function provides a hint about how this vertex buffer is going to be used in terms of data update frequency.</p>
<p>After changing the usage specifier, the vertex buffer has to be updated with new data for the usage specifier to take effect.</p>
<p>The default primitive type is <aclass="el"href="classsf_1_1VertexBuffer.html#a3a531528684e63ecb45edd51282f5cb7aeed06a391698772af58a9cfdff77deaf"title="Constantly changing data. ">sf::VertexBuffer::Stream</a>.</p>
<p><code>offset</code> is specified as the number of vertices to skip from the beginning of the buffer.</p>
<p>If <code>offset</code> is 0 and <code>vertexCount</code> is equal to the size of the currently created buffer, its whole contents are replaced.</p>
<p>If <code>offset</code> is 0 and <code>vertexCount</code> is greater than the size of the currently created buffer, a new buffer is created containing the vertex data.</p>
<p>If <code>offset</code> is 0 and <code>vertexCount</code> is less than the size of the currently created buffer, only the corresponding region is updated.</p>
<p>If <code>offset</code> is not 0 and <code>offset</code> + <code>vertexCount</code> is greater than the size of the currently created buffer, the update fails.</p>
<p>No additional check is performed on the size of the vertex array, passing invalid arguments will lead to undefined behavior.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">vertices</td><td>Array of vertices to copy to the buffer </td></tr>
<tr><tdclass="paramname">vertexCount</td><td>Number of vertices to copy </td></tr>
<tr><tdclass="paramname">offset</td><td>Offset in the buffer to copy to</td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>True if the update was successful </dd></dl>
<p>Copy the contents of another buffer into this buffer. </p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">vertexBuffer</td><td><aclass="el"href="classsf_1_1Vertex.html"title="Define a point with color and texture coordinates. ">Vertex</a> buffer whose contents to copy into this vertex buffer</td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>True if the copy was successful </dd></dl>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>