From 6c8c0714f67866c42e1d7b4e1e5da60f16647f77 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Fri, 19 Mar 2010 09:30:59 +0000 Subject: [PATCH] cogl: adds convenience cogl_multiply_matrix function Quite often it's desirable to be able to multiply the current modelview matrix by an arbitrary matrix. Currently though you have to first explicitly call cogl_get_modelview_matrix to get the current modelview into a temporary variable, then you need to multiply it with your matrix using cogl_matrix_multiply and finally use cogl_set_modelview_matrix to make the result be the new modelview. This new convenience function lets more efficiently skip the first get and last set steps. --- cogl/cogl.c | 8 ++++++++ cogl/cogl.h | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/cogl/cogl.c b/cogl/cogl.c index 106c229c9..9632ce529 100644 --- a/cogl/cogl.c +++ b/cogl/cogl.c @@ -937,6 +937,14 @@ cogl_rotate (float angle, float x, float y, float z) _cogl_matrix_stack_rotate (modelview_stack, angle, x, y, z); } +void +cogl_multiply_matrix (const CoglMatrix *matrix) +{ + CoglMatrixStack *modelview_stack = + _cogl_framebuffer_get_modelview_stack (_cogl_get_framebuffer ()); + _cogl_matrix_stack_multiply (modelview_stack, matrix); +} + void cogl_perspective (float fov_y, float aspect, diff --git a/cogl/cogl.h b/cogl/cogl.h index 53ddec2de..b2e244736 100644 --- a/cogl/cogl.h +++ b/cogl/cogl.h @@ -347,6 +347,17 @@ cogl_rotate (float angle, float y, float z); +/** + * cogl_multiply_matrix: + * @matrix: the matrix to multiply with the current model-view + * + * Multiplies the current model-view matrix by the given matrix. + * + * Since: 1.4 + */ +void +cogl_multiply_matrix (const CoglMatrix *matrix); + /** * cogl_get_modelview_matrix: * @matrix: (out): return location for the model-view matrix