Cogl.Buffer.map_range

### Method

# Cogl Buffermap_range

#### Declaration [src]

    void*
    cogl_buffer_map_range (
      CoglBuffer* buffer,
      size_t offset,
      size_t size,
      CoglBufferAccess access,
      CoglBufferMapHint hints,
      GError** error
    )

#### Description [src]

Maps a sub-region of the buffer into the application’s address space for direct access.

It is strongly recommended that you pass `COGL_BUFFER_MAP_HINT_DISCARD` as a hint if you are going to replace all the buffer’s data. This way if the buffer is currently being used by the GPU then the driver won’t have to stall the CPU and wait for the hardware to finish because it can instead allocate a new buffer to map. You can pass `COGL_BUFFER_MAP_HINT_DISCARD_RANGE` instead if you want the regions outside of the mapping to be retained.

The behaviour is undefined if you access the buffer in a way conflicting with the `access` mask you pass. It is also an error to release your last reference while the buffer is mapped.

#### Parameters

`offset`

  Type: `size_t`

  Offset within the buffer to start the mapping.

`size`

  Type: `size_t`

  The size of data to map.

`access`

  Type: `CoglBufferAccess`

  How the mapped buffer will be used by the application.

`hints`

  Type: `CoglBufferMapHint`

  A mask of `CoglBufferMapHint`s that tell Cogl how the data will be modified once mapped.

`error`

  Type: `GError **`

  The return location for a recoverable error.

  The argument can be `NULL`.
  If the return location is not `NULL`, then you must initialize it to a `NULL` `GError*`.
  The argument will be left initialized to `NULL` by the method if there are no errors.
  In case of error, the argument will be set to a newly allocated `GError`; the caller will take ownership of the data, and be responsible for freeing it.

#### Return value

Type: `void*`

A pointer to the mapped memory or `NULL` is the call fails.

The returned data is owned by the instance.
The return value can be `NULL`.