Creating A Pipeline
In this section, we present how to create a static pipeline with the library :
try
{
pipelineLayout.addInput("inputTexture");
pipelineLayout.addOutput("outputTexture");
pipelineLayout.add(filterLayout, "ThisFilterName");
pipelineLayout.connectToInput("inputTexture", "ThisFilterName", "inputName");
pipelineLayout.connectToOutput("ThisFilterName", "outputName", "outputTexture");
Glip::CorePipelinePipeline pipeline(pl, "ThisPipelineName");
pipeline << yourTexture << Pipeline::Process;
yourDisplay(pipeline->out(0));
}
{
std::cerr << e.
what() << std::endl;
}
Loading A Pipeline Script
The previous section was limiting the pipeline to be with a static architecture. As you read in the introduction, it is also possible to load complete structures from strings or files via Glip::Modules::LayoutLoader :
try
{
HandleOpenGL::init();
Pipeline* pipeline = layoutLoader.
getPipeline(
"path/to/pipelineScript.ppl",
"ThisPipelineName");
}
{
std::cerr << e.
what() << std::endl;
}
Change Uniform Parameters
After the pipeline being created, it is possible to change filter parameters declared as uniform in the GLSL sources.
It is also possible to work with dynamic typing :
const std::string varname = filter.getUniformsNames().front();
const GLenum typeEnum = filter.getUniformsTypes().front();
delete var;
Save and Load Settings
We can also save and load complete sets of settings (uniform variables) from or to a pipeline with Glip::Modules::UniformsLoader :
uniformsLoader.
load(pipeline);
uniformsLoader.
clear(pipeline.getTypeName());
uniformsLoader.
load(
"otherSettings.uvd");
The settings are kept in a plain text format ressembling the following :
PIPELINE:PipelineLayoutName
{
FILTER:FilterLayoutName
{
GL_FLOAT:someVariable(1.0)
GL_VEC3:anotherVariable(1.4, 1.5, 1.6)
}
}
Buffer Cells
Pipelines typically build a unique set, or cell, of buffers to process data. In some cases, you might need to have other cells to operate on. For intance, if the pipeline shall read from one of its own output, it is not safe to use a single cell as it would then be possible to read and write to the same texture (an undefined behavior). We can write the following code for the library to handle these cases :
const int cellA = pipeline.getCurrentCellID();
const int cellB = pipeline.createBuffersCell();
pipeline << input1 << input2 << ... << Pipeline::Process;
for(int k=0; k<numLoops; k++)
{
if(k%2==0)
{
pipeline.changeTargetBuffersCell(cellB);
pipeline << pipeline.out(0, cellA) << pipeline.out(1, cellA) << ... << Pipeline::Process;
}
else
{
pipeline.changeTargetBuffersCell(cellA);
pipeline << pipeline.out(0, cellB) << pipeline.out(1, cellB) << ... << Pipeline::Process;
}
}