[cogl/wip/neil/master-next: 16/16] test-snippets: Add a test case for sampling arbitrary units
- From: Neil Roberts <nroberts src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl/wip/neil/master-next: 16/16] test-snippets: Add a test case for sampling arbitrary units
- Date: Fri, 10 Feb 2012 17:03:03 +0000 (UTC)
commit 3a3cbd2f0ab71ca4418c251a982c87ca0d2ff892
Author: Neil Roberts <neil linux intel com>
Date: Fri Feb 10 16:58:31 2012 +0000
test-snippets: Add a test case for sampling arbitrary units
This adds a sub-test that samples from two texture units by naming
their layer numbers.
tests/conform/test-snippets.c | 43 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/tests/conform/test-snippets.c b/tests/conform/test-snippets.c
index 2692b09..655b340 100644
--- a/tests/conform/test-snippets.c
+++ b/tests/conform/test-snippets.c
@@ -7,6 +7,7 @@
typedef struct _TestState
{
CoglFramebuffer *fb;
+ CoglContext *context;
} TestState;
typedef void (* SnippetTestFunc) (TestState *state);
@@ -591,6 +592,46 @@ test_snippet_order (TestState *state)
}
static void
+test_naming_texture_units (TestState *state)
+{
+ CoglPipeline *pipeline;
+ CoglSnippet *snippet;
+ CoglTexture *tex1, *tex2;
+
+ /* Test that we can sample from an arbitrary texture unit by naming
+ its layer number */
+
+ snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT,
+ NULL,
+ NULL);
+ cogl_snippet_set_replace (snippet,
+ "cogl_color_out = "
+ "texture2D (cogl_sampler100, vec2 (0.0, 0.0)) + "
+ "texture2D (cogl_sampler200, vec2 (0.0, 0.0));");
+
+ tex1 = test_utils_create_color_texture (state->context, 0xff0000ff);
+ tex2 = test_utils_create_color_texture (state->context, 0x00ff00ff);
+
+ pipeline = cogl_pipeline_new ();
+
+ cogl_pipeline_set_layer_texture (pipeline, 100, tex1);
+ cogl_pipeline_set_layer_texture (pipeline, 200, tex2);
+
+ cogl_pipeline_add_snippet (pipeline, snippet);
+
+ cogl_push_source (pipeline);
+ cogl_rectangle (0, 0, 10, 10);
+ cogl_pop_source ();
+
+ cogl_object_unref (pipeline);
+ cogl_object_unref (snippet);
+ cogl_object_unref (tex1);
+ cogl_object_unref (tex2);
+
+ test_utils_check_pixel (5, 5, 0xffff00ff);
+}
+
+static void
test_snippet_properties (TestState *state)
{
CoglSnippet *snippet;
@@ -651,6 +692,7 @@ tests[] =
test_replace_vertex_layer,
test_vertex_transform_hook,
test_snippet_order,
+ test_naming_texture_units,
test_snippet_properties
};
@@ -681,6 +723,7 @@ test_cogl_snippets (TestUtilsGTestFixture *fixture,
TestState state;
state.fb = shared_state->fb;
+ state.context = shared_state->ctx;
cogl_ortho (/* left, right */
0, cogl_framebuffer_get_width (shared_state->fb),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]