def add_render_texture(output, mode=None, bitplane=None): """Add render texture to `output`. Args: output (GraphicsOutput): Graphics output. Keyword Args: mode (GraphicsOutput.RenderTextureMode): | RTMNode | RTMBindOrCopy | RTMCopyTexture | RTMCopyRam | RTMTriggeredCopyTexture | RTMTriggeredCopyRam bitplane (DrawableRegion.RenderTexturePlane): | RTPStencil | RTPDepthStencil | RTPColor | RTPAuxRgba0 | RTPAuxRgba1 | RTPAuxRgba2 | RTPAuxRgba3 | RTPAuxHrgba0 | RTPAuxHrgba1 | RTPAuxHrgba2 | RTPAuxHrgba3 | RTPAuxFloat0 | RTPAuxFloat1 | RTPAuxFloat2 | RTPAuxFloat3 | RTPDepth | RTPCOUNT Return: (Texture): Texture object. """ # Mode. if mode is None: mode = GraphicsOutput.RTMBindOrCopy elif isinstance(mode, str): mode = getattr(GraphicsOutput, mode) if bitplane is None: bitplane = GraphicsOutput.RTPColor elif isinstance(bitplane, str): bitplane = getattr(GraphicsOutput, bitplane) # Bitplane. if bitplane is GraphicsOutput.RTPColor: fmt = Texture.FLuminance elif bitplane is GraphicsOutput.RTPDepth: fmt = Texture.FDepthComponent # Get a handle to the texture. tex = Texture() tex.setFormat(fmt) # Add the texture to the buffer. output.addRenderTexture(tex, mode, bitplane) tex.clearRamImage() return tex