4
* An object oriented GL/GLES Abstraction/Utility Layer
6
* Copyright (C) 2008,2009 Intel Corporation.
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.
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.
18
* You should have received a copy of the GNU Lesser General Public
19
* License along with this library; if not, write to the
20
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21
* Boston, MA 02111-1307, USA.
24
* Robert Bragg <robert@linux.intel.com>
27
#ifndef __COGL_MATERIAL_PRIVATE_H
28
#define __COGL_MATERIAL_PRIVATE_H
30
#include "cogl-material.h"
31
#include "cogl-matrix.h"
32
#include "cogl-handle.h"
36
typedef struct _CoglMaterial CoglMaterial;
37
typedef struct _CoglMaterialLayer CoglMaterialLayer;
39
typedef enum _CoglMaterialEqualFlags
41
/* Return FALSE if any component of either material isn't set to its
42
* default value. (Note: if the materials have corresponding flush
43
* options indicating that e.g. the material color won't be flushed then
44
* this will not assert a default color value.) */
45
COGL_MATERIAL_EQUAL_FLAGS_ASSERT_ALL_DEFAULTS = 1L<<0,
47
} CoglMaterialEqualFlags;
49
/* XXX: I don't think gtk-doc supports having private enums so these aren't
50
* bundled in with CoglMaterialLayerFlags */
51
typedef enum _CoglMaterialLayerPrivFlags
53
/* Ref: CoglMaterialLayerFlags
54
COGL_MATERIAL_LAYER_FLAG_HAS_USER_MATRIX = 1L<<0
56
COGL_MATERIAL_LAYER_FLAG_DIRTY = 1L<<1,
57
COGL_MATERIAL_LAYER_FLAG_DEFAULT_COMBINE = 1L<<2
58
} CoglMaterialLayerPrivFlags;
60
/* For tracking the state of a layer that's been flushed to OpenGL */
61
typedef struct _CoglLayerInfo
69
gboolean layer0_overridden;
72
struct _CoglMaterialLayer
74
CoglHandleObject _parent;
75
guint index; /*!< lowest index is blended first then others
78
CoglHandle texture; /*!< The texture for this layer, or COGL_INVALID_HANDLE
81
CoglMaterialFilter mag_filter;
82
CoglMaterialFilter min_filter;
84
/* Determines how the color of individual texture fragments
86
GLint texture_combine_rgb_func;
87
GLint texture_combine_rgb_src[3];
88
GLint texture_combine_rgb_op[3];
90
GLint texture_combine_alpha_func;
91
GLint texture_combine_alpha_src[3];
92
GLint texture_combine_alpha_op[3];
94
GLfloat texture_combine_constant[4];
96
/* TODO: Support purely GLSL based material layers */
101
typedef enum _CoglMaterialFlags
103
COGL_MATERIAL_FLAG_SHOWN_SAMPLER_WARNING = 1L<<0,
105
COGL_MATERIAL_FLAG_DEFAULT_COLOR = 1L<<1,
106
COGL_MATERIAL_FLAG_DEFAULT_GL_MATERIAL = 1L<<2,
107
COGL_MATERIAL_FLAG_DEFAULT_ALPHA_FUNC = 1L<<3,
108
COGL_MATERIAL_FLAG_ENABLE_BLEND = 1L<<4,
109
COGL_MATERIAL_FLAG_DEFAULT_BLEND = 1L<<5
114
CoglHandleObject _parent;
115
gulong journal_ref_count;
119
/* If no lighting is enabled; this is the basic material color */
122
/* Standard OpenGL lighting model attributes */
129
/* Determines what fragments are discarded based on their alpha */
130
CoglMaterialAlphaFunc alpha_func;
131
GLfloat alpha_func_reference;
133
/* Determines how this material is blended with other primitives */
134
#ifndef HAVE_COGL_GLES
135
GLenum blend_equation_rgb;
136
GLenum blend_equation_alpha;
137
GLint blend_src_factor_alpha;
138
GLint blend_dst_factor_alpha;
139
GLfloat blend_constant[4];
141
GLint blend_src_factor_rgb;
142
GLint blend_dst_factor_rgb;
149
* SECTION:cogl-material-internals
150
* @short_description: Functions for creating custom primitives that make use
151
* of Cogl materials for filling.
153
* Normally you shouldn't need to use this API directly, but if you need to
154
* developing a custom/specialised primitive - probably using raw OpenGL - then
155
* this API aims to expose enough of the material internals to support being
156
* able to fill your geometry according to a given Cogl material.
161
* cogl_material_get_cogl_enable_flags:
162
* @material: A CoglMaterial object
164
* This determines what flags need to be passed to cogl_enable before this
165
* material can be used. Normally you shouldn't need to use this function
166
* directly since Cogl will do this internally, but if you are developing
167
* custom primitives directly with OpenGL you may want to use this.
169
* Note: This API is hopfully just a stop-gap solution. Ideally cogl_enable
172
/* TODO: find a nicer solution! */
173
gulong _cogl_material_get_cogl_enable_flags (CoglHandle handle);
176
* CoglMaterialLayerFlags:
177
* @COGL_MATERIAL_LAYER_FLAG_USER_MATRIX: Means the user has supplied a
178
* custom texture matrix.
180
typedef enum _CoglMaterialLayerFlags
182
COGL_MATERIAL_LAYER_FLAG_HAS_USER_MATRIX = 1L<<0
183
} CoglMaterialLayerFlags;
184
/* XXX: NB: if you add flags here you will need to update
185
* CoglMaterialLayerPrivFlags!!! */
188
* cogl_material_layer_get_flags:
189
* @layer_handle: A CoglMaterialLayer layer handle
191
* This lets you get a number of flag attributes about the layer. Normally
192
* you shouldn't need to use this function directly since Cogl will do this
193
* internally, but if you are developing custom primitives directly with
194
* OpenGL you may need this.
196
gulong _cogl_material_layer_get_flags (CoglHandle layer_handle);
199
* CoglMaterialFlushFlag:
200
* @COGL_MATERIAL_FLUSH_FALLBACK_MASK: The fallback_layers member is set to
201
* a guint32 mask of the layers that can't be supported with the user
202
* supplied texture and need to be replaced with fallback textures. (1 =
203
* fallback, and the least significant bit = layer 0)
204
* @COGL_MATERIAL_FLUSH_DISABLE_MASK: The disable_layers member is set to
205
* a guint32 mask of the layers that you want to completly disable
206
* texturing for (1 = fallback, and the least significant bit = layer 0)
207
* @COGL_MATERIAL_FLUSH_LAYER0_OVERRIDE: The layer0_override_texture member is
208
* set to a GLuint OpenGL texture name to override the texture used for
209
* layer 0 of the material. This is intended for dealing with sliced
210
* textures where you will need to point to each of the texture slices in
211
* turn when drawing your geometry. Passing a value of 0 is the same as
212
* not passing the option at all.
213
* @COGL_MATERIAL_FLUSH_SKIP_GL_COLOR: When flushing the GL state for the
214
* material don't call glColor.
216
typedef enum _CoglMaterialFlushFlag
218
COGL_MATERIAL_FLUSH_FALLBACK_MASK = 1L<<0,
219
COGL_MATERIAL_FLUSH_DISABLE_MASK = 1L<<1,
220
COGL_MATERIAL_FLUSH_LAYER0_OVERRIDE = 1L<<2,
221
COGL_MATERIAL_FLUSH_SKIP_GL_COLOR = 1L<<3
222
} CoglMaterialFlushFlag;
225
* CoglMaterialFlushOptions:
228
typedef struct _CoglMaterialFlushOptions
230
CoglMaterialFlushFlag flags;
232
guint32 fallback_layers;
233
guint32 disable_layers;
234
GLuint layer0_override_texture;
235
} CoglMaterialFlushOptions;
239
void _cogl_material_get_colorubv (CoglHandle handle,
242
void _cogl_material_flush_gl_state (CoglHandle material,
243
CoglMaterialFlushOptions *options);
245
gboolean _cogl_material_equal (CoglHandle material0_handle,
246
CoglMaterialFlushOptions *material0_flush_options,
247
CoglHandle material1_handle,
248
CoglMaterialFlushOptions *material1_flush_options);
250
CoglHandle _cogl_material_journal_ref (CoglHandle material_handle);
251
void _cogl_material_journal_unref (CoglHandle material_handle);
254
#endif /* __COGL_MATERIAL_PRIVATE_H */