diff --git a/cogl-material.h b/cogl-material.h index d69ae276c..cf364d3fa 100644 --- a/cogl-material.h +++ b/cogl-material.h @@ -365,92 +365,6 @@ void cogl_material_set_alpha_test_function (CoglHandle material, CoglMaterialAlphaFunc alpha_func, float alpha_reference); -/** - * CoglMaterialBlendFactor: - * @COGL_MATERIAL_BLEND_FACTOR_ZERO: (0, 0, 0, 0) - * @COGL_MATERIAL_BLEND_FACTOR_ONE: (1, 1, 1, 1) - * @COGL_MATERIAL_BLEND_FACTOR_SRC_COLOR: (Rs, Gs, Bs, As) - * @COGL_MATERIAL_BLEND_FACTOR_DST_COLOR: (Rd, Gd, Bd, Ad) - * @COGL_MATERIAL_BLEND_FACTOR_ONE_MINUS_SRC_COLOR: (1-Rs, 1-Gs, 1-Bs, 1-As) - * @COGL_MATERIAL_BLEND_FACTOR_ONE_MINUS_DST_COLOR: (1-Rd, 1-Gd, 1-Bd, 1-Ad) - * @COGL_MATERIAL_BLEND_FACTOR_SRC_ALPHA: (As, As, As, As) - * @COGL_MATERIAL_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA: (1-As, 1-As, 1-As, 1-As) - * @COGL_MATERIAL_BLEND_FACTOR_DST_ALPHA: (Ad, Ad, Ad, Ad) - * @COGL_MATERIAL_BLEND_FACTOR_ONE_MINUS_DST_ALPHA: (1-Ad, 1-Ad, 1-Ad, 1-Ad) - * @COGL_MATERIAL_BLEND_FACTOR_CONSTANT: (Rc, Gc, Bc, Ac) - * @COGL_MATERIAL_BLEND_FACTOR_ONE_MINUS_CONSTANT: (1-Rc, 1-Gc, 1-Bc, 1-Ac) - * @COGL_MATERIAL_BLEND_FACTOR_CONSTANT_ALPHA: (Ac, Ac, Ac, Ac) - * @COGL_MATERIAL_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA: (1-Ac, 1-Ac, 1-Ac, 1-Ac) - * @COGL_MATERIAL_BLEND_FACTOR_SRC_ALPHA_SATURATE: (f,f,f,1) where f=MIN(As,1-Ad) - * - * - * A fixed function is used to determine the blended color, which is based on - * the incoming source color of your fragment (Rs, Gs, Bs, As), a source - * factor (Sr, Sg, Sb, Sa), a destination color (Rd, Rg, Rb, Ra) and - * a destination factor (Dr, Dg, Db, Da), and is given by these equations: - * - * - * R = Rs*Sr + Rd*Dr - * G = Gs*Sg + Gd*Dg - * B = Bs*Sb + Bd*Db - * A = As*Sa + Ad*Da - * - * - * All factors have a range [0, 1] - * - * The factors are selected with the following constants: - */ -typedef enum _CoglMaterialBlendFactor -{ - COGL_MATERIAL_BLEND_FACTOR_ZERO = GL_ZERO, - COGL_MATERIAL_BLEND_FACTOR_ONE = GL_ONE, - COGL_MATERIAL_BLEND_FACTOR_SRC_COLOR = GL_SRC_COLOR, - COGL_MATERIAL_BLEND_FACTOR_DST_COLOR = GL_DST_COLOR, - COGL_MATERIAL_BLEND_FACTOR_ONE_MINUS_SRC_COLOR = GL_ONE_MINUS_SRC_COLOR, - COGL_MATERIAL_BLEND_FACTOR_ONE_MINUS_DST_COLOR = GL_ONE_MINUS_DST_COLOR, - COGL_MATERIAL_BLEND_FACTOR_SRC_ALPHA = GL_SRC_ALPHA, - COGL_MATERIAL_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA = GL_ONE_MINUS_SRC_ALPHA, - COGL_MATERIAL_BLEND_FACTOR_DST_ALPHA = GL_DST_ALPHA, - COGL_MATERIAL_BLEND_FACTOR_ONE_MINUS_DST_ALPHA = GL_ONE_MINUS_DST_ALPHA, -#ifdef HAVE_COGL_GL - COGL_MATERIAL_BLEND_FACTOR_CONSTANT = GL_CONSTANT_COLOR, - COGL_MATERIAL_BLEND_FACTOR_ONE_MINUS_CONSTANT = - GL_ONE_MINUS_CONSTANT_COLOR, - COGL_MATERIAL_BLEND_FACTOR_CONSTANT_ALPHA = GL_CONSTANT_ALPHA, - COGL_MATERIAL_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA = - GL_ONE_MINUS_CONSTANT_ALPHA, -#endif - COGL_MATERIAL_BLEND_FACTOR_SRC_ALPHA_SATURATE = GL_SRC_ALPHA_SATURATE, -} CoglMaterialBlendFactor; - -/** - * cogl_material_set_blend_factors: - * @material: A CoglMaterial object - * @src_factor: Chooses the @CoglMaterialBlendFactor you want plugged in to - * the blend equation. - * @dst_factor: Chooses the @CoglMaterialBlendFactor you want plugged in to - * the blend equation. - * - * This function lets you control how primitives using this material will get - * blended with the contents of your framebuffer. The blended RGBA components - * are calculated like this: - * - * (RsSr+RdDr, GsSg+GdDg, BsSb+BsSb, AsSa+AdDa) - * - * Where (Rs,Gs,Bs,As) represents your source - material- color, - * (Rd,Gd,Bd,Ad) represents your destination - framebuffer - color, - * (Sr,Sg,Sb,Sa) represents your source blend factor and - * (Dr,Dg,Db,Da) represents you destination blend factor. - * - * All factors lie in the range [0,1] and incoming color components are also - * normalized to the range [0,1] - * - * Since 1.0 - */ -void cogl_material_set_blend_factors (CoglHandle material, - CoglMaterialBlendFactor src_factor, - CoglMaterialBlendFactor dst_factor); - /** * cogl_material_set_blend: * @material: A CoglMaterial object @@ -675,212 +589,6 @@ void cogl_material_set_layer_combine_constant (CoglHandle ma int layer_index, CoglColor *constant); -/** - * CoglMaterialLayerCombineFunc: - * @COGL_MATERIAL_LAYER_COMBINE_FUNC_REPLACE: Arg0 - * @COGL_MATERIAL_LAYER_COMBINE_FUNC_MODULATE: Arg0 x Arg1 - * @COGL_MATERIAL_LAYER_COMBINE_FUNC_ADD: Arg0 + Arg1 - * @COGL_MATERIAL_LAYER_COMBINE_FUNC_ADD_SIGNED: Arg0 + Arg1 - 0.5 - * @COGL_MATERIAL_LAYER_COMBINE_FUNC_INTERPOLATE: Arg0 x Arg + Arg1 x (1-Arg2) - * @COGL_MATERIAL_LAYER_COMBINE_FUNC_SUBTRACT: Arg0 - Arg1 - * @COGL_MATERIAL_LAYER_COMBINE_FUNC_DOT3_RGB: 4 x ((Arg0r - 0.5) x (Arg1r - 0.5)) + - * @COGL_MATERIAL_LAYER_COMBINE_FUNC_DOT3_RGBA: ((Arg0b - 0.5) x (Arg1b - 0.5)) + - * - * A material may comprise of 1 or more layers that can be combined using a - * number of different functions. By default layers are modulated, which is - * to say the components of the current source layer S are simply multipled - * together with the combined results of the previous layer P like this: - * - * - * (Rs*Rp, Gs*Gp, Bs*Bp, As*Ap) - * - * - * For more advanced techniques, Cogl exposes the fixed function texture - * combining capabilities of your GPU to give you greater control. - */ -typedef enum _CoglMaterialLayerCombineFunc -{ - COGL_MATERIAL_LAYER_COMBINE_FUNC_REPLACE = CGL_REPLACE, - COGL_MATERIAL_LAYER_COMBINE_FUNC_MODULATE = CGL_MODULATE, - COGL_MATERIAL_LAYER_COMBINE_FUNC_ADD = CGL_ADD, - COGL_MATERIAL_LAYER_COMBINE_FUNC_ADD_SIGNED = CGL_ADD_SIGNED, - COGL_MATERIAL_LAYER_COMBINE_FUNC_INTERPOLATE = CGL_INTERPOLATE, - COGL_MATERIAL_LAYER_COMBINE_FUNC_SUBTRACT = CGL_SUBTRACT, - COGL_MATERIAL_LAYER_COMBINE_FUNC_DOT3_RGB = CGL_DOT3_RGB, - COGL_MATERIAL_LAYER_COMBINE_FUNC_DOT3_RGBA = CGL_DOT3_RGBA -} CoglMaterialLayerCombineFunc; - -/** - * CoglMaterialLayerCombineChannels: - * @COGL_MATERIAL_LAYER_COMBINE_CHANNELS_RGB: Modify the function or argument - * src/op for the RGB components of a - * layer - * @COGL_MATERIAL_LAYER_COMBINE_CHANNELS_ALPHA: Modify the function or argument - * src/op for the Alpha component of a - * layer - * @COGL_MATERIAL_LAYER_COMBINE_CHANNELS_RGBA: Modify the function or argument - * src/op for all the components of a - * layer - * - * Cogl optionally lets you describe 2 seperate combine modes for a single - * layer; 1 for the RGB components, and 1 for the Alpha component, so in this - * case you would repeat the 3 steps documented with the - * @cogl_material_set_layer_combine_function function for each channel - * selector. - * - * (Note: you can't have different modes for each channel, so if you need more - * control you will need to use a glsl fragment shader) - */ -typedef enum _CoglMaterialLayerCombineChannels -{ - COGL_MATERIAL_LAYER_COMBINE_CHANNELS_RGB, - COGL_MATERIAL_LAYER_COMBINE_CHANNELS_ALPHA, - COGL_MATERIAL_LAYER_COMBINE_CHANNELS_RGBA -} CoglMaterialLayerCombineChannels; - -/** - * cogl_material_set_layer_combine_function: - * @material: A CoglMaterial object - * @layer_index: Specifies the layer whos combine mode you want to modify - * @channels: Specifies which channels combine mode you want to modify - * (RGB, ALPHA, or RGBA) - * @func: Specifies the function you want to use for combining fragments - * of the specified layer with the results of previously combined - * layers. - * - * There are three basic steps to describing how a layer should be combined: - * - * - * Choose a function. - * - * - * Specify the source color for each argument of the chosen function. (Note - * the functions don't all take the same number of arguments) - * - * - * Specify an operator for each argument that can modify the corresponding - * source color before the function is applied. - * - * - * - * Cogl optionally lets you describe 2 seperate combine modes for a single - * layer; 1 for the RGB components, and 1 for the Alpha component, so in this - * case you would repeat the 3 steps for each channel selector. - * - * (Note: you can't have different modes for each channel, so if you need more - * control you will need to use a glsl fragment shader) - * - * For example here is how you could elect to use the ADD function for all - * components of layer 1 in your material: - * - * //Step 1: Choose a function. Note the ADD function takes 2 arguments... - * cogl_material_set_layer_combine_function (material, - * 1, - * COGL_MATERIAL_LAYER_COMBINE_CHANNELS_RGBA) - * COGL_MATERIAL_LAYER_COMBINE_FUNC_ADD); - * //Step 2: Specify the source color for the 2 ADD function arguments... - * cogl_material_set_layer_combine_arg_src (material, - * 1,//layer index - * 0,//argument index - * COGL_MATERIAL_LAYER_COMBINE_SRC_PREVIOUS); - * cogl_material_set_layer_combine_arg_src (material, - * 1,//layer index - * 1,//argument index - * COGL_MATERIAL_LAYER_COMBINE_CHANNELS_RGBA) - * COGL_MATERIAL_LAYER_COMBINE_SRC_TEXTURE); - * //Step 3: Specify the operators used to modify the arguments... - * cogl_material_set_layer_combine_arg_op (material, - * 1,//layer index - * 0,//argument index - * COGL_MATERIAL_LAYER_COMBINE_CHANNELS_RGBA, - * COGL_MATERIAL_LAYER_COMBINE_OP_SRC_COLOR); - * cogl_material_set_layer_combine_arg_op (material, - * 1,//layer index - * 1,//argument index - * COGL_MATERIAL_LAYER_COMBINE_CHANNELS_RGBA, - * COGL_MATERIAL_LAYER_COMBINE_OP_SRC_COLOR); - * - */ -void cogl_material_set_layer_combine_function (CoglHandle material, - int layer_index, - CoglMaterialLayerCombineChannels channels, - CoglMaterialLayerCombineFunc func); - -/** - * CoglMaterialLayerCombineSrc: - * @COGL_MATERIAL_LAYER_COMBINE_SRC_TEXTURE: The fragment color of the current texture layer - * @COGL_MATERIAL_LAYER_COMBINE_SRC_TEXTURE0: The fragment color of texture unit 0 - * @COGL_MATERIAL_LAYER_COMBINE_SRC_TEXTURE1: The fragment color of texture unit 1 - * @COGL_MATERIAL_LAYER_COMBINE_SRC_TEXTURE2: The fragment color of texture unit 2..7 - * @COGL_MATERIAL_LAYER_COMBINE_SRC_CONSTANT: A fixed constant color (TODO: no API yet to specify the actual color!) - * @COGL_MATERIAL_LAYER_COMBINE_SRC_PRIMARY_COLOR: The basic color of the primitive ignoring texturing - * @COGL_MATERIAL_LAYER_COMBINE_SRC_PREVIOUS: The result of combining all previous layers - * - * Note for the constants @COGL_MATERIAL_LAYER_COMBINE_SRC_TEXTURE0..n the - * numbers may not correspond to the indices you choose for your layers since - * your layer indices don't need to be contiguous. If you need to use these - * it would probably be sensible to ensure the layer indices do infact - * correspond. - */ -typedef enum _CoglMaterialLayerCombineSrc -{ - COGL_MATERIAL_LAYER_COMBINE_SRC_TEXTURE = GL_TEXTURE, - - /* Can we find a nicer way... */ - COGL_MATERIAL_LAYER_COMBINE_SRC_TEXTURE0 = GL_TEXTURE0, - COGL_MATERIAL_LAYER_COMBINE_SRC_TEXTURE1 = GL_TEXTURE1, - COGL_MATERIAL_LAYER_COMBINE_SRC_TEXTURE2 = GL_TEXTURE2, - COGL_MATERIAL_LAYER_COMBINE_SRC_TEXTURE3 = GL_TEXTURE3, - COGL_MATERIAL_LAYER_COMBINE_SRC_TEXTURE4 = GL_TEXTURE4, - COGL_MATERIAL_LAYER_COMBINE_SRC_TEXTURE5 = GL_TEXTURE5, - COGL_MATERIAL_LAYER_COMBINE_SRC_TEXTURE6 = GL_TEXTURE6, - COGL_MATERIAL_LAYER_COMBINE_SRC_TEXTURE7 = GL_TEXTURE7, - /* .. who would ever need more than 8 texture layers.. :-) */ - - COGL_MATERIAL_LAYER_COMBINE_SRC_CONSTANT = CGL_CONSTANT, - COGL_MATERIAL_LAYER_COMBINE_SRC_PRIMARY_COLOR = CGL_PRIMARY_COLOR, - COGL_MATERIAL_LAYER_COMBINE_SRC_PREVIOUS = CGL_PREVIOUS -} CoglMaterialLayerCombineSrc; - -/** - * cogl_material_set_layer_combine_arg_src: - * @material: A CoglMaterial object - * @layer_index: - * @argument: - * @channels: - * @src: - * - */ -void cogl_material_set_layer_combine_arg_src (CoglHandle material, - int layer_index, - int argument, - CoglMaterialLayerCombineChannels channels, - CoglMaterialLayerCombineSrc src); - -typedef enum _CoglMaterialLayerCombineOp -{ - COGL_MATERIAL_LAYER_COMBINE_OP_SRC_COLOR = GL_SRC_COLOR, - COGL_MATERIAL_LAYER_COMBINE_OP_ONE_MINUS_SRC_COLOR = GL_ONE_MINUS_SRC_COLOR, - - COGL_MATERIAL_LAYER_COMBINE_OP_SRC_ALPHA = GL_SRC_ALPHA, - COGL_MATERIAL_LAYER_COMBINE_OP_ONE_MINUS_SRC_ALPHA = GL_ONE_MINUS_SRC_ALPHA -} CoglMaterialLayerCombineOp; - -/** - * cogl_material_set_layer_combine_arg_op: - * @material: A CoglMaterial object - * @layer_index: - * @argument: - * @channels: - * @op: - * - */ -void cogl_material_set_layer_combine_arg_op (CoglHandle material, - int layer_index, - int argument, - CoglMaterialLayerCombineChannels channels, - CoglMaterialLayerCombineOp op); - /** * cogl_material_set_layer_matrix: * @material: A CoglMaterial object @@ -892,7 +600,6 @@ void cogl_material_set_layer_matrix (CoglHandle material, int layer_index, CoglMatrix *matrix); - /** * SECTION:cogl-material-internals * @short_description: Functions for creating custom primitives that make use diff --git a/common/cogl-material-private.h b/common/cogl-material-private.h index f0e053eff..5d3cecfd9 100644 --- a/common/cogl-material-private.h +++ b/common/cogl-material-private.h @@ -70,13 +70,13 @@ struct _CoglMaterialLayer /* Determines how the color of individual texture fragments * are calculated. */ - CoglMaterialLayerCombineFunc texture_combine_rgb_func; - CoglMaterialLayerCombineSrc texture_combine_rgb_src[3]; - CoglMaterialLayerCombineOp texture_combine_rgb_op[3]; + GLint texture_combine_rgb_func; + GLint texture_combine_rgb_src[3]; + GLint texture_combine_rgb_op[3]; - CoglMaterialLayerCombineFunc texture_combine_alpha_func; - CoglMaterialLayerCombineSrc texture_combine_alpha_src[3]; - CoglMaterialLayerCombineOp texture_combine_alpha_op[3]; + GLint texture_combine_alpha_func; + GLint texture_combine_alpha_src[3]; + GLint texture_combine_alpha_op[3]; GLfloat texture_combine_constant[4]; @@ -119,12 +119,12 @@ struct _CoglMaterial #ifndef HAVE_COGL_GLES GLenum blend_equation_rgb; GLenum blend_equation_alpha; - CoglMaterialBlendFactor blend_dst_factor_alpha; - CoglMaterialBlendFactor blend_src_factor_alpha; + GLint blend_src_factor_alpha; + GLint blend_dst_factor_alpha; GLfloat blend_constant[4]; #endif - CoglMaterialBlendFactor blend_src_factor_rgb; - CoglMaterialBlendFactor blend_dst_factor_rgb; + GLint blend_src_factor_rgb; + GLint blend_dst_factor_rgb; GList *layers; }; diff --git a/common/cogl-material.c b/common/cogl-material.c index cc1ae0691..aef14cd00 100644 --- a/common/cogl-material.c +++ b/common/cogl-material.c @@ -500,8 +500,8 @@ arg_to_gl_blend_factor (CoglBlendStringArgument *arg) void setup_blend_state (CoglBlendStringStatement *statement, GLenum *blend_equation, - CoglMaterialBlendFactor *blend_src_factor, - CoglMaterialBlendFactor *blend_dst_factor) + GLint *blend_src_factor, + GLint *blend_dst_factor) { #ifndef HAVE_COGL_GLES switch (statement->function->type) @@ -600,26 +600,6 @@ cogl_material_set_blend_constant (CoglHandle handle, #endif } -void -cogl_material_set_blend_factors (CoglHandle handle, - CoglMaterialBlendFactor src_factor, - CoglMaterialBlendFactor dst_factor) -{ - CoglMaterial *material; - - g_return_if_fail (cogl_is_material (handle)); - - material = _cogl_material_pointer_from_handle (handle); - material->blend_src_factor_rgb = src_factor; - material->blend_dst_factor_rgb = dst_factor; -#ifndef HAVE_COGL_GLES - material->blend_src_factor_alpha = src_factor; - material->blend_dst_factor_alpha = dst_factor; -#endif - - material->flags &= ~COGL_MATERIAL_FLAG_DEFAULT_BLEND_FUNC; -} - /* Asserts that a layer corresponding to the given index exists. If no * match is found, then a new empty layer is added. */ @@ -659,21 +639,16 @@ _cogl_material_get_layer (CoglMaterial *material, /* Choose the same default combine mode as OpenGL: * MODULATE(PREVIOUS[RGBA],TEXTURE[RGBA]) */ - layer->texture_combine_rgb_func = COGL_MATERIAL_LAYER_COMBINE_FUNC_MODULATE; - layer->texture_combine_rgb_src[0] = COGL_MATERIAL_LAYER_COMBINE_SRC_PREVIOUS; - layer->texture_combine_rgb_src[1] = COGL_MATERIAL_LAYER_COMBINE_SRC_TEXTURE; - layer->texture_combine_rgb_op[0] = COGL_MATERIAL_LAYER_COMBINE_OP_SRC_COLOR; - layer->texture_combine_rgb_op[1] = COGL_MATERIAL_LAYER_COMBINE_OP_SRC_COLOR; - layer->texture_combine_alpha_func = - COGL_MATERIAL_LAYER_COMBINE_FUNC_MODULATE; - layer->texture_combine_alpha_src[0] = - COGL_MATERIAL_LAYER_COMBINE_SRC_PREVIOUS; - layer->texture_combine_alpha_src[1] = - COGL_MATERIAL_LAYER_COMBINE_SRC_TEXTURE; - layer->texture_combine_alpha_op[0] = - COGL_MATERIAL_LAYER_COMBINE_OP_SRC_ALPHA; - layer->texture_combine_alpha_op[1] = - COGL_MATERIAL_LAYER_COMBINE_OP_SRC_ALPHA; + layer->texture_combine_rgb_func = GL_MODULATE; + layer->texture_combine_rgb_src[0] = GL_PREVIOUS; + layer->texture_combine_rgb_src[1] = GL_TEXTURE; + layer->texture_combine_rgb_op[0] = GL_SRC_COLOR; + layer->texture_combine_rgb_op[1] = GL_SRC_COLOR; + layer->texture_combine_alpha_func = GL_MODULATE; + layer->texture_combine_alpha_src[0] = GL_PREVIOUS; + layer->texture_combine_alpha_src[1] = GL_TEXTURE; + layer->texture_combine_alpha_op[0] = GL_SRC_ALPHA; + layer->texture_combine_alpha_op[1] = GL_SRC_ALPHA; cogl_matrix_init_identity (&layer->matrix); @@ -728,9 +703,9 @@ cogl_material_set_layer (CoglHandle material_handle, static void setup_texture_combine_state (CoglBlendStringStatement *statement, - CoglMaterialLayerCombineFunc *texture_combine_func, - CoglMaterialLayerCombineSrc *texture_combine_src, - CoglMaterialLayerCombineOp *texture_combine_op) + GLint *texture_combine_func, + GLint *texture_combine_src, + GLint *texture_combine_op) { int i; @@ -889,109 +864,6 @@ cogl_material_set_layer_combine_constant (CoglHandle handle, layer->flags &= ~COGL_MATERIAL_LAYER_FLAG_DEFAULT_COMBINE; } -void -cogl_material_set_layer_combine_function ( - CoglHandle handle, - gint layer_index, - CoglMaterialLayerCombineChannels channels, - CoglMaterialLayerCombineFunc func) -{ - CoglMaterial *material; - CoglMaterialLayer *layer; - gboolean set_alpha_func = FALSE; - gboolean set_rgb_func = FALSE; - - g_return_if_fail (cogl_is_material (handle)); - - material = _cogl_material_pointer_from_handle (handle); - layer = _cogl_material_get_layer (material, layer_index, TRUE); - - if (channels == COGL_MATERIAL_LAYER_COMBINE_CHANNELS_RGBA) - set_alpha_func = set_rgb_func = TRUE; - else if (channels == COGL_MATERIAL_LAYER_COMBINE_CHANNELS_RGB) - set_rgb_func = TRUE; - else if (channels == COGL_MATERIAL_LAYER_COMBINE_CHANNELS_ALPHA) - set_alpha_func = TRUE; - - if (set_rgb_func) - layer->texture_combine_rgb_func = func; - if (set_alpha_func) - layer->texture_combine_alpha_func = func; - - layer->flags |= COGL_MATERIAL_LAYER_FLAG_DIRTY; - layer->flags &= ~COGL_MATERIAL_LAYER_FLAG_DEFAULT_COMBINE; -} - -void -cogl_material_set_layer_combine_arg_src ( - CoglHandle handle, - gint layer_index, - gint argument, - CoglMaterialLayerCombineChannels channels, - CoglMaterialLayerCombineSrc src) -{ - CoglMaterial *material; - CoglMaterialLayer *layer; - gboolean set_arg_alpha_src = FALSE; - gboolean set_arg_rgb_src = FALSE; - - g_return_if_fail (cogl_is_material (handle)); - g_return_if_fail (argument >=0 && argument <= 3); - - material = _cogl_material_pointer_from_handle (handle); - layer = _cogl_material_get_layer (material, layer_index, TRUE); - - if (channels == COGL_MATERIAL_LAYER_COMBINE_CHANNELS_RGBA) - set_arg_alpha_src = set_arg_rgb_src = TRUE; - else if (channels == COGL_MATERIAL_LAYER_COMBINE_CHANNELS_RGB) - set_arg_rgb_src = TRUE; - else if (channels == COGL_MATERIAL_LAYER_COMBINE_CHANNELS_ALPHA) - set_arg_alpha_src = TRUE; - - if (set_arg_rgb_src) - layer->texture_combine_rgb_src[argument] = src; - if (set_arg_alpha_src) - layer->texture_combine_alpha_src[argument] = src; - - layer->flags |= COGL_MATERIAL_LAYER_FLAG_DIRTY; - layer->flags &= ~COGL_MATERIAL_LAYER_FLAG_DEFAULT_COMBINE; -} - -void -cogl_material_set_layer_combine_arg_op ( - CoglHandle material_handle, - gint layer_index, - gint argument, - CoglMaterialLayerCombineChannels channels, - CoglMaterialLayerCombineOp op) -{ - CoglMaterial *material; - CoglMaterialLayer *layer; - gboolean set_arg_alpha_op = FALSE; - gboolean set_arg_rgb_op = FALSE; - - g_return_if_fail (cogl_is_material (material_handle)); - g_return_if_fail (argument >=0 && argument <= 3); - - material = _cogl_material_pointer_from_handle (material_handle); - layer = _cogl_material_get_layer (material, layer_index, TRUE); - - if (channels == COGL_MATERIAL_LAYER_COMBINE_CHANNELS_RGBA) - set_arg_alpha_op = set_arg_rgb_op = TRUE; - else if (channels == COGL_MATERIAL_LAYER_COMBINE_CHANNELS_RGB) - set_arg_rgb_op = TRUE; - else if (channels == COGL_MATERIAL_LAYER_COMBINE_CHANNELS_ALPHA) - set_arg_alpha_op = TRUE; - - if (set_arg_rgb_op) - layer->texture_combine_rgb_op[argument] = op; - if (set_arg_alpha_op) - layer->texture_combine_alpha_op[argument] = op; - - layer->flags |= COGL_MATERIAL_LAYER_FLAG_DIRTY; - layer->flags &= ~COGL_MATERIAL_LAYER_FLAG_DEFAULT_COMBINE; -} - void cogl_material_set_layer_matrix (CoglHandle material_handle, gint layer_index, @@ -1119,20 +991,20 @@ cogl_material_layer_get_flags (CoglHandle layer_handle) } static guint -get_n_args_for_combine_func (CoglMaterialLayerCombineFunc func) +get_n_args_for_combine_func (GLint func) { switch (func) { - case COGL_MATERIAL_LAYER_COMBINE_FUNC_REPLACE: + case GL_REPLACE: return 1; - case COGL_MATERIAL_LAYER_COMBINE_FUNC_MODULATE: - case COGL_MATERIAL_LAYER_COMBINE_FUNC_ADD: - case COGL_MATERIAL_LAYER_COMBINE_FUNC_ADD_SIGNED: - case COGL_MATERIAL_LAYER_COMBINE_FUNC_SUBTRACT: - case COGL_MATERIAL_LAYER_COMBINE_FUNC_DOT3_RGB: - case COGL_MATERIAL_LAYER_COMBINE_FUNC_DOT3_RGBA: + case GL_MODULATE: + case GL_ADD: + case GL_ADD_SIGNED: + case GL_SUBTRACT: + case GL_DOT3_RGB: + case GL_DOT3_RGBA: return 2; - case COGL_MATERIAL_LAYER_COMBINE_FUNC_INTERPOLATE: + case GL_INTERPOLATE: return 3; } return 0; diff --git a/doc/reference/cogl/cogl-sections.txt b/doc/reference/cogl/cogl-sections.txt index ca7664132..3b32cda5b 100644 --- a/doc/reference/cogl/cogl-sections.txt +++ b/doc/reference/cogl/cogl-sections.txt @@ -349,22 +349,13 @@ cogl_material_set_specular cogl_material_get_specular cogl_material_set_shininess cogl_material_get_shininess - CoglMaterialAlphaFunc cogl_material_set_alpha_test_function CoglMaterialBlendFactor -cogl_material_set_blend_factors cogl_material_set_blend cogl_material_set_blend_constant cogl_material_set_layer cogl_material_remove_layer -CoglMaterialLayerCombineFunc -cogl_material_set_layer_combine_function -CoglMaterialLayerCombineChannels -CoglMaterialLayerCombineSrc -cogl_material_set_layer_combine_arg_src -CoglMaterialLayerCombineOp -cogl_material_set_layer_combine_arg_op cogl_material_set_layer_combine cogl_material_set_layer_combine_constant cogl_material_set_layer_matrix @@ -372,8 +363,6 @@ cogl_material_set_layer_matrix CoglMaterial CoglMaterialFlags CoglMaterialLayerPrivFlags -cogl_material_set_layer_alpha_combine -cogl_material_set_layer_rgb_combine