Hello.

I tried to apply vertex shader with ClutterShader api, but it seems it
doesn't draw anything.

And I found there is no sample code for vertex shader in
tests/interactive/test_shader.c source file, there is only fragment
shader test.

I'll attach a simple source code for applying vertex shader.

Should anyone tell me code is wrong? or is this known issue?

Regards.
#include <string.h>
#include <clutter/clutter.h>

#define NOOP_VERTEX \
    "void main(void) {gl_Position = ftransform();}"

int main(int argc, char **argv)
{
    clutter_init(&argc, &argv);
    ClutterActor *stage = clutter_stage_get_default();
    ClutterColor color = {0x00, 0x00, 0xff, 0xff};
    ClutterShader *shader = clutter_shader_new();
    clutter_shader_set_vertex_source(shader, NOOP_VERTEX, strlen(NOOP_VERTEX));

    ClutterActor *rect = clutter_rectangle_new_with_color(&color);
    clutter_actor_set_size(rect, 100, 100);
    clutter_container_add_actor(CLUTTER_CONTAINER(stage), rect);
    if (clutter_actor_set_shader(rect, shader)) {
	g_print("shader is applied\n");
    }

    rect = clutter_rectangle_new_with_color(&color);
    clutter_actor_set_size(rect, 100, 100);
    clutter_actor_set_position(rect, 110, 0);
    clutter_container_add_actor(CLUTTER_CONTAINER(stage), rect);

    clutter_actor_show_all(stage);
    clutter_main();
    return 0;
}

Reply via email to