Glf module

Summary: The Glf module contains Utility classes for OpenGL output.


glf

Classes:

DrawTarget

A class representing a GL render target with mutliple image attachments.

GLQueryObject

Represents a GL query object in Glf

SimpleLight

SimpleMaterial

Texture

Represents a texture object in Glf.

class pxr.Glf.DrawTarget

A class representing a GL render target with mutliple image attachments.

A DrawTarget is essentially a custom render pass into which several arbitrary variables can be output into. These can later be used as texture samplers by GLSL shaders.

The DrawTarget maintains a map of named attachments that correspond to GL_TEXTURE_2D mages. By default, DrawTargets also create a depth component that is used both as a depth buffer during the draw pass, and can later be accessed as a regular GL_TEXTURE_2D data. Stencils are also available (by setting the format to GL_DEPTH_STENCIL and the internalFormat to GL_DEPTH24_STENCIL8)

Methods:

AddAttachment(name, format, type, internalFormat)

Add an attachment to the DrawTarget.

Bind()

Binds the framebuffer.

Unbind()

Unbinds the framebuffer.

WriteToFile(name, filename, viewMatrix, ...)

Write the Attachment buffer to an image file (debugging).

Attributes:

expired

True if this object has expired, False otherwise.

AddAttachment(name, format, type, internalFormat) None

Add an attachment to the DrawTarget.

Parameters
  • name (str) –

  • format (GLenum) –

  • type (GLenum) –

  • internalFormat (GLenum) –

Bind() None

Binds the framebuffer.

Unbind() None

Unbinds the framebuffer.

WriteToFile(name, filename, viewMatrix, projectionMatrix) bool

Write the Attachment buffer to an image file (debugging).

Parameters
  • name (str) –

  • filename (str) –

  • viewMatrix (Matrix4d) –

  • projectionMatrix (Matrix4d) –

property expired

True if this object has expired, False otherwise.

class pxr.Glf.GLQueryObject

Represents a GL query object in Glf

Methods:

Begin(target)

Begin query for the given target target has to be one of GL_SAMPLES_PASSED, GL_ANY_SAMPLES_PASSED, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, GL_PRIMITIVES_GENERATED GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN GL_TIME_ELAPSED, GL_TIMESTAMP.

BeginPrimitivesGenerated()

equivalent to Begin(GL_PRIMITIVES_GENERATED).

BeginSamplesPassed()

equivalent to Begin(GL_SAMPLES_PASSED).

BeginTimeElapsed()

equivalent to Begin(GL_TIME_ELAPSED).

End()

End query.

GetResult()

Return the query result (synchronous) stalls CPU until the result becomes available.

GetResultNoWait()

Return the query result (asynchronous) returns 0 if the result hasn't been available.

Begin(target) None

Begin query for the given target target has to be one of GL_SAMPLES_PASSED, GL_ANY_SAMPLES_PASSED, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, GL_PRIMITIVES_GENERATED GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN GL_TIME_ELAPSED, GL_TIMESTAMP.

Parameters

target (GLenum) –

BeginPrimitivesGenerated() None

equivalent to Begin(GL_PRIMITIVES_GENERATED).

The number of primitives sent to the rasterizer by the scoped drawing command will be returned.

BeginSamplesPassed() None

equivalent to Begin(GL_SAMPLES_PASSED).

The number of samples that pass the depth test for all drawing commands within the scope of the query will be returned.

BeginTimeElapsed() None

equivalent to Begin(GL_TIME_ELAPSED).

The time that it takes for the GPU to execute all of the scoped commands will be returned in nanoseconds.

End() None

End query.

GetResult() int

Return the query result (synchronous) stalls CPU until the result becomes available.

GetResultNoWait() int

Return the query result (asynchronous) returns 0 if the result hasn’t been available.

class pxr.Glf.SimpleLight

Attributes:

ambient

None

attenuation

None

diffuse

None

hasShadow

None

id

isCameraSpaceLight

None

isDomeLight

None

position

None

shadowBias

None

shadowBlur

None

shadowIndexEnd

None

shadowIndexStart

None

shadowMatrices

None

shadowResolution

None

specular

None

spotCutoff

None

spotDirection

None

spotFalloff

None

transform

None

property ambient

None


type : Vec4f

Type

type

property attenuation

None


type : Vec3f

Type

type

property diffuse

None


type : Vec4f

Type

type

property hasShadow

None

Type

type

property id
property isCameraSpaceLight

None


type : bool

Type

type

property isDomeLight

None


type : bool

Type

type

property position

None


type : Vec4f

Type

type

property shadowBias

None


type : float

Type

type

property shadowBlur

None


type : float

Type

type

property shadowIndexEnd

None


type : int

Type

type

property shadowIndexStart

None


type : int

Type

type

property shadowMatrices

None


type : list[Matrix4d]

Type

type

property shadowResolution

None


type : int

Type

type

property specular

None


type : Vec4f

Type

type

property spotCutoff

None


type : float

Type

type

property spotDirection

None


type : Vec3f

Type

type

property spotFalloff

None


type : float

Type

type

property transform

None


type : Matrix4d

Type

type

class pxr.Glf.SimpleMaterial

Attributes:

ambient

None

diffuse

None

emission

None

shininess

None

specular

None

property ambient

None


type : Vec4f

Type

type

property diffuse

None


type : Vec4f

Type

type

property emission

None


type : Vec4f

Type

type

property shininess

None


type : float

Type

type

property specular

None


type : Vec4f

Type

type

class pxr.Glf.Texture

Represents a texture object in Glf.

A texture is typically defined by reading texture image data from an image file but a texture might also represent an attachment of a draw target.

Methods:

GetTextureMemoryAllocated

classmethod GetTextureMemoryAllocated() -> int

Attributes:

magFilterSupported

bool

memoryRequested

None

memoryUsed

int

minFilterSupported

bool

static GetTextureMemoryAllocated()

classmethod GetTextureMemoryAllocated() -> int

static reporting function

property magFilterSupported

bool

Type

type

property memoryRequested

None

Specify the amount of memory the user wishes to allocate to the texture.


type : int

Amount of memory the user wishes to allocate to the texture.

Type

type

property memoryUsed

int

Amount of memory used to store the texture.

Type

type

property minFilterSupported

bool

Type

type