Clutter / COGL中的高效反射?

时间:2013-05-09 21:33:46

标签: c clutter cogl

我正在研究一个使用Clutter(1.10)和COGL将元素渲染到显示器的程序。

我创建了一组ClutterTextures,我正在渲染视频,我希望视频纹理有反射。

每次绘制纹理时,实现此操作的“标准”方法似乎都是回调,代码类似于:

static void texture_paint_cb (ClutterActor *actor ) {
    ClutterGeometry geom;
    CoglHandle cmaterial;
    CoglHandle ctexture;
    gfloat squish = 1.5;

    cogl_push_matrix ();

    clutter_actor_get_allocation_geometry (actor, &geom);

    guint8 opacity = clutter_actor_get_paint_opacity (actor);
    opacity /= 2;

    CoglTextureVertex vertices[] =
    { 
        { geom.width, geom.height,     0,  1, 1 },
        { 0,          geom.height,     0,  0, 1 },
        { 0,          geom.height*squish, 0,  0, 0 },
        { geom.width, geom.height*squish, 0,  1, 0 } 
    };

    cogl_color_set_from_4ub (&vertices[0].color, opacity, opacity, opacity, opacity);
    cogl_color_set_from_4ub (&vertices[1].color, opacity, opacity, opacity, opacity);
    cogl_color_set_from_4ub (&vertices[2].color, 0, 0, 0, 0);
    cogl_color_set_from_4ub (&vertices[3].color, 0, 0, 0, 0);

    cmaterial = clutter_texture_get_cogl_material (CLUTTER_TEXTURE (actor));
    ctexture  = clutter_texture_get_cogl_texture  (CLUTTER_TEXTURE (actor));

    cogl_material_set_layer (cmaterial, 0, ctexture);
    cogl_set_source(cmaterial);
    cogl_set_source_texture(ctexture);
    cogl_polygon (vertices, G_N_ELEMENTS (vertices), TRUE);

    cogl_pop_matrix ();
}

然后将其连接到ClutterTexture上的paint信号。代码here的代码类似于类似代码。 (Google cache, since the page has been down today

我遇到的问题是反射效果会导致性能下降 - 启用时会丢失5~7 fps。部分问题可能是我正在使用的低功耗硬件(Raspberry Pi)。

通过设置纹理的克隆并使其有些透明,我设法做了类似于此代码的操作。这不会导致任何性能损失。但是,与绘制回调方法不同,反射具有硬边并且不会淡出。

我希望在没有性能影响的情况下获得更好看的反射效果。我想知道是否有某种方法可以获得类似的效果,每个油漆不需要那么多的工作......还有一堆其他的Clutter和COGL方法可以操作材料,着色器等等,但是我很少没有OpenGL的专业知识,所以我不知道我是否可以按照这些方式做一些事情来做我想要的事情,甚至不知道如何找到类似我能做的事情的例子。

是否可以通过Clutter / COGL获得更好看,高性能的反射效果?

0 个答案:

没有答案
相关问题