Hi all,

Clutter is using perspective projection by default.
More than that, I couldn't find a way to make it use orthogonal projection.
Internally, ClutterStage uses cogl_setup_viewport, which uses cogl_perspective. There is a commented out call to cogl_wrap_glOrtho which seems to tell that there was an attempt to support orthogonal projection, which was apparently abandoned.

It results in some offset from expected x,y position, even when depth is 0.
See the code example attached in test_ortho.c.
It basically creates a rectangle which should be exactly 1 pixel within the stage window on all sides. Instead, the rectangle shows up 10 pixels from the top and 3 pixels from the right side. Left and bottom are correctly 1 pixel.

Any idea how to get the right orthogonal projection without changing clutter's internal code ?

In general, I would have expected clutter to use orthogonal projection by default, since it is used mostly for UI.

Thanks,

Michael


--
Michael Boccara
Graphtech
Herzliya, Israel


#include <clutter/clutter.h>
#include <clutter/clutter-stage.h>
#include <clutter/clutter-color.h>
#include <clutter/clutter-rectangle.h>
#include <stdlib.h>

int
main (int argc, char *argv[])
{
    ClutterColor stage_color = { 0x00, 0x00, 0x00, 0xff };
    ClutterColor rect_color = { 0xff, 0xff, 0xff, 0xff };

    clutter_init (&argc, &argv);

    /* Get the stage and set its size and color: */
    ClutterActor *stage = clutter_stage_get_default ();

    clutter_actor_set_size (stage, 400, 800);
    clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
    
    ClutterRectangle* rect = NULL;
    rect = clutter_rectangle_new_with_color(&rect_color);
    
    clutter_actor_set_size (rect, 398, 798);
    clutter_actor_set_position (rect, 1, 1);
    
    clutter_container_add_actor (CLUTTER_CONTAINER (stage), CLUTTER_ACTOR(rect));

    clutter_actor_show_all (stage);
    /* Start the main loop, so we can respond to events: */
    clutter_main ();

    return EXIT_SUCCESS;
}

Reply via email to