Cogl.Context
Description: Reference for Cogl.Context

### Class

# CoglContext

#### Description [src]

    final class Cogl.Context : GObject.Object
    {
      /* No available fields */
    }

The top level application context.

A `CoglContext` is the top most sandbox of Cogl state for an application or toolkit. Its main purpose is to act as a sandbox for the memory management of state objects. Normally an application will only create a single context since there is no way to share resources between contexts.

For those familiar with OpenGL or perhaps Cairo it should be understood that unlike these APIs a Cogl context isn’t a rendering context as such. In other words Cogl doesn’t aim to provide a state machine style model for configuring rendering parameters. Most rendering state in Cogl is directly associated with user managed objects called pipelines and geometry is drawn with a specific pipeline object to a framebuffer object and those 3 things fully define the state for drawing. This is an important part of Cogl’s design since it helps you write orthogonal rendering components that can all access the same GPU without having to worry about what state other components have left you with.

Cogl does not maintain internal references to the context for resources that depend on the context so applications. This is to help applications control the lifetime a context without us needing to introduce special api to handle the breakup of internal circular references due to internal resources and caches associated with the context.

One a context has been destroyed then all directly or indirectly dependent resources will be in an inconsistent state and should not be manipulated or queried in any way.

For applications that rely on the operating system to clean up resources this policy shouldn’t affect them, but for applications that need to carefully destroy and re-create Cogl contexts multiple times throughout their lifetime (such as Android applications) they should be careful to destroy all context dependent resources, such as framebuffers or textures etc before unrefing and destroying the context.

#### Hierarchy

#### Ancestors

- GObject

#### Constructors

###### cogl_context_new

Creates a new `CoglContext` which acts as an application sandbox for any state objects that are allocated.

#### Instance methods

###### cogl_context_flush

This function should only need to be called in exceptional circumstances.

###### cogl_context_get_display

Retrieves the `CoglDisplay` that is internally associated with the given `context`. This will return the same `CoglDisplay` that was passed to `cogl_context_new()` or if `NULL` was passed to `cogl_context_new()` then this function returns a pointer to the display that was automatically setup internally.

###### cogl_context_get_driver

No description available.

###### cogl_context_get_latest_sync_fd

This function is used to get support for waiting on previous GPU work through sync fds. It will return a sync fd which will signal when the previous work has completed.

###### cogl_context_get_named_pipeline

No description available.

###### cogl_context_get_rectangle_indices

No description available.

###### cogl_context_get_renderer

Retrieves the `CoglRenderer` that is internally associated with the given `context`. This will return the same `CoglRenderer` that was passed to `cogl_display_new()` or if `NULL` was passed to `cogl_display_new()` or `cogl_context_new()` then this function returns a pointer to the renderer that was automatically connected internally.

###### cogl_context_has_winsys_feature

No description available.

###### cogl_context_set_named_pipeline

Associate a `CoglPipeline` with a `context` and `key`. This will not take a new reference to the `pipeline`, but will unref all associated pipelines when the `context` gets destroyed. Similarly, if a pipeline gets overwritten, it will get unreffed as well.

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

#### Signals

##### Signals inherited from GObject (1)

###### GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

#### Class structure

    struct CoglContextClass {
      GObjectClass parent_class;

    }

No description available.

###### Class members

`parent_class: GObjectClass`

  No description available.