switch (src)
{
- case GL_TEXTURE:
+ case COGL_PIPELINE_COMBINE_SOURCE_TEXTURE:
arg->type = COGL_PIPELINE_FRAGEND_ARBFP_ARG_TYPE_TEXTURE;
arg->name = "texel%d";
arg->texture_unit = _cogl_pipeline_layer_get_unit_index (layer);
cogl_texture_get_gl_texture (texture, NULL, &gl_target);
setup_texture_source (arbfp_program_state, arg->texture_unit, gl_target);
break;
- case GL_CONSTANT:
+ case COGL_PIPELINE_COMBINE_SOURCE_CONSTANT:
{
int unit_index = _cogl_pipeline_layer_get_unit_index (layer);
UnitState *unit_state = &arbfp_program_state->unit_state[unit_index];
arg->constant_id = unit_state->constant_id;
break;
}
- case GL_PRIMARY_COLOR:
+ case COGL_PIPELINE_COMBINE_SOURCE_PRIMARY_COLOR:
arg->type = COGL_PIPELINE_FRAGEND_ARBFP_ARG_TYPE_SIMPLE;
arg->name = "fragment.color.primary";
break;
- case GL_PREVIOUS:
+ case COGL_PIPELINE_COMBINE_SOURCE_PREVIOUS:
arg->type = COGL_PIPELINE_FRAGEND_ARBFP_ARG_TYPE_SIMPLE;
if (_cogl_pipeline_layer_get_unit_index (layer) == 0)
arg->name = "fragment.color.primary";
switch (op)
{
- case GL_SRC_COLOR:
+ case COGL_PIPELINE_COMBINE_OP_SRC_COLOR:
break;
- case GL_ONE_MINUS_SRC_COLOR:
+ case COGL_PIPELINE_COMBINE_OP_ONE_MINUS_SRC_COLOR:
g_string_append_printf (arbfp_program_state->source,
"SUB tmp%d, one, ",
arg_index);
arg->name = tmp_name[arg_index];
arg->swizzle = "";
break;
- case GL_SRC_ALPHA:
+ case COGL_PIPELINE_COMBINE_OP_SRC_ALPHA:
/* avoid a swizzle if we know RGB are going to be masked
* in the end anyway */
if (mask != COGL_BLEND_STRING_CHANNEL_MASK_ALPHA)
arg->swizzle = ".a";
break;
- case GL_ONE_MINUS_SRC_ALPHA:
+ case COGL_PIPELINE_COMBINE_OP_ONE_MINUS_SRC_ALPHA:
g_string_append_printf (arbfp_program_state->source,
"SUB tmp%d, one, ",
arg_index);
switch (function)
{
- case GL_ADD:
+ case COGL_PIPELINE_COMBINE_FUNC_ADD:
g_string_append_printf (arbfp_program_state->source,
"ADD_SAT output%s, ",
mask_name);
break;
- case GL_MODULATE:
+ case COGL_PIPELINE_COMBINE_FUNC_MODULATE:
/* Note: no need to saturate since we can assume operands
* have values in the range [0,1] */
g_string_append_printf (arbfp_program_state->source, "MUL output%s, ",
mask_name);
break;
- case GL_REPLACE:
+ case COGL_PIPELINE_COMBINE_FUNC_REPLACE:
/* Note: no need to saturate since we can assume operand
* has a value in the range [0,1] */
g_string_append_printf (arbfp_program_state->source, "MOV output%s, ",
mask_name);
break;
- case GL_SUBTRACT:
+ case COGL_PIPELINE_COMBINE_FUNC_SUBTRACT:
g_string_append_printf (arbfp_program_state->source,
"SUB_SAT output%s, ",
mask_name);
break;
- case GL_ADD_SIGNED:
+ case COGL_PIPELINE_COMBINE_FUNC_ADD_SIGNED:
g_string_append_printf (arbfp_program_state->source, "ADD tmp3%s, ",
mask_name);
append_arg (arbfp_program_state->source, &args[0]);
mask_name);
n_args = 0;
break;
- case GL_DOT3_RGB:
+ case COGL_PIPELINE_COMBINE_FUNC_DOT3_RGB:
/* These functions are the same except that GL_DOT3_RGB never
* updates the alpha channel.
*
* an RGBA mask and we end up ignoring any separate alpha channel
* function.
*/
- case GL_DOT3_RGBA:
+ case COGL_PIPELINE_COMBINE_FUNC_DOT3_RGBA:
{
const char *tmp4 = "tmp4";
n_args = 0;
}
break;
- case GL_INTERPOLATE:
+ case COGL_PIPELINE_COMBINE_FUNC_INTERPOLATE:
/* Note: no need to saturate since we can assume operands
* have values in the range [0,1] */
append_masked_combine (CoglPipeline *arbfp_authority,
CoglPipelineLayer *layer,
CoglBlendStringChannelMask mask,
- GLint function,
- GLint *src,
- GLint *op)
+ CoglPipelineCombineFunc function,
+ CoglPipelineCombineSource *src,
+ CoglPipelineCombineOp *op)
{
int i;
int n_args;
big_state->texture_combine_rgb_src,
big_state->texture_combine_rgb_op);
}
- else if (big_state->texture_combine_rgb_func == GL_DOT3_RGBA)
+ else if (big_state->texture_combine_rgb_func ==
+ COGL_PIPELINE_COMBINE_FUNC_DOT3_RGBA)
{
/* GL_DOT3_RGBA Is a bit weird as a GL_COMBINE_RGB function
* since if you use it, it overrides your ALPHA function...
add_arg (GlslShaderState *glsl_shader_state,
CoglPipeline *pipeline,
CoglPipelineLayer *layer,
- GLint src,
- GLenum operand,
+ CoglPipelineCombineSource src,
+ CoglPipelineCombineOp operand,
const char *swizzle)
{
GString *shader_source = glsl_shader_state->source;
g_string_append_c (shader_source, '(');
- if (operand == GL_ONE_MINUS_SRC_COLOR || operand == GL_ONE_MINUS_SRC_ALPHA)
+ if (operand == COGL_PIPELINE_COMBINE_OP_ONE_MINUS_SRC_COLOR ||
+ operand == COGL_PIPELINE_COMBINE_OP_ONE_MINUS_SRC_ALPHA)
g_string_append_printf (shader_source,
"vec4(1.0, 1.0, 1.0, 1.0).%s - ",
swizzle);
/* If the operand is reading from the alpha then replace the swizzle
with the same number of copies of the alpha */
- if (operand == GL_SRC_ALPHA || operand == GL_ONE_MINUS_SRC_ALPHA)
+ if (operand == COGL_PIPELINE_COMBINE_OP_SRC_ALPHA ||
+ operand == COGL_PIPELINE_COMBINE_OP_ONE_MINUS_SRC_ALPHA)
{
alpha_swizzle[strlen (swizzle)] = '\0';
swizzle = alpha_swizzle;
switch (src)
{
- case GL_TEXTURE:
+ case COGL_PIPELINE_COMBINE_SOURCE_TEXTURE:
add_texture_lookup (glsl_shader_state,
pipeline,
layer,
swizzle);
break;
- case GL_CONSTANT:
+ case COGL_PIPELINE_COMBINE_SOURCE_CONSTANT:
add_constant_lookup (glsl_shader_state,
pipeline,
layer,
swizzle);
break;
- case GL_PREVIOUS:
+ case COGL_PIPELINE_COMBINE_SOURCE_PREVIOUS:
if (_cogl_pipeline_layer_get_unit_index (layer) > 0)
{
g_string_append_printf (shader_source, "cogl_color_out.%s", swizzle);
break;
}
/* flow through */
- case GL_PRIMARY_COLOR:
+ case COGL_PIPELINE_COMBINE_SOURCE_PRIMARY_COLOR:
g_string_append_printf (shader_source, "cogl_color_in.%s", swizzle);
break;
default:
- if (src >= GL_TEXTURE0 && src < GL_TEXTURE0 + 32)
+ if (src >= COGL_PIPELINE_COMBINE_SOURCE_TEXTURE0 &&
+ src < COGL_PIPELINE_COMBINE_SOURCE_TEXTURE0 + 32)
{
FindPipelineLayerData data;
- data.unit_index = src - GL_TEXTURE0;
+ data.unit_index = src - COGL_PIPELINE_COMBINE_SOURCE_TEXTURE0;
data.layer = layer;
_cogl_pipeline_foreach_layer_internal (pipeline,
append_masked_combine (CoglPipeline *pipeline,
CoglPipelineLayer *layer,
const char *swizzle,
- GLint function,
- GLint *src,
- GLint *op)
+ CoglPipelineCombineFunc function,
+ CoglPipelineCombineSource *src,
+ CoglPipelineCombineOp *op)
{
GlslShaderState *glsl_shader_state = get_glsl_shader_state (pipeline);
GString *shader_source = glsl_shader_state->source;
switch (function)
{
- case GL_REPLACE:
+ case COGL_PIPELINE_COMBINE_FUNC_REPLACE:
add_arg (glsl_shader_state, pipeline, layer,
src[0], op[0], swizzle);
break;
- case GL_MODULATE:
+ case COGL_PIPELINE_COMBINE_FUNC_MODULATE:
add_arg (glsl_shader_state, pipeline, layer,
src[0], op[0], swizzle);
g_string_append (shader_source, " * ");
src[1], op[1], swizzle);
break;
- case GL_ADD:
+ case COGL_PIPELINE_COMBINE_FUNC_ADD:
add_arg (glsl_shader_state, pipeline, layer,
src[0], op[0], swizzle);
g_string_append (shader_source, " + ");
src[1], op[1], swizzle);
break;
- case GL_ADD_SIGNED:
+ case COGL_PIPELINE_COMBINE_FUNC_ADD_SIGNED:
add_arg (glsl_shader_state, pipeline, layer,
src[0], op[0], swizzle);
g_string_append (shader_source, " + ");
swizzle);
break;
- case GL_SUBTRACT:
+ case COGL_PIPELINE_COMBINE_FUNC_SUBTRACT:
add_arg (glsl_shader_state, pipeline, layer,
src[0], op[0], swizzle);
g_string_append (shader_source, " - ");
src[1], op[1], swizzle);
break;
- case GL_INTERPOLATE:
+ case COGL_PIPELINE_COMBINE_FUNC_INTERPOLATE:
add_arg (glsl_shader_state, pipeline, layer,
src[0], op[0], swizzle);
g_string_append (shader_source, " * ");
g_string_append_c (shader_source, ')');
break;
- case GL_DOT3_RGB:
- case GL_DOT3_RGBA:
+ case COGL_PIPELINE_COMBINE_FUNC_DOT3_RGB:
+ case COGL_PIPELINE_COMBINE_FUNC_DOT3_RGBA:
g_string_append (shader_source, "vec4(4.0 * ((");
add_arg (glsl_shader_state, pipeline, layer,
src[0], op[0], "r");
/* GL_DOT3_RGBA Is a bit weird as a GL_COMBINE_RGB function
* since if you use it, it overrides your ALPHA function...
*/
- big_state->texture_combine_rgb_func == GL_DOT3_RGBA)
+ big_state->texture_combine_rgb_func ==
+ COGL_PIPELINE_COMBINE_FUNC_DOT3_RGBA)
append_masked_combine (pipeline,
layer,
"rgba",
} CoglPipelineLayerState;
+typedef enum
+{
+ /* These are the same values as GL */
+ COGL_PIPELINE_COMBINE_FUNC_ADD = 0x0104,
+ COGL_PIPELINE_COMBINE_FUNC_ADD_SIGNED = 0x8574,
+ COGL_PIPELINE_COMBINE_FUNC_SUBTRACT = 0x84E7,
+ COGL_PIPELINE_COMBINE_FUNC_INTERPOLATE = 0x8575,
+ COGL_PIPELINE_COMBINE_FUNC_REPLACE = 0x1E01,
+ COGL_PIPELINE_COMBINE_FUNC_MODULATE = 0x2100,
+ COGL_PIPELINE_COMBINE_FUNC_DOT3_RGB = 0x86AE,
+ COGL_PIPELINE_COMBINE_FUNC_DOT3_RGBA = 0x86AF
+} CoglPipelineCombineFunc;
+
+typedef enum
+{
+ /* These are the same values as GL */
+ COGL_PIPELINE_COMBINE_SOURCE_TEXTURE = 0x1702,
+ COGL_PIPELINE_COMBINE_SOURCE_CONSTANT = 0x8576,
+ COGL_PIPELINE_COMBINE_SOURCE_PRIMARY_COLOR = 0x8577,
+ COGL_PIPELINE_COMBINE_SOURCE_PREVIOUS = 0x8578,
+ COGL_PIPELINE_COMBINE_SOURCE_TEXTURE0 = 0x84C0
+} CoglPipelineCombineSource;
+
+typedef enum
+{
+ /* These are the same values as GL */
+ COGL_PIPELINE_COMBINE_OP_SRC_COLOR = 0x0300,
+ COGL_PIPELINE_COMBINE_OP_ONE_MINUS_SRC_COLOR = 0x0301,
+ COGL_PIPELINE_COMBINE_OP_SRC_ALPHA = 0x0302,
+ COGL_PIPELINE_COMBINE_OP_ONE_MINUS_SRC_ALPHA = 0x0303
+} CoglPipelineCombineOp;
+
typedef struct
{
/* The texture combine state determines how the color of individual
* texture fragments are calculated. */
- GLint texture_combine_rgb_func;
- GLint texture_combine_rgb_src[3];
- GLint texture_combine_rgb_op[3];
+ CoglPipelineCombineFunc texture_combine_rgb_func;
+ CoglPipelineCombineSource texture_combine_rgb_src[3];
+ CoglPipelineCombineOp texture_combine_rgb_op[3];
- GLint texture_combine_alpha_func;
- GLint texture_combine_alpha_src[3];
- GLint texture_combine_alpha_op[3];
+ CoglPipelineCombineFunc texture_combine_alpha_func;
+ CoglPipelineCombineSource texture_combine_alpha_src[3];
+ CoglPipelineCombineOp texture_combine_alpha_op[3];
float texture_combine_constant[4];
_cogl_use_vertex_program (GLuint gl_program, CoglPipelineProgramType type);
unsigned int
-_cogl_get_n_args_for_combine_func (GLint func);
+_cogl_get_n_args_for_combine_func (CoglPipelineCombineFunc func);
/*
* _cogl_pipeline_weak_copy:
* assume it may result in an alpha value < 1
*
* FIXME: we could do better than this. */
- if (big_state->texture_combine_alpha_func != GL_MODULATE ||
- big_state->texture_combine_alpha_src[0] != GL_PREVIOUS ||
- big_state->texture_combine_alpha_op[0] != GL_SRC_ALPHA ||
- big_state->texture_combine_alpha_src[1] != GL_TEXTURE ||
- big_state->texture_combine_alpha_op[1] != GL_SRC_ALPHA)
+ if (big_state->texture_combine_alpha_func !=
+ COGL_PIPELINE_COMBINE_FUNC_MODULATE ||
+ big_state->texture_combine_alpha_src[0] !=
+ COGL_PIPELINE_COMBINE_SOURCE_PREVIOUS ||
+ big_state->texture_combine_alpha_op[0] !=
+ COGL_PIPELINE_COMBINE_OP_SRC_ALPHA ||
+ big_state->texture_combine_alpha_src[1] !=
+ COGL_PIPELINE_COMBINE_SOURCE_TEXTURE ||
+ big_state->texture_combine_alpha_op[1] !=
+ COGL_PIPELINE_COMBINE_OP_SRC_ALPHA)
{
*has_alpha = TRUE;
/* return FALSE to stop iterating layers... */
}
unsigned int
-_cogl_get_n_args_for_combine_func (GLint func)
+_cogl_get_n_args_for_combine_func (CoglPipelineCombineFunc func)
{
switch (func)
{
- case GL_REPLACE:
+ case COGL_PIPELINE_COMBINE_FUNC_REPLACE:
return 1;
- case GL_MODULATE:
- case GL_ADD:
- case GL_ADD_SIGNED:
- case GL_SUBTRACT:
- case GL_DOT3_RGB:
- case GL_DOT3_RGBA:
+ case COGL_PIPELINE_COMBINE_FUNC_MODULATE:
+ case COGL_PIPELINE_COMBINE_FUNC_ADD:
+ case COGL_PIPELINE_COMBINE_FUNC_ADD_SIGNED:
+ case COGL_PIPELINE_COMBINE_FUNC_SUBTRACT:
+ case COGL_PIPELINE_COMBINE_FUNC_DOT3_RGB:
+ case COGL_PIPELINE_COMBINE_FUNC_DOT3_RGBA:
return 2;
- case GL_INTERPOLATE:
+ case COGL_PIPELINE_COMBINE_FUNC_INTERPOLATE:
return 3;
}
return 0;
/* Choose the same default combine mode as OpenGL:
* RGBA = MODULATE(PREVIOUS[RGBA],TEXTURE[RGBA]) */
- big_state->texture_combine_rgb_func = GL_MODULATE;
- big_state->texture_combine_rgb_src[0] = GL_PREVIOUS;
- big_state->texture_combine_rgb_src[1] = GL_TEXTURE;
- big_state->texture_combine_rgb_op[0] = GL_SRC_COLOR;
- big_state->texture_combine_rgb_op[1] = GL_SRC_COLOR;
- big_state->texture_combine_alpha_func = GL_MODULATE;
- big_state->texture_combine_alpha_src[0] = GL_PREVIOUS;
- big_state->texture_combine_alpha_src[1] = GL_TEXTURE;
- big_state->texture_combine_alpha_op[0] = GL_SRC_ALPHA;
- big_state->texture_combine_alpha_op[1] = GL_SRC_ALPHA;
+ big_state->texture_combine_rgb_func =
+ COGL_PIPELINE_COMBINE_FUNC_MODULATE;
+ big_state->texture_combine_rgb_src[0] =
+ COGL_PIPELINE_COMBINE_SOURCE_PREVIOUS;
+ big_state->texture_combine_rgb_src[1] =
+ COGL_PIPELINE_COMBINE_SOURCE_TEXTURE;
+ big_state->texture_combine_rgb_op[0] =
+ COGL_PIPELINE_COMBINE_OP_SRC_COLOR;
+ big_state->texture_combine_rgb_op[1] =
+ COGL_PIPELINE_COMBINE_OP_SRC_COLOR;
+ big_state->texture_combine_alpha_func =
+ COGL_PIPELINE_COMBINE_FUNC_MODULATE;
+ big_state->texture_combine_alpha_src[0] =
+ COGL_PIPELINE_COMBINE_SOURCE_PREVIOUS;
+ big_state->texture_combine_alpha_src[1] =
+ COGL_PIPELINE_COMBINE_SOURCE_TEXTURE;
+ big_state->texture_combine_alpha_op[0] =
+ COGL_PIPELINE_COMBINE_OP_SRC_ALPHA;
+ big_state->texture_combine_alpha_op[1] =
+ COGL_PIPELINE_COMBINE_OP_SRC_ALPHA;
big_state->point_sprite_coords = FALSE;
static void
setup_texture_combine_state (CoglBlendStringStatement *statement,
- GLint *texture_combine_func,
- GLint *texture_combine_src,
- GLint *texture_combine_op)
+ CoglPipelineCombineFunc *texture_combine_func,
+ CoglPipelineCombineSource *texture_combine_src,
+ CoglPipelineCombineOp *texture_combine_op)
{
int i;
switch (statement->function->type)
{
case COGL_BLEND_STRING_FUNCTION_REPLACE:
- *texture_combine_func = GL_REPLACE;
+ *texture_combine_func = COGL_PIPELINE_COMBINE_FUNC_REPLACE;
break;
case COGL_BLEND_STRING_FUNCTION_MODULATE:
- *texture_combine_func = GL_MODULATE;
+ *texture_combine_func = COGL_PIPELINE_COMBINE_FUNC_MODULATE;
break;
case COGL_BLEND_STRING_FUNCTION_ADD:
- *texture_combine_func = GL_ADD;
+ *texture_combine_func = COGL_PIPELINE_COMBINE_FUNC_ADD;
break;
case COGL_BLEND_STRING_FUNCTION_ADD_SIGNED:
- *texture_combine_func = GL_ADD_SIGNED;
+ *texture_combine_func = COGL_PIPELINE_COMBINE_FUNC_ADD_SIGNED;
break;
case COGL_BLEND_STRING_FUNCTION_INTERPOLATE:
- *texture_combine_func = GL_INTERPOLATE;
+ *texture_combine_func = COGL_PIPELINE_COMBINE_FUNC_INTERPOLATE;
break;
case COGL_BLEND_STRING_FUNCTION_SUBTRACT:
- *texture_combine_func = GL_SUBTRACT;
+ *texture_combine_func = COGL_PIPELINE_COMBINE_FUNC_SUBTRACT;
break;
case COGL_BLEND_STRING_FUNCTION_DOT3_RGB:
- *texture_combine_func = GL_DOT3_RGB;
+ *texture_combine_func = COGL_PIPELINE_COMBINE_FUNC_DOT3_RGB;
break;
case COGL_BLEND_STRING_FUNCTION_DOT3_RGBA:
- *texture_combine_func = GL_DOT3_RGBA;
+ *texture_combine_func = COGL_PIPELINE_COMBINE_FUNC_DOT3_RGBA;
break;
}
switch (arg->source.info->type)
{
case COGL_BLEND_STRING_COLOR_SOURCE_CONSTANT:
- texture_combine_src[i] = GL_CONSTANT;
+ texture_combine_src[i] = COGL_PIPELINE_COMBINE_SOURCE_CONSTANT;
break;
case COGL_BLEND_STRING_COLOR_SOURCE_TEXTURE:
- texture_combine_src[i] = GL_TEXTURE;
+ texture_combine_src[i] = COGL_PIPELINE_COMBINE_SOURCE_TEXTURE;
break;
case COGL_BLEND_STRING_COLOR_SOURCE_TEXTURE_N:
texture_combine_src[i] =
- GL_TEXTURE0 + arg->source.texture;
+ COGL_PIPELINE_COMBINE_SOURCE_TEXTURE0 + arg->source.texture;
break;
case COGL_BLEND_STRING_COLOR_SOURCE_PRIMARY:
- texture_combine_src[i] = GL_PRIMARY_COLOR;
+ texture_combine_src[i] = COGL_PIPELINE_COMBINE_SOURCE_PRIMARY_COLOR;
break;
case COGL_BLEND_STRING_COLOR_SOURCE_PREVIOUS:
- texture_combine_src[i] = GL_PREVIOUS;
+ texture_combine_src[i] = COGL_PIPELINE_COMBINE_SOURCE_PREVIOUS;
break;
default:
g_warning ("Unexpected texture combine source");
- texture_combine_src[i] = GL_TEXTURE;
+ texture_combine_src[i] = COGL_PIPELINE_COMBINE_SOURCE_TEXTURE;
}
if (arg->source.mask == COGL_BLEND_STRING_CHANNEL_MASK_RGB)
{
if (statement->args[i].source.one_minus)
- texture_combine_op[i] = GL_ONE_MINUS_SRC_COLOR;
+ texture_combine_op[i] =
+ COGL_PIPELINE_COMBINE_OP_ONE_MINUS_SRC_COLOR;
else
- texture_combine_op[i] = GL_SRC_COLOR;
+ texture_combine_op[i] = COGL_PIPELINE_COMBINE_OP_SRC_COLOR;
}
else
{
if (statement->args[i].source.one_minus)
- texture_combine_op[i] = GL_ONE_MINUS_SRC_ALPHA;
+ texture_combine_op[i] =
+ COGL_PIPELINE_COMBINE_OP_ONE_MINUS_SRC_ALPHA;
else
- texture_combine_op[i] = GL_SRC_ALPHA;
+ texture_combine_op[i] = COGL_PIPELINE_COMBINE_OP_SRC_ALPHA;
}
}
}