summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2012-02-10 16:44:57 +0000
committerNeil Roberts <neil@linux.intel.com>2012-02-13 17:29:28 +0000
commit39b9e717f5e91e04fcf6bf1dd0c8d5646871dedb (patch)
tree77f9bb1b386f0eb0e57bc45e17ef04780c1b0164
parent6ca852fad612adde096e7df884f9ea8f4fb45281 (diff)
downloadcogl-39b9e717f5e91e04fcf6bf1dd0c8d5646871dedb.tar.gz
test-snippets: Add a test for using cogl_sampler in tex hook
This adds a test for doing custom sampling using the cogl_sampler variable in the texture lookup hook. Reviewed-by: Robert Bragg <robert@linux.intel.com>
-rw-r--r--tests/conform/test-snippets.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/conform/test-snippets.c b/tests/conform/test-snippets.c
index 43005f20..2692b093 100644
--- a/tests/conform/test-snippets.c
+++ b/tests/conform/test-snippets.c
@@ -299,6 +299,34 @@ test_texture_lookup_hook (TestState *state)
}
static void
+test_multiple_samples (TestState *state)
+{
+ CoglPipeline *pipeline;
+ CoglSnippet *snippet;
+
+ /* Check that we can use the passed in sampler in the texture lookup
+ to sample multiple times */
+ snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_TEXTURE_LOOKUP,
+ NULL,
+ NULL);
+ cogl_snippet_set_replace (snippet,
+ "cogl_texel = "
+ "texture2D (cogl_sampler, vec2 (0.25, 0.25)) + "
+ "texture2D (cogl_sampler, vec2 (0.75, 0.25));");
+
+ pipeline = create_texture_pipeline ();
+ cogl_pipeline_add_layer_snippet (pipeline, 0, snippet);
+ cogl_push_source (pipeline);
+ cogl_rectangle (0, 0, 10, 10);
+ cogl_pop_source ();
+ cogl_object_unref (pipeline);
+
+ cogl_object_unref (snippet);
+
+ test_utils_check_pixel (5, 5, 0xffff00ff);
+}
+
+static void
test_replace_lookup_hook (TestState *state)
{
CoglPipeline *pipeline;
@@ -614,6 +642,7 @@ tests[] =
test_pipeline_caching,
test_replace_string,
test_texture_lookup_hook,
+ test_multiple_samples,
test_replace_lookup_hook,
test_replace_snippet,
test_replace_fragment_layer,