Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion docs/guides/developing/usage_examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ and an example helper class is provided for use with OpenGL.
C++
+++

This example is available as a working app in the OCIO source: src/apps/ociodisplay.
This example is available as a working app in the OCIO source: ``src/apps/ociodisplay``.

.. code-block:: cpp

Expand Down Expand Up @@ -402,3 +402,36 @@ This example is available as a working app in the OCIO source: src/apps/ociodisp
oglApp->setShader(shaderDesc);

oglApp->redisplay();

Python
++++++

A full example of a GPUProcessor can be found in the OCIO source: ``src/apps/pyociodisplay``.

.. code-block:: python

import PyOpenColorIO as OCIO

# Step 1: Get the config
config = OCIO.GetCurrentConfig()

# Step 2: Lookup the display ColorSpace
display = config.getDefaultDisplay()
view = config.getDefaultView(display)

# Step 3: Create a DisplayViewTransform, and set the input, display, and view
# (This example assumes the input is a role. Adapt as needed.)
transform = OCIO.DisplayViewTransform()
transform.setSrc(OCIO.ROLE_SCENE_LINEAR)
transform.setDisplay(display)
transform.setView(view)

# Step 4: Create the processor
processor = config.getProcessor(transform)
gpu = processor.getDefaultGPUProcessor()

# Step 5: Extract the GLSL ShaderText to be used in an OpenGL app.
shader_desc = OCIO.GpuShaderDesc.CreateShaderDesc(language=OCIO.GPU_LANGUAGE_GLSL_4_0)
gpu.extractGpuShaderInfo(shader_desc)
source = shader_desc.getShaderText()
print(source)