pipeline: Wrap each snippet in its own function
Each snippet is now given its own function which contains the pre and post strings. Between these strings the function will chain on to another function. The generated cogl source is now stored in a function called cogl_generated_source() which the last snippet will chain on to. This should make it so that each snippet has its own namespace for local variables and it can share variables declared in the pre string in the post string. Hopefully the GLSL compiler will just inline all of the functions so it shouldn't make much difference to the compiled output. Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:

committed by
Robert Bragg

parent
2f66cd7036
commit
0fdd5690c6
@@ -105,14 +105,14 @@ paint (TestState *state)
|
||||
|
||||
cogl_object_unref (pipeline);
|
||||
|
||||
/* The pre string can't really do anything with the current hooks,
|
||||
but let's just test that it compiles */
|
||||
/* Test that the pre string can declare variables used by the post
|
||||
string */
|
||||
pipeline = cogl_pipeline_new ();
|
||||
|
||||
cogl_pipeline_set_color4ub (pipeline, 255, 0, 0, 255);
|
||||
cogl_pipeline_set_color4ub (pipeline, 255, 255, 255, 255);
|
||||
|
||||
snippet = cogl_snippet_new (NULL, NULL);
|
||||
cogl_snippet_set_pre (snippet, "cogl_color_out = vec4 (1.0, 0.5, 0.8, 1.0);");
|
||||
snippet = cogl_snippet_new (NULL, "cogl_color_out = redvec;");
|
||||
cogl_snippet_set_pre (snippet, "vec4 redvec = vec4 (1.0, 0.0, 0.0, 1.0);");
|
||||
cogl_pipeline_add_vertex_hook (pipeline, snippet);
|
||||
cogl_pipeline_add_fragment_hook (pipeline, snippet);
|
||||
cogl_object_unref (snippet);
|
||||
|
Reference in New Issue
Block a user