Cogl.Onscreen.get_buffer_age
Description: Reference for Cogl.Onscreen.get_buffer_age

### Virtual Method

# Cogl Onscreenget_buffer_age

#### Declaration [src]

    int
    get_buffer_age (
      CoglOnscreen* onscreen
    )

#### Description [src]

Gets the current age of the buffer contents.

This function allows applications to query the age of the current back buffer contents for a `CoglOnscreen` as the number of frames elapsed since the contents were most recently defined.

These age values exposes enough information to applications about how Cogl internally manages back buffers to allow applications to re-use the contents of old frames and minimize how much must be redrawn for the next frame.

The back buffer contents can either be reported as invalid (has an age of 0) or it may be reported to be the same contents as from n frames prior to the current frame.

The queried value remains valid until the next buffer swap.

One caveat is that under X11 the buffer age does not reflect changes to buffer contents caused by the window systems. X11 applications must track Expose events to determine what buffer regions need to additionally be repaired each frame.

The recommended way to take advantage of this buffer age api is to build up a circular buffer of length 3 for tracking damage regions over the last 3 frames and when starting a new frame look at the age of the buffer and combine the damage regions for the current frame with the damage regions of previous `age` frames so you know everything that must be redrawn to update the old contents for the new frame.

If the system doesn’t not support being able to track the age of back buffers then this function will always return 0 which implies that the contents are undefined.

The `COGL_FEATURE_ID_BUFFER_AGE` feature can optionally be explicitly checked to determine if Cogl is currently tracking the age of `CoglOnscreen` back buffer contents. If this feature is missing then this function will always return 0.

Stability: | Stable
Available since: | 1.14

#### Return value

Returns: | `int`
| The age of the buffer contents or 0 when the buffer contents are undefined.