An immediate mode vertex array that you can write everyframe using a ImmBegin()/ImmVertex()/ImmEnd() OpenGL style interface. More...
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. |
An immediate mode vertex array that you can write everyframe using a ImmBegin()/ImmVertex()/ImmEnd() OpenGL style interface.
void ImmBegin | ( | DrawMode | mode, |
uint | max_vertices_intended | ||
) |
Begin a draw primitive.
mode | The draw primitive type. |
max_vertices_intended | The 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:
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.)
gl | The core graphics context. |
max_vertices | The maximum number of vertices you can have per frame. |
indices | The array of indices (can be null), assuming a static setup. |
vertices_per_primitive | If 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_primitive | If 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. |
formats | The 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.