CoglMatrixState *flushed_state;
};
-
+/* XXX: this doesn't initialize the matrix! */
static CoglMatrixState*
_cogl_matrix_state_new (void)
{
CoglMatrixState *state;
- state = g_slice_new0 (CoglMatrixState);
-
- /* load identity */
- cogl_matrix_init_identity (&state->matrix);
-
- /* state->push_count defaults to 0 */
+ state = g_slice_new (CoglMatrixState);
+ state->push_count = 0;
return state;
}
return stack->stack->data;
}
-static CoglMatrixState*
-_cogl_matrix_stack_top_mutable (CoglMatrixStack *stack)
+static CoglMatrixState *
+_cogl_matrix_stack_top_mutable (CoglMatrixStack *stack,
+ gboolean initialize)
{
CoglMatrixState *state;
CoglMatrixState *new_top;
new_top = _cogl_matrix_state_new ();
- new_top->matrix = state->matrix;
-
- if (stack->flushed_state == state)
+ if (initialize)
{
- stack->flushed_state = new_top;
+ new_top->matrix = state->matrix;
+
+ if (stack->flushed_state == state)
+ stack->flushed_state = new_top;
}
- stack->stack =
- g_slist_prepend (stack->stack,
- new_top);
+ stack->stack = g_slist_prepend (stack->stack, new_top);
return new_top;
}
CoglMatrixState *state;
stack = g_slice_new0 (CoglMatrixStack);
+
state = _cogl_matrix_state_new ();
- stack->stack =
- g_slist_prepend (stack->stack,
- state);
+ cogl_matrix_init_identity (&state->matrix);
+
+ stack->stack = g_slist_prepend (stack->stack, state);
return stack;
}
{
CoglMatrixState *state;
- state = _cogl_matrix_stack_top_mutable (stack);
+ /* XXX: In this case an uninitialized top is acceptable */
+ state = _cogl_matrix_stack_top_mutable (stack, FALSE);
cogl_matrix_init_identity (&state->matrix);
/* mark dirty */
{
CoglMatrixState *state;
- state = _cogl_matrix_stack_top_mutable (stack);
+ state = _cogl_matrix_stack_top_mutable (stack, TRUE);
cogl_matrix_scale (&state->matrix, x, y, z);
/* mark dirty */
stack->flushed_state = NULL;
{
CoglMatrixState *state;
- state = _cogl_matrix_stack_top_mutable (stack);
+ state = _cogl_matrix_stack_top_mutable (stack, TRUE);
cogl_matrix_translate (&state->matrix, x, y, z);
/* mark dirty */
stack->flushed_state = NULL;
{
CoglMatrixState *state;
- state = _cogl_matrix_stack_top_mutable (stack);
+ state = _cogl_matrix_stack_top_mutable (stack, TRUE);
cogl_matrix_rotate (&state->matrix, angle, x, y, z);
/* mark dirty */
stack->flushed_state = NULL;
{
CoglMatrixState *state;
- state = _cogl_matrix_stack_top_mutable (stack);
+ state = _cogl_matrix_stack_top_mutable (stack, TRUE);
cogl_matrix_multiply (&state->matrix, &state->matrix, matrix);
/* mark dirty */
stack->flushed_state = NULL;
{
CoglMatrixState *state;
- state = _cogl_matrix_stack_top_mutable (stack);
+ state = _cogl_matrix_stack_top_mutable (stack, TRUE);
cogl_matrix_frustum (&state->matrix,
left, right, bottom, top,
z_near, z_far);
{
CoglMatrixState *state;
- state = _cogl_matrix_stack_top_mutable (stack);
+ state = _cogl_matrix_stack_top_mutable (stack, TRUE);
cogl_matrix_perspective (&state->matrix,
fov_y, aspect, z_near, z_far);
/* mark dirty */
{
CoglMatrixState *state;
- state = _cogl_matrix_stack_top_mutable (stack);
+ state = _cogl_matrix_stack_top_mutable (stack, TRUE);
cogl_matrix_ortho (&state->matrix,
left, right, bottom, top, z_near, z_far);
/* mark dirty */
{
CoglMatrixState *state;
- state = _cogl_matrix_stack_top_mutable (stack);
+ state = _cogl_matrix_stack_top_mutable (stack, TRUE);
state->matrix = *matrix;
/* mark dirty */
stack->flushed_state = NULL;