ImmediateMode< T > Class Template Reference

An immediate mode vertex array that you can write everyframe using a ImmBegin()/ImmVertex()/ImmEnd() OpenGL style interface. More...

List of all members.

Public Member Functions

 ImmediateMode (GraphicsContextAlpha gl, uint max_vertices, ushort[] indices, int vertices_per_primitive, int indices_per_primitive, params VertexFormat[] formats)
 ImmediateMode constructor.
void Dispose ()
 Dispose implementation.
void ImmBegin (DrawMode mode, uint max_vertices_intended)
 Begin a draw primitive.
void ImmVertex (T vertex)
 Add a vertex, must be called between ImmBegin and ImmEnd.
void ImmEnd ()
 End draw primitive and draw.
void ImmEndIndexing ()
 Special version of ImmEnd that uses the 'vertices_per_primitive' and 'indices_per_primitive' arguments passed to ImmediateMode's constructor.

Properties

bool Disposed [get]
 Return true if this object been disposed.
bool ImmActive [get]
 Return true if we are in the middle of an ImmBegin()/ImmEnd().
uint MaxVertices [get]
 Return the maximum (total) number of vertices we can add per frame.

Detailed Description

template<T>
class Sce::PlayStation::HighLevel::GameEngine2D::Base::ImmediateMode< T >

An immediate mode vertex array that you can write everyframe using a ImmBegin()/ImmVertex()/ImmEnd() OpenGL style interface.


Member Function Documentation

void ImmBegin ( DrawMode  mode,
uint  max_vertices_intended 
)

Begin a draw primitive.

Parameters:
modeThe draw primitive type.
max_vertices_intendedThe maximum number of vertices you intend to write.
ImmediateMode ( GraphicsContextAlpha  gl,
uint  max_vertices,
ushort[]  indices,
int  vertices_per_primitive,
int  indices_per_primitive,
params VertexFormat[]  formats 
)

ImmediateMode constructor.

If indices is not null, vertices_per_primitive and indices_per_primitive must follow the constraints below:

  • vertices_per_primitive must not be 0
  • indices_per_primitive must not be 0
  • max_vertices must be a multiple of vertices_per_primitive
  • indices.Length must be a multiple of indices_per_primitive
  • max_vertices / vertices_per_primitive must be equal to indices.Length / indices_per_primitive

If any of those constraints is not met, the constructor will assert.

Note that ImmediateMode relies on the frame counter incremented by Common.OnSwap(). In the context of using GameEngine2D.Director, Common.OnSwap() is already called inside Director.Instance.PostSwap().

But if you use ImmediateMode "stand alone" then you will need to call Common.OnSwap() yourself everyframe to make sure the GameEngine2D's frame counter gets increments (else you will get memory leaks.)

Parameters:
glThe core graphics context.
max_verticesThe maximum number of vertices you can have per frame.
indicesThe array of indices (can be null), assuming a static setup.
vertices_per_primitiveIf indices is not null, this must be set to the number of vertices each ImmBegin is expected to have. If indices is null, just set to 0.
indices_per_primitiveIf indices is not null, this must be set to the number of indices you want to draw for each primitive. If indices is null, just set to 0.
formatsThe vertex format, passed to VertexBuffer as it is.
void ImmEndIndexing ( )

Special version of ImmEnd that uses the 'vertices_per_primitive' and 'indices_per_primitive' arguments passed to ImmediateMode's constructor.

It is assumed that in that case all primitives consume the same amount of vertices.