mirror of
https://github.com/brl/mutter.git
synced 2024-12-24 12:02:04 +00:00
a05c701e6b
Once the GLES2 wrapper is removed we won't be able to upload the matrices with the fixed function API any more. The fixed function API gives a global state for setting the matrix but if a custom shader uniform is used for the matrices then the state is per program. _cogl_matrix_stack_flush_to_gl is called in a few places and it is assumed the current pipeline doesn't need to be flushed before it is called. To allow these semantics to continue to work, on GLES2 the matrix flush now just stores a reference to the matrix stack in the CoglContext. A pre_paint virtual is added to the progend which is called whenever a pipeline is flushed, even if the same pipeline was flushed already. This gives the GLSL progend a chance to upload the matrices to the uniforms. The combined modelview/projection matrix is only calculated if it is used. The generated programs end up never using the modelview or projection matrix so it usually only has to upload the combined matrix. When a matrix stack is flushed a reference is taked to it by the pipeline progend and the age is stored so that if the same state is used with the same program again then we don't need to reupload the uniform.
131 lines
4.1 KiB
C
131 lines
4.1 KiB
C
/*
|
|
* Cogl
|
|
*
|
|
* An object oriented GL/GLES Abstraction/Utility Layer
|
|
*
|
|
* Copyright (C) 2009,2010 Intel Corporation.
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library. If not, see
|
|
* <http://www.gnu.org/licenses/>.
|
|
*
|
|
*
|
|
*
|
|
* Authors:
|
|
* Havoc Pennington <hp@pobox.com> for litl
|
|
* Robert Bragg <robert@linux.intel.com>
|
|
*/
|
|
|
|
#ifndef __COGL_MATRIX_STACK_H
|
|
#define __COGL_MATRIX_STACK_H
|
|
|
|
#include "cogl-matrix.h"
|
|
|
|
typedef struct _CoglMatrixStack CoglMatrixStack;
|
|
|
|
typedef enum {
|
|
COGL_MATRIX_MODELVIEW,
|
|
COGL_MATRIX_PROJECTION,
|
|
COGL_MATRIX_TEXTURE
|
|
} CoglMatrixMode;
|
|
|
|
typedef void (* CoglMatrixStackFlushFunc) (gboolean is_identity,
|
|
const CoglMatrix *matrix,
|
|
void *user_data);
|
|
|
|
CoglMatrixStack *
|
|
_cogl_matrix_stack_new (void);
|
|
|
|
void
|
|
_cogl_matrix_stack_push (CoglMatrixStack *stack);
|
|
|
|
void
|
|
_cogl_matrix_stack_pop (CoglMatrixStack *stack);
|
|
|
|
void
|
|
_cogl_matrix_stack_load_identity (CoglMatrixStack *stack);
|
|
|
|
void
|
|
_cogl_matrix_stack_scale (CoglMatrixStack *stack,
|
|
float x,
|
|
float y,
|
|
float z);
|
|
void
|
|
_cogl_matrix_stack_translate (CoglMatrixStack *stack,
|
|
float x,
|
|
float y,
|
|
float z);
|
|
void
|
|
_cogl_matrix_stack_rotate (CoglMatrixStack *stack,
|
|
float angle,
|
|
float x,
|
|
float y,
|
|
float z);
|
|
void
|
|
_cogl_matrix_stack_multiply (CoglMatrixStack *stack,
|
|
const CoglMatrix *matrix);
|
|
void
|
|
_cogl_matrix_stack_frustum (CoglMatrixStack *stack,
|
|
float left,
|
|
float right,
|
|
float bottom,
|
|
float top,
|
|
float z_near,
|
|
float z_far);
|
|
void
|
|
_cogl_matrix_stack_perspective (CoglMatrixStack *stack,
|
|
float fov_y,
|
|
float aspect,
|
|
float z_near,
|
|
float z_far);
|
|
void
|
|
_cogl_matrix_stack_ortho (CoglMatrixStack *stack,
|
|
float left,
|
|
float right,
|
|
float bottom,
|
|
float top,
|
|
float z_near,
|
|
float z_far);
|
|
gboolean
|
|
_cogl_matrix_stack_get_inverse (CoglMatrixStack *stack,
|
|
CoglMatrix *inverse);
|
|
void
|
|
_cogl_matrix_stack_get (CoglMatrixStack *stack,
|
|
CoglMatrix *matrix);
|
|
void
|
|
_cogl_matrix_stack_set (CoglMatrixStack *stack,
|
|
const CoglMatrix *matrix);
|
|
void
|
|
_cogl_matrix_stack_flush_to_gl (CoglMatrixStack *stack,
|
|
CoglMatrixMode mode);
|
|
void
|
|
_cogl_matrix_stack_dirty (CoglMatrixStack *stack);
|
|
|
|
unsigned int
|
|
_cogl_matrix_stack_get_age (CoglMatrixStack *stack);
|
|
|
|
/* If this returns TRUE then the top of the matrix is definitely the
|
|
identity matrix. If it returns FALSE it may or may not be the
|
|
identity matrix but no expensive comparison is performed to verify
|
|
it. */
|
|
gboolean
|
|
_cogl_matrix_stack_has_identity_flag (CoglMatrixStack *stack);
|
|
|
|
void
|
|
_cogl_matrix_stack_prepare_for_flush (CoglMatrixStack *stack,
|
|
CoglMatrixMode mode,
|
|
CoglMatrixStackFlushFunc callback,
|
|
void *user_data);
|
|
|
|
#endif /* __COGL_MATRIX_STACK_H */
|