---
name: "clCreateFromGLRenderbuffer"
section: "3clc"
platform: "linux"
package: "opencl-1.2-man-doc"
version: "1.0~svn33624-5.1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/clCreateFromGLRenderbuffer"
---

# clCreateFromGLRenderbuffer(3clc)

Creates an OpenCL 2D image object from an OpenGL renderbuffer object.

## NAME

clCreateFromGLRenderbuffer - Creates an OpenCL 2D image object from an OpenGL renderbuffer object.

##

**cl\_mem clCreateFromGLRenderbuffer(cl\_context** *context***, cl\_mem\_flags** *flags***, GLuint** *renderbuffer***, cl\_int \*** *errcode\_ret***);**

## PARAMETERS

 *context*

A valid OpenCL context created from an OpenGL context.

 *flags*

A bit-field that is used to specify usage information. Refer to the table at [**clCreateBuffer**(3clc)](/clCreateBuffer/3clc.md) for a description of *flags*. Only **CL\_MEM\_READ\_ONLY**, **CL\_MEM\_WRITE\_ONLY**, and **CL\_MEM\_READ\_WRITE** values specified in the table at [**clCreateBuffer**(3clc)](/clCreateBuffer/3clc.md) can be used.

 *renderbuffer*

The name of a GL renderbuffer object. The renderbuffer storage must be specified before the image object can be created. The *renderbuffer* format and dimensions defined by OpenGL will be used to create the 2D image object. Only GL renderbuffers with internal formats that map to appropriate image channel order and data type specified in the table of supported Image Channel Order Values and the table of supported Image Channel Data Types for [**cl\_image\_format**(3clc)](/cl_image_format/3clc.md) can be used to create the 2D image object.

 *errcode\_ret*

Returns an appropriate error code as described below. If *errcode\_ret* is NULL, no error code is returned.

## DESCRIPTION

If the state of a GL renderbuffer object is modified through the GL API (i.e. changes to the dimensions or format used to represent pixels of the GL renderbuffer using appropriate GL API calls such as **glRenderbufferStorage**) while there exists a corresponding CL image object, subsequent use of the CL image object will result in undefined behavior.

The [**clRetainMemObject**(3clc)](/clRetainMemObject/3clc.md) and [**clReleaseMemObject**(3clc)](/clReleaseMemObject/3clc.md) functions can be used to retain and release the image objects.

The table below (Table 9.4) describes the list of GL texture internal formats and the corresponding CL image formats. If a GL texture object with an internal format from the table below is successfully created by OpenGL, then there is guaranteed to be a mapping to one of the corresponding CL image format(s) in that table. Texture objects created with other OpenGL internal formats may (but are not guaranteed to) have a mapping to a CL image format; if such mappings exist, they are guaranteed to preserve all color components, data types, and at least the number of bits/component actually allocated by OpenGL for that format.

| | |
| --- | --- |
| **GL internal format** | **CL image format (channel order, channel data type)** |
| **GL\_RGBA8** | **CL\_RGBA, CL\_UNORM\_INT8 or CL\_BGRA, CL\_UNORM\_INT8** |
| **GL\_RGBA**, **GL\_UNSIGNED\_INT\_8\_8\_8\_8\_REV** | **CL\_RGBA, CL\_UNORM\_INT8** |
| **GL\_BGRA**, **GL\_UNSIGNED\_INT\_8\_8\_8\_8\_REV** | **CL\_BGRA, CL\_UNORM\_INT8** |
| **GL\_RGBA16** | **CL\_RGBA, CL\_UNORM\_INT16** |
| **GL\_RGBA8I, GL\_RGBA8I\_EXT** | **CL\_RGBA, CL\_SIGNED\_INT8** |
| **GL\_RGBA16I, GL\_RGBA16I\_EXT** | **CL\_RGBA, CL\_SIGNED\_INT16** |
| **GL\_RGBA32I, GL\_RGBA32I\_EXT** | **CL\_RGBA, CL\_SIGNED\_INT32** |
| **GL\_RGBA8UI, GL\_RGBA8UI\_EXT** | **CL\_RGBA, CL\_UNSIGNED\_INT8** |
| **GL\_RGBA16UI, GL\_RGBA16UI\_EXT** | **CL\_RGBA, CL\_UNSIGNED\_INT16** |
| **GL\_RGBA32UI, GL\_RGBA32UI\_EXT** | **CL\_RGBA, CL\_UNSIGNED\_INT32** |
| **GL\_RGBA16F, GL\_RGBA16F\_ARB** | **CL\_RGBA, CL\_HALF\_FLOAT** |
| **GL\_RGBA32F, GL\_RGBA32F\_ARB** | **CL\_RGBA, CL\_FLOAT** |

## ERRORS

Returns a valid non-zero OpenCL image object and *errcode\_ret* is set to CL\_SUCCESS if the image object is created successfully. Otherwise, it returns a NULL value with one of the following error values returned in *errcode\_ret*:

• CL\_INVALID\_CONTEXT if *context* is not a valid context or was not created from a GL context.

• CL\_INVALID\_VALUE if values specified in *flags* are not valid.

• CL\_INVALID\_GL\_OBJECT if *renderbuffer* is not a GL renderbuffer object or if the width or height of *renderbuffer* is zero.

• CL\_INVALID\_IMAGE\_FORMAT\_DESCRIPTOR if the OpenGL renderbuffer internal format does not map to a supported OpenCL image format.

• CL\_INVALID\_OPERATION if *renderbuffer* is a multi-sample GL renderbuffer object.

• CL\_OUT\_OF\_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.

• CL\_OUT\_OF\_HOST\_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.

## SPECIFICATION

**OpenCL Specification**\[1\]

## SEE ALSO

[**cl\_khr\_gl\_sharing**(3clc)](/cl_khr_gl_sharing/3clc.md), [**clCreateBuffer**(3clc)](/clCreateBuffer/3clc.md), [**cl\_image\_format**(3clc)](/cl_image_format/3clc.md), [**clRetainMemObject**(3clc)](/clRetainMemObject/3clc.md), [**clReleaseMemObject**(3clc)](/clReleaseMemObject/3clc.md)

## AUTHORS

**The Khronos Group**

## COPYRIGHT

Copyright © 2007-2011 The Khronos Group Inc.\
 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials.

## NOTES

- 1\.

  OpenCL Specification

  page 53, section 9.7.4 - CL Image Objects -\> GL Renderbuffers
