Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The simple answer is yes, you should create multiple vertex buffers, input layouts, shaders, etc. and set the appropriate ones before each corresponding draw call. This will work and is reasonably efficient (should be efficient enough for a 2D game on modern hardware).</p> <p>Things tend to get a bit more complicated in a full 3D game engine. Typically the rendering engine will have some additional internal levels of abstraction layered on top of primitive objects like vertex and index buffers, input layouts, shaders etc. </p> <p>A reasonably common simple way of structuring things is to have a Mesh class which knows about all of the vertex buffers, index buffers, input layouts, shaders, textures, etc. which make up a bit of a 3D model that can be drawn in a single draw call and is responsible for setting them all (often along with other bits of render state like blend modes, culling modes, etc.) and issuing the corresponding draw call.</p> <p>There is a cost associated with changing any device state and so rendering engines are often designed to try and sort all the objects that need drawing in a particular frame so as to minimize the number of state changes required. In the Dawn of War 2 renderer for example we sorted all of the mesh geometry so that we could draw e.g. all of the space marine helmets with minimal state changes required before drawing all of the space marine bodies with different vertex and index buffers, textures, etc. </p> <p>Modern 3D hardware and APIs have somewhat less overhead for changing state than in the past so sorting to minimize state changes is a bit less important than it once was but it is still common practice for games that need to get maximum performance on the PC.</p> <p>In a data driven rendering engine that supports a flexible lighting and material model along with skinned animation, terrain, particle systems, full screen effects, 2D UI, etc. a suitable design for managing all of the state required to draw the game objects and for sorting it so it can be drawn with maximum efficiency can get quite complex and there are many different approaches to structuring things. The code for everything that could be classed as 'renderer state management' often makes up a significant portion of the code in a typical rendering engine.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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