Package org.lwjgl.opengles
Class PixelFormat
- java.lang.Object
-
- org.lwjgl.opengles.PixelFormat
-
- All Implemented Interfaces:
PixelFormatLWJGL
public final class PixelFormat extends Object implements PixelFormatLWJGL
This class describes the configuration settings for an EGL surface. Instances of this class are used as arguments to Display.create(). The attributes specified in this class will be used to get EGLConfigs from an EGLDisplay. PixelFormat is not the best name for this class, but it matches the corresponding class in the official desktop LWJGL. Instances of this class are immutable. An example of the expected way to set the PixelFormat property values is the following:PixelFormat pf = new PixelFormat().withDepth(24).withSamples(4);
Attributes that correspond to EGL extensions will be silently ignored if those extensions are not supported by the EGLDisplay.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PixelFormat.Attrib
-
Constructor Summary
Constructors Constructor Description PixelFormat()
Creates a new PixelFormat with rgbSize = 8, alphaSize = 8 and depthSize = 16.PixelFormat(int alphaSize, int depthSize, int stencilSize)
Creates a new PixelFormat with rgbSize = 8 and the specified alphaSize, depthSize and stencilSize.PixelFormat(int alphaSize, int depthSize, int stencilSize, int samples)
Creates a new PixelFormat with rgbSize = 8 and the specified alphaSize, depthSize, stencilSize and samples.PixelFormat(int rgbSize, int alphaSize, int luminanceSize, int depthSize, int stencilSize, int samples)
Creates a new PixelFormat with the specified RGB sizes, EGL_ALPHA_SIZE, EGL_LUMINANCE_SIZE, EGL_DEPTH_SIZE, EGL_STENCIL_SIZE, EGL_SAMPLES.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getAttrib(PixelFormat.Attrib attrib)
Returns the value of the specified attribute.IntBuffer
getAttribBuffer(EGLDisplay display, int surfaceType, int[] lwjglAttribs)
Returns an IntBuffer that can be used to get/choose EGLConfigs.EGLConfig
getBestMatch(EGLConfig[] configs)
Returns the EGL config from the specified array that best matches this PixelFormat.void
setSurfaceAttribs(EGLSurface surface)
Applies this PixelFormat's surface attributes to the specified EGL surface.PixelFormat
withAlphaSize(int alphaSize)
Returns a new PixelFormat with the specified EGL_ALPHA_SIZE.PixelFormat
withCoverageSamplesNV(int samples)
Returns a new PixelFormat with the specified number of EGL_COVERAGE_SAMPLES_NV.PixelFormat
withDepthEncodingNonlinearNV(int depthEncoding)
Returns a new PixelFormat with the specified EGL_DEPTH_ENCODING_NONLINEAR_NV.PixelFormat
withDepthSize(int depthSize)
Returns a new PixelFormat with the specified EGL_DEPTH_SIZE.PixelFormat
withLuminanceSize(int luminanceSize)
Returns a new PixelFormat with the specified EGL_LUMINANCE_SIZE.PixelFormat
withMaxSwapInterval(int maxSwapInterval)
Returns a new PixelFormat with the specified EGL_MAX_SWAP_INTERVAL.PixelFormat
withMinSwapInterval(int minSwapInterval)
Returns a new PixelFormat with the specified EGL_MIN_SWAP_INTERVAL.PixelFormat
withMultisampleResolve(int multisampleResolve)
Returns a new PixelFormat with the specified EGL_MULTISAMPLE_RESOLVE value.PixelFormat
withRGBSize(int rgb)
Returns a new PixelFormat with the specified RGB sizes.PixelFormat
withRGBSize(int r, int g, int b)
Returns a new PixelFormat with the specified EGL_RED_SIZE, EGL_GREEN_SIZE and EGL_BLUE_SIZE.PixelFormat
withSamples(int samples)
Returns a new PixelFormat with the specified number of EGL_SAMPLES.PixelFormat
withStencilSize(int stencilSize)
Returns a new PixelFormat with the specified EGL_STENCIL_SIZE.PixelFormat
withSwapBehavior(int swapBehavior)
Returns a new PixelFormat with the specified EGL_SWAP_BEHAVIOR value.PixelFormat
withTransparentType(int transparentType, int r, int g, int b)
Returns a new PixelFormat with the specified EGL_TRANSPARENT_TYPE and the specified transparent RGB values.
-
-
-
Constructor Detail
-
PixelFormat
public PixelFormat()
Creates a new PixelFormat with rgbSize = 8, alphaSize = 8 and depthSize = 16.
-
PixelFormat
public PixelFormat(int alphaSize, int depthSize, int stencilSize)
Creates a new PixelFormat with rgbSize = 8 and the specified alphaSize, depthSize and stencilSize.- Parameters:
alphaSize
- the EGL_ALPHA_SIZE valuedepthSize
- the EGL_DEPTH_SIZE valuestencilSize
- the EGL_STENCIL_SIZE value- See Also:
PixelFormat(int, int, int, int, int, int)
-
PixelFormat
public PixelFormat(int alphaSize, int depthSize, int stencilSize, int samples)
Creates a new PixelFormat with rgbSize = 8 and the specified alphaSize, depthSize, stencilSize and samples.- Parameters:
alphaSize
- the EGL_ALPHA_SIZE valuedepthSize
- the EGL_DEPTH_SIZE valuestencilSize
- the EGL_STENCIL_SIZE valuesamples
- the EGL_SAMPLE_SIZE value- See Also:
PixelFormat(int, int, int, int, int, int)
-
PixelFormat
public PixelFormat(int rgbSize, int alphaSize, int luminanceSize, int depthSize, int stencilSize, int samples)
Creates a new PixelFormat with the specified RGB sizes, EGL_ALPHA_SIZE, EGL_LUMINANCE_SIZE, EGL_DEPTH_SIZE, EGL_STENCIL_SIZE, EGL_SAMPLES. All values must be greater than or equal to 0. rgbSize and luminanceSize cannot both be greater than 0. depthSize greater than 24 and stencilSize greater than 8 are not recommended. The corresponding EGL_SAMPLE_BUFFERS value will become 0 if samples is 0, or 1 if samples is greater than 0.- Parameters:
rgbSize
- the RGB sizesalphaSize
- the EGL_ALPHA_SIZE valueluminanceSize
- the EGL_LUMINANCE_SIZE valuedepthSize
- the EGL_DEPTH_SIZE valuestencilSize
- the EGL_STENCIL_SIZE valuesamples
- the EGL_SAMPLE_SIZE value
-
-
Method Detail
-
getAttribBuffer
public IntBuffer getAttribBuffer(EGLDisplay display, int surfaceType, int[] lwjglAttribs)
Returns an IntBuffer that can be used to get/choose EGLConfigs. The contents of the IntBuffer will be the sum of the source LWJGL attributes and the user-defined attributes from this PixelFormat's configuration. The source LWJGL attributes should not contain the EGL_SURFACE_TYPE attirube, or any attributes that are handled by PixelFormat. Attributes that correspond to EGL extensions will be checked against the extensions supported in the specified EGLDisplay. Attributes that correspond to unsupported extensions will not be included in the final EGLConfig query.- Parameters:
display
- the EGL display from which the EGLConfig is going to be retrievedlwjglAttribs
- the LWJGL attributes- Returns:
- the IntBuffer
-
getBestMatch
public EGLConfig getBestMatch(EGLConfig[] configs) throws LWJGLException
Returns the EGL config from the specified array that best matches this PixelFormat.- Parameters:
configs
- the EGL configs- Returns:
- the best match
- Throws:
LWJGLException
-
setSurfaceAttribs
public void setSurfaceAttribs(EGLSurface surface) throws LWJGLException
Applies this PixelFormat's surface attributes to the specified EGL surface.- Parameters:
surface
- the EGL surface- Throws:
LWJGLException
-
getAttrib
public int getAttrib(PixelFormat.Attrib attrib)
Returns the value of the specified attribute.- Parameters:
attrib
- the attribute to retrieve- Returns:
- the attribute's value
-
withRGBSize
public PixelFormat withRGBSize(int rgb)
Returns a new PixelFormat with the specified RGB sizes.- Parameters:
rgb
- the new EGL_RED_SIZE, EGL_GREEN_SIZE and EGL_BLUE_SIZE- Returns:
- the new PixelFormat
- See Also:
withRGBSize(int, int, int)
-
withRGBSize
public PixelFormat withRGBSize(int r, int g, int b)
Returns a new PixelFormat with the specified EGL_RED_SIZE, EGL_GREEN_SIZE and EGL_BLUE_SIZE. All 3 values must be greater than or equal to 0. If any of the 3 values is greater than 0, the luminanceSize will be set to 0.- Parameters:
r
- the new EGL_RED_SIZEg
- the new EGL_GREEN_SIZEb
- the new EGL_BLUE_SIZE- Returns:
- the new PixelFormat
-
withAlphaSize
public PixelFormat withAlphaSize(int alphaSize)
Returns a new PixelFormat with the specified EGL_ALPHA_SIZE. The alphaSize value must be greater than or equal to 0.- Parameters:
alphaSize
- the new EGL_ALPHA_SIZE- Returns:
- the new PixelFormat
-
withLuminanceSize
public PixelFormat withLuminanceSize(int luminanceSize)
Returns a new PixelFormat with the specified EGL_LUMINANCE_SIZE. The luminanceSize value must be greater than or equal to 0. If luminanceSize is greater than 0, the RGB sizes will be set to 0.- Parameters:
luminanceSize
- the new EGL_LUMINANCE_SIZE- Returns:
- the new PixelFormat
-
withDepthSize
public PixelFormat withDepthSize(int depthSize)
Returns a new PixelFormat with the specified EGL_DEPTH_SIZE. The depthSize value must be greater than or equal to 0. Values greater than 24 are not recommended.- Parameters:
depthSize
- the new EGL_DEPTH_SIZE- Returns:
- the new PixelFormat
-
withStencilSize
public PixelFormat withStencilSize(int stencilSize)
Returns a new PixelFormat with the specified EGL_STENCIL_SIZE. The stencilSize value must be greater than or equal to 0. Values greater than 8 are not recommended.- Parameters:
stencilSize
- the new EGL_STENCIL_SIZE- Returns:
- the new PixelFormat
-
withMinSwapInterval
public PixelFormat withMinSwapInterval(int minSwapInterval)
Returns a new PixelFormat with the specified EGL_MIN_SWAP_INTERVAL. The minSwapInterval value must be between 0 and this PixelFormat's EGL_MAX_SWAP_INTERVAL.- Parameters:
minSwapInterval
- the new EGL_MIN_SWAP_INTERVAL value- Returns:
- the new PixelFormat
-
withMaxSwapInterval
public PixelFormat withMaxSwapInterval(int maxSwapInterval)
Returns a new PixelFormat with the specified EGL_MAX_SWAP_INTERVAL. The maxSwapInterval value must be greater than or equal to this PixelFormat's EGL_MIN_SWAP_INTERVAL.- Parameters:
maxSwapInterval
- the new EGL_MAX_SWAP_INTERVAL value- Returns:
- the new PixelFormat
-
withSamples
public PixelFormat withSamples(int samples)
Returns a new PixelFormat with the specified number of EGL_SAMPLES. The samples value must be either 0 or greater than or equal to 2. The related EGL_SAMPLE_BUFFERS value will become 0 if samples is 0, or 1 if samples is greater than or equal to 2.- Parameters:
samples
- the new EGL_SAMPLES value- Returns:
- the new PixelFormat
-
withTransparentType
public PixelFormat withTransparentType(int transparentType, int r, int g, int b)
Returns a new PixelFormat with the specified EGL_TRANSPARENT_TYPE and the specified transparent RGB values. The transparentType must be either EGL_NONE or EGL_TRANSPARENT_RGB. When it is EGL_NONE, the RGB values are set to zero and ignored. When it is EGL_TRANSPARENT_RGB, the RGB values must be between 0 and 2^rgbSize - 1.- Parameters:
transparentType
- the new EGL_TRANSPARENT_TYPE valuer
- the new EGL_TRANSPARENT_RED_VALUEg
- the new EGL_TRANSPARENT_GREEN_VALUEb
- the new EGL_TRANSPARENT_BLUE_VALUE- Returns:
- the new PixelFormat
-
withMultisampleResolve
public PixelFormat withMultisampleResolve(int multisampleResolve)
Returns a new PixelFormat with the specified EGL_MULTISAMPLE_RESOLVE value. Valid values for multisampleResolve are EGL_MULTISAMPLE_RESOLVE_DEFAULT and EGL_MULTISAMPLE_RESOLVE_BOX. An IllegalStateException will be thrown if EGL_SAMPLES has not been previously defined to be greater than or equal to 2.- Parameters:
multisampleResolve
- the new EGL_MULTISAMPLE_RESOLVE value- Returns:
- the new PixelFormat
-
withSwapBehavior
public PixelFormat withSwapBehavior(int swapBehavior)
Returns a new PixelFormat with the specified EGL_SWAP_BEHAVIOR value. Valid values for swapBehavior are EGL_DONT_CARE, EGL_BUFFER_PRESERVED and EGL_BUFFER_DESTROYED.- Parameters:
swapBehavior
- the new EGL_SWAP_BEHAVIOR value- Returns:
- the new PixelFormat
-
withCoverageSamplesNV
public PixelFormat withCoverageSamplesNV(int samples)
Returns a new PixelFormat with the specified number of EGL_COVERAGE_SAMPLES_NV. The samples value must be greater than or equal to 0. The related EGL_COVERAGE_BUFFERS_NV value will become 0 if samples is 0, or 1 if samples is greater than 0.- Parameters:
samples
- the new EGL_SAMPLES value- Returns:
- the new PixelFormat
-
withDepthEncodingNonlinearNV
public PixelFormat withDepthEncodingNonlinearNV(int depthEncoding)
Returns a new PixelFormat with the specified EGL_DEPTH_ENCODING_NONLINEAR_NV. Valid values for depthEncoding are EGL_DONT_CARE, EGL_DEPTH_ENCODING_NONE_NV and EGL_DEPTH_ENCODING_NONLINEAR_NV.- Parameters:
depthEncoding
- the new EGL_DEPTH_ENCODING_NONLINEAR_NV value- Returns:
- the new PixelFormat
-
-