From cdc4bd6361cc1037a31da813f3bb8ee25cef7523 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Fri, 25 Nov 2011 20:59:05 +0000 Subject: [PATCH] snippet: Fix detecting the last snippet The function for generating the GLSL for a list of snippets was trying to detect the last snippet so that it could use a different function name. However this wouldn't work if the last snippet has a different hook. To fix this it now just counts the snippets that have the same hook beforehand and detects the last one using the count. Reviewed-by: Robert Bragg --- cogl/cogl-pipeline-snippet.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cogl/cogl-pipeline-snippet.c b/cogl/cogl-pipeline-snippet.c index 794e163c5..a5d1340b2 100644 --- a/cogl/cogl-pipeline-snippet.c +++ b/cogl/cogl-pipeline-snippet.c @@ -42,6 +42,13 @@ _cogl_pipeline_snippet_generate_code (const CoglPipelineSnippetData *data) { CoglPipelineSnippet *snippet; int snippet_num = 0; + int n_snippets = 0; + + /* First count the number of snippets so we can easily tell when + we're at the last one */ + COGL_LIST_FOREACH (snippet, data->snippets, list_node) + if (snippet->snippet->hook == data->hook) + n_snippets++; COGL_LIST_FOREACH (snippet, data->snippets, list_node) if (snippet->snippet->hook == data->hook) @@ -58,7 +65,7 @@ _cogl_pipeline_snippet_generate_code (const CoglPipelineSnippetData *data) data->return_type : "void"); - if (COGL_LIST_NEXT (snippet, list_node)) + if (snippet_num + 1 < n_snippets) g_string_append_printf (data->source_buf, "%s_%i", data->function_prefix,