BufferSpec

public class BufferSpec

Specification of a pixel buffer. A pixel buffer can have color, depth and stencil attachments and mostly corresponds to the OpenGL concept of a framebuffer object. However, since there can be multiple such objects for each frame, we avoid calling them "framebuffers". Pixel buffers which are part of the currently acquired frame are immutable, i.e., they cannot be resized or otherwise reconfigured.

Nested Classes

class BufferSpec.ColorFormat Available color formats. 
class BufferSpec.DepthStencilFormat Available depth & stencil formats. 

Public Methods

int
getSamples()
Gets the number of samples per pixel in the buffer to be created.
void
getSize(Point bufferSizeOut)
Gets the size of the buffer to be created.
static boolean
isValidColorFormat(int format)
Checks if the given integer is a legal color format.
static boolean
isValidDepthStencilFormat(int format)
Checks if the given integer is a legal depth-stencil format.
void
setColorFormat(int format)
Sets the format of the color attachment for the buffer to be created.
void
setDepthStencilFormat(int format)
Sets the format of the packed depth-stencil attachment for the buffer to be created.
void
setMultiviewLayers(int numLayers)
Sets the number of layers in a framebuffer backed by an array texture.
void
setSamples(int samples)
Sets the number of samples per pixel in the buffer to be created.
void
setSize(Point bufferSize)
Sets the size of the buffer to be created.
void
shutdown()
Shuts down the BufferSpec instance, freeing associated resources.

Inherited Methods

Public Methods

public int getSamples ()

Gets the number of samples per pixel in the buffer to be created.

Returns
  • Value >= 1 giving the number of samples. 1 means multisampling is disabled. Negative values and 0 are never returned.

public void getSize (Point bufferSizeOut)

Gets the size of the buffer to be created.

Parameters
bufferSizeOut The (output) size of the pixel buffer. The default is equal to the recommended render target size at the time when the specification was created.

public static boolean isValidColorFormat (int format)

Checks if the given integer is a legal color format.

Parameters
format Value to check.
Returns

public static boolean isValidDepthStencilFormat (int format)

Checks if the given integer is a legal depth-stencil format.

Parameters
format Value to check.
Returns

public void setColorFormat (int format)

Sets the format of the color attachment for the buffer to be created.

Parameters
format One of the available formats from BufferSpec.ColorFormat.

public void setDepthStencilFormat (int format)

Sets the format of the packed depth-stencil attachment for the buffer to be created.

Parameters
format One of the available formats from BufferSpec.DepthStencilFormat.

public void setMultiviewLayers (int numLayers)

Sets the number of layers in a framebuffer backed by an array texture. Default is 1, which means a non-layered texture will be created. Not all platforms support multiple layers, so clients can call GvrApi.isFeatureSupported(GvrApi.Feature.MULTIVIEW) to check.

Parameters
numLayers The number of layers in the array texture.

public void setSamples (int samples)

Sets the number of samples per pixel in the buffer to be created.

Parameters
samples The number of samples. Negative values are an error. The values 0 and 1 are treated identically and indicate that multisampling should be disabled.

public void setSize (Point bufferSize)

Sets the size of the buffer to be created.

Parameters
bufferSize The size. Width and height must both be greater than zero. Otherwise, the application is aborted.

public void shutdown ()

Shuts down the BufferSpec instance, freeing associated resources.

Note: The caller is responsible for ensuring that this BufferSpec isn't used after shutdown.