Associates a linked CoglProgram with the given pipeline so that the program can take full control of vertex and/or fragment processing.
This is an example of how it can be used to associate an ARBfp program with a Pipeline:
CoglHandle shader;
CoglHandle program;
CoglPipeline *pipeline;
shader = cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT);
cogl_shader_source (shader,
"!!ARBfp1.0\n"
"MOV result.color,fragment.color;\n"
"END\n");
cogl_shader_compile (shader);
program = cogl_create_program ();
cogl_program_attach_shader (program, shader);
cogl_program_link (program);
pipeline = cogl_pipeline_new ();
cogl_pipeline_set_user_program (pipeline, program);
cogl_set_source_color4ub (0xff, 0x00, 0x00, 0xff);
cogl_rectangle (0, 0, 100, 100);
It is possibly worth keeping in mind that this API is not part of the long term design for how we want to expose shaders to Cogl developers (We are planning on deprecating the cogl_program and cogl_shader APIs in favour of a "snippet" framework) but in the meantime we hope this will handle most practical GLSL and ARBfp requirements.
Also remember you need to check for either the cogl_feature_shaders_glsl or cogl_feature_shaders_arbfp before using the cogl_program or cogl_shader API.
this |
a Pipeline object. |
program |
A Handle to a linked CoglProgram |