source: OGRE/trunk/ogrenew/Docs/manual/manual_50.html @ 692

Revision 692, 6.3 KB checked in by mattausch, 18 years ago (diff)

adding ogre 1.2 and dependencies

Line 
1<HTML>
2<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
3<!-- Created on , 12 2006 by texi2html 1.64 -->
4<!--
5Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
6            Karl Berry  <karl@freefriends.org>
7            Olaf Bachmann <obachman@mathematik.uni-kl.de>
8            and many others.
9Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de>
10Send bugs and suggestions to <texi2html@mathematik.uni-kl.de>
11 
12-->
13<HEAD>
14<TITLE>OGRE Manual v1.2.0 ('Dagon'): Vertex Buffer Bindings</TITLE>
15
16<META NAME="description" CONTENT="OGRE Manual v1.2.0 ('Dagon'): Vertex Buffer Bindings">
17<META NAME="keywords" CONTENT="OGRE Manual v1.2.0 ('Dagon'): Vertex Buffer Bindings">
18<META NAME="resource-type" CONTENT="document">
19<META NAME="distribution" CONTENT="global">
20<META NAME="Generator" CONTENT="texi2html 1.64">
21<LINK TYPE="text/css" rel="stylesheet" href="../style.css"> 
22</HEAD>
23
24<BODY LANG="" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
25
26<A NAME="SEC241"></A>
27<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
28<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_49.html#SEC239"> &lt; </A>]</TD>
29<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_47.html#SEC237"> Up </A>]</TD>
30<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_51.html#SEC244"> &gt; </A>]</TD>
31<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="index.html#SEC_Top">Top</A>]</TD>
32<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_toc.html#SEC_Contents">Contents</A>]</TD>
33<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
34<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_abt.html#SEC_About"> ? </A>]</TD>
35</TR></TABLE>
36<HR SIZE=1>
37<H3> 5.6.3 Vertex Buffer Bindings </H3>
38<!--docid::SEC241::-->
39Vertex buffer bindings are about associating a vertex buffer with a source index used in <A HREF="manual_49.html#SEC239">5.6.2 Vertex Declarations</A>.
40<A NAME="SEC242"></A>
41<H3> Creating the Vertex Buffer </H3>
42<!--docid::SEC242::-->
43Firstly, lets look at how you create a vertex buffer:
44<TABLE><tr><td>&nbsp;</td><td class=example><pre>HardwareVertexBufferSharedPtr vbuf =
45        HardwareBufferManager::getSingleton().createVertexBuffer(
46                3*sizeof(Real), // size of one whole vertex
47                numVertices, // number of vertices
48                HardwareBuffer::HBU_STATIC_WRITE_ONLY, // usage
49                false); // no shadow buffer
50</pre></td></tr></table><P>
51
52Notice that we use <A HREF="manual_42.html#SEC231">5.1 The Hardware Buffer Manager</A> to create our vertex buffer, and that a class called HardwareVertexBufferSharedPtr is returned from the method, rather than a raw pointer. This is because vertex buffers are reference counted - you are able to use a single vertex buffer as a source for multiple pieces of geometry therefore a standard pointer would not be good enough, because you would not know when all the different users of it had finished with it. The HardwareVertexBufferSharedPtr class manages its own destruction by keeping a reference count of the number of times it is being used - when the last HardwareVertexBufferSharedPtr is destroyed, the buffer itself automatically destroys itself.<BR><BR>
53</P><P>
54
55The parameters to the creation of a vertex buffer are as follows:
56<DL COMPACT>
57<DT>vertexSize
58<DD>The size in bytes of a whole vertex in this buffer. A vertex may include multiple elements, and in fact the contents of the vertex data may be reinterpreted by different vertex declarations if you wish. Therefore you must tell the buffer manager how large a whole vertex is, but not the internal format of the vertex, since that is down to the declaration to interpret. In the above example, the size is set to the size of 3 floating point values - this would be enough to hold a standard 3D position or normal, or a 3D texture coordinate, per vertex.
59<DT>numVertices
60<DD>The number of vertices in this buffer. Remember, not all the vertices have to be used at once - it can be beneficial to create large buffers which are shared between many chunks of geometry because changing vertex buffer bindings is a render state switch, and those are best minimised.
61<DT>usage
62<DD>This tells the system how you intend to use the buffer. See section <A HREF="manual_43.html#SEC232">5.2 Buffer Usage</A>
63<DT>useShadowBuffer
64<DD>Tells the system whether you want this buffer backed by a system-memory copy. See section <A HREF="manual_44.html#SEC233">5.3 Shadow Buffers</A>
65</DL>
66<P>
67
68<A NAME="SEC243"></A>
69<H3> Binding the Vertex Buffer </H3>
70<!--docid::SEC243::-->
71The second part of the process is to bind this buffer which you have created to a source index. To do this, you call:
72<TABLE><tr><td>&nbsp;</td><td class=example><pre>vertexBufferBinding-&#62;setBinding(0, vbuf);
73</pre></td></tr></table>This results in the vertex buffer you created earlier being bound to source index 0, so any vertex element which is pulling its data from source index 0 will retrieve data from this buffer. <BR><BR>
74There are also methods for retrieving buffers from the binding data - see the API reference for full details.
75<P>
76
77<A NAME="Updating Vertex Buffers"></A>
78<HR SIZE=1>
79<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
80<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_49.html#SEC239"> &lt; </A>]</TD>
81<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_47.html#SEC237"> Up </A>]</TD>
82<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_51.html#SEC244"> &gt; </A>]</TD>
83<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="index.html#SEC_Top">Top</A>]</TD>
84<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_toc.html#SEC_Contents">Contents</A>]</TD>
85<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
86<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_abt.html#SEC_About"> ? </A>]</TD>
87</TR></TABLE>
88<BR> 
89<FONT SIZE="-1">
90This document was generated
91by <I>Steve Streeting</I> on <I>, 12 2006</I>
92using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
93"><I>texi2html</I></A>
94
95</BODY>
96</HTML>
Note: See TracBrowser for help on using the repository browser.