examples: use framebuffer matrix stack apis
Instead of using apis like cogl_push/pop_matrix, cogl_rotate, cogl_translate and cogl_scale all the examples now use the cogl_framebuffer_* equivalents. Our aim is to remove the need for the default CoglContext and so we are switching towards apis that are explicitly tied to a specific context. Reviewed-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
parent
7287dd1faf
commit
0365f6cda3
@ -81,17 +81,21 @@ static CoglVertexP3T2 vertices[] =
|
|||||||
static void
|
static void
|
||||||
paint (Data *data)
|
paint (Data *data)
|
||||||
{
|
{
|
||||||
|
CoglFramebuffer *fb = data->fb;
|
||||||
float rotation;
|
float rotation;
|
||||||
|
|
||||||
cogl_framebuffer_clear4f (data->fb,
|
cogl_framebuffer_clear4f (fb,
|
||||||
COGL_BUFFER_BIT_COLOR|COGL_BUFFER_BIT_DEPTH,
|
COGL_BUFFER_BIT_COLOR|COGL_BUFFER_BIT_DEPTH,
|
||||||
0, 0, 0, 1);
|
0, 0, 0, 1);
|
||||||
|
|
||||||
cogl_push_matrix ();
|
cogl_framebuffer_push_matrix (fb);
|
||||||
|
|
||||||
cogl_translate (data->framebuffer_width / 2, data->framebuffer_height / 2, 0);
|
cogl_framebuffer_translate (fb,
|
||||||
|
data->framebuffer_width / 2,
|
||||||
|
data->framebuffer_height / 2,
|
||||||
|
0);
|
||||||
|
|
||||||
cogl_scale (75, 75, 75);
|
cogl_framebuffer_scale (fb, 75, 75, 75);
|
||||||
|
|
||||||
/* Update the rotation based on the time the application has been
|
/* Update the rotation based on the time the application has been
|
||||||
running so that we get a linear animation regardless of the frame
|
running so that we get a linear animation regardless of the frame
|
||||||
@ -107,9 +111,9 @@ paint (Data *data)
|
|||||||
* we want it to be a rotation around the origin, before it is
|
* we want it to be a rotation around the origin, before it is
|
||||||
* scaled and translated.
|
* scaled and translated.
|
||||||
*/
|
*/
|
||||||
cogl_rotate (rotation, 0, 0, 1);
|
cogl_framebuffer_rotate (fb, rotation, 0, 0, 1);
|
||||||
cogl_rotate (rotation, 0, 1, 0);
|
cogl_framebuffer_rotate (fb, rotation, 0, 1, 0);
|
||||||
cogl_rotate (rotation, 1, 0, 0);
|
cogl_framebuffer_rotate (fb, rotation, 1, 0, 0);
|
||||||
|
|
||||||
/* Whenever you draw something with Cogl using geometry defined by
|
/* Whenever you draw something with Cogl using geometry defined by
|
||||||
* one of cogl_rectangle, cogl_polygon, cogl_path or
|
* one of cogl_rectangle, cogl_polygon, cogl_path or
|
||||||
@ -125,7 +129,7 @@ paint (Data *data)
|
|||||||
|
|
||||||
cogl_set_depth_test_enabled (FALSE);
|
cogl_set_depth_test_enabled (FALSE);
|
||||||
|
|
||||||
cogl_pop_matrix ();
|
cogl_framebuffer_pop_matrix (fb);
|
||||||
|
|
||||||
/* And finally render our Pango layouts... */
|
/* And finally render our Pango layouts... */
|
||||||
|
|
||||||
|
@ -90,12 +90,12 @@ main (int argc, char **argv)
|
|||||||
|
|
||||||
cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
|
cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
|
||||||
|
|
||||||
cogl_push_matrix ();
|
cogl_framebuffer_push_matrix (fb);
|
||||||
cogl_scale (0.5, 1, 1);
|
cogl_framebuffer_scale (fb, 0.5, 1, 1);
|
||||||
cogl_translate (-1, 0, 0);
|
cogl_framebuffer_translate (fb, -1, 0, 0);
|
||||||
cogl_set_source (pipeline);
|
cogl_set_source (pipeline);
|
||||||
cogl_primitive_draw (triangle);
|
cogl_primitive_draw (triangle);
|
||||||
cogl_pop_matrix ();
|
cogl_framebuffer_pop_matrix (fb);
|
||||||
|
|
||||||
cogl_push_framebuffer (offscreen_fb);
|
cogl_push_framebuffer (offscreen_fb);
|
||||||
cogl_primitive_draw (triangle);
|
cogl_primitive_draw (triangle);
|
||||||
|
@ -17,15 +17,17 @@ typedef struct Data
|
|||||||
static void
|
static void
|
||||||
redraw (Data *data)
|
redraw (Data *data)
|
||||||
{
|
{
|
||||||
cogl_framebuffer_clear4f (data->fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
|
CoglFramebuffer *fb = data->fb;
|
||||||
|
|
||||||
cogl_push_matrix ();
|
cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
|
||||||
cogl_translate (data->center_x, -data->center_y, 0.0f);
|
|
||||||
|
cogl_framebuffer_push_matrix (fb);
|
||||||
|
cogl_framebuffer_translate (fb, data->center_x, -data->center_y, 0.0f);
|
||||||
|
|
||||||
cogl_primitive_draw (data->triangle);
|
cogl_primitive_draw (data->triangle);
|
||||||
cogl_pop_matrix ();
|
cogl_framebuffer_pop_matrix (fb);
|
||||||
|
|
||||||
cogl_framebuffer_swap_buffers (data->fb);
|
cogl_framebuffer_swap_buffers (fb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user