SwapChain

public class SwapChain

Swap chain that contains some number of frames. Frames in the swap chain can be unused, in the process of being distorted and presented on the screen, or acquired and being rendered to by the application. The swap chain ensures that the most recent available frame is always shown and that the application never has to wait to render the next frame.

Public Methods

Frame
acquireFrame()
Acquires a Frame from the swap chain for rendering.
int
getBufferCount()
Gets the number of buffers in each frame of the swap chain.
void
getBufferSize(int bufferIndex, Point sizeOut)
Retrieves the size of the specified pixel buffer.
void
resizeBuffer(int bufferIndex, Point newSize)
Resizes the specified pixel buffer to the given size.
void
shutdown()
Destroys the swap chain.

Inherited Methods

Public Methods

public Frame acquireFrame ()

Acquires a Frame from the swap chain for rendering.

Buffers that are part of the frame can then be bound with bindBuffer(int). Once the frame is finished and all its constituent buffers are ready, call submit(BufferViewportList, float[]) to display it while applying lens distortion.

Note: If frame submission is asynchronous, e.g., when async reprojection is enabled, it's possible that no free frames will be available for acquisition. Under such circumstances, this method will fail and return null. The client should re-attempt acquisition after a reasonable delay, e.g., several milliseconds.

Note: Please make sure that the GL context from initializeGl() is current when this method is called, or that it lives in a share group with the initialization context.

Returns
  • Handle to the acquired frame. null if no frames are available.
Throws
RuntimeException if a previous Frame has not yet been submitted.

public int getBufferCount ()

Gets the number of buffers in each frame of the swap chain.

public void getBufferSize (int bufferIndex, Point sizeOut)

Retrieves the size of the specified pixel buffer.

Note: If the buffer was resized while the current frame was acquired, the return value will be different than the value obtained from the equivalent function for the current frame.

Parameters
bufferIndex Index of the buffer.
sizeOut The (output) dimensions of the specified buffer.

public void resizeBuffer (int bufferIndex, Point newSize)

Resizes the specified pixel buffer to the given size.

The frames are resized when they are unused, so the currently acquired frame will not be resized immediately.

Parameters
bufferIndex Index of the buffer.
newSize The new size for the specified buffer.

public void shutdown ()

Destroys the swap chain. The SwapChain instance should not be used after this call.