"Initial commit to Gerrit"
[profile/ivi/cogl.git] / cogl / cogl-matrix-stack.h
1 /*
2  * Cogl
3  *
4  * An object oriented GL/GLES Abstraction/Utility Layer
5  *
6  * Copyright (C) 2009,2010 Intel Corporation.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library. If not, see
20  * <http://www.gnu.org/licenses/>.
21  *
22  *
23  *
24  * Authors:
25  *   Havoc Pennington <hp@pobox.com> for litl
26  *   Robert Bragg <robert@linux.intel.com>
27  */
28
29 #ifndef __COGL_MATRIX_STACK_H
30 #define __COGL_MATRIX_STACK_H
31
32 #include "cogl-matrix.h"
33 #include "cogl-context.h"
34
35 typedef struct _CoglMatrixStack CoglMatrixStack;
36
37 typedef struct
38 {
39   CoglMatrixStack *stack;
40   unsigned int age;
41   gboolean flushed_identity;
42   gboolean flipped;
43 } CoglMatrixStackCache;
44
45 typedef enum {
46   COGL_MATRIX_MODELVIEW,
47   COGL_MATRIX_PROJECTION,
48   COGL_MATRIX_TEXTURE
49 } CoglMatrixMode;
50
51 typedef void (* CoglMatrixStackFlushFunc) (CoglContext *context,
52                                            gboolean is_identity,
53                                            const CoglMatrix *matrix,
54                                            void *user_data);
55
56 CoglMatrixStack *
57 _cogl_matrix_stack_new (void);
58
59 void
60 _cogl_matrix_stack_push (CoglMatrixStack *stack);
61
62 void
63 _cogl_matrix_stack_pop (CoglMatrixStack *stack);
64
65 void
66 _cogl_matrix_stack_load_identity (CoglMatrixStack *stack);
67
68 void
69 _cogl_matrix_stack_scale (CoglMatrixStack *stack,
70                           float x,
71                           float y,
72                           float z);
73 void
74 _cogl_matrix_stack_translate (CoglMatrixStack *stack,
75                               float x,
76                               float y,
77                               float z);
78 void
79 _cogl_matrix_stack_rotate (CoglMatrixStack *stack,
80                            float angle,
81                            float x,
82                            float y,
83                            float z);
84 void
85 _cogl_matrix_stack_multiply (CoglMatrixStack *stack,
86                              const CoglMatrix *matrix);
87 void
88 _cogl_matrix_stack_frustum (CoglMatrixStack *stack,
89                             float left,
90                             float right,
91                             float bottom,
92                             float top,
93                             float z_near,
94                             float z_far);
95 void
96 _cogl_matrix_stack_perspective (CoglMatrixStack *stack,
97                                 float fov_y,
98                                 float aspect,
99                                 float z_near,
100                                 float z_far);
101 void
102 _cogl_matrix_stack_ortho (CoglMatrixStack *stack,
103                           float left,
104                           float right,
105                           float bottom,
106                           float top,
107                           float z_near,
108                           float z_far);
109 gboolean
110 _cogl_matrix_stack_get_inverse (CoglMatrixStack *stack,
111                                 CoglMatrix *inverse);
112 void
113 _cogl_matrix_stack_get (CoglMatrixStack *stack,
114                         CoglMatrix *matrix);
115 void
116 _cogl_matrix_stack_set (CoglMatrixStack *stack,
117                         const CoglMatrix *matrix);
118
119 void
120 _cogl_matrix_stack_flush_to_gl_builtins (CoglContext *ctx,
121                                          CoglMatrixStack *stack,
122                                          CoglMatrixMode mode,
123                                          gboolean disable_flip);
124
125 unsigned int
126 _cogl_matrix_stack_get_age (CoglMatrixStack *stack);
127
128 /* If this returns TRUE then the top of the matrix is definitely the
129    identity matrix. If it returns FALSE it may or may not be the
130    identity matrix but no expensive comparison is performed to verify
131    it. */
132 gboolean
133 _cogl_matrix_stack_has_identity_flag (CoglMatrixStack *stack);
134
135 gboolean
136 _cogl_matrix_stack_equal (CoglMatrixStack *stack0,
137                           CoglMatrixStack *stack1);
138
139 void
140 _cogl_matrix_stack_init_cache (CoglMatrixStackCache *cache);
141
142 gboolean
143 _cogl_matrix_stack_check_and_update_cache (CoglMatrixStack *stack,
144                                            CoglMatrixStackCache *cache,
145                                            gboolean flip);
146
147 void
148 _cogl_matrix_stack_destroy_cache (CoglMatrixStackCache *cache);
149
150 gboolean
151 _cogl_is_matrix_stack (void *object);
152
153 #endif /* __COGL_MATRIX_STACK_H */