Class PixelFormat

  • All Implemented Interfaces:
    PixelFormatLWJGL

    public final class PixelFormat
    extends Object
    implements PixelFormatLWJGL
    This class describes pixel format properties for an OpenGL context. Instances of this class is used as arguments to Display.create(), Pbuffer.create() and AWTGLCanvas, to indicate minimum required properties.

    Instants of this class are immutable. An example of the expected way to set the PixelFormat property values is the following: PixelFormat pf = new PixelFormat().withDepthBits(24).withSamples(4).withSRGB(true);

    WARNING: Some pixel formats are known to cause troubles on certain buggy drivers. Example: Under Windows, specifying samples != 0 will enable the ARB pixel format selection path, which could trigger a crash.

    Version:
    $Revision$
    Author:
    elias_naur@sourceforge.net
    • Constructor Detail

      • PixelFormat

        public PixelFormat()
        Default pixel format is minimum 8 bits depth, and no alpha nor stencil requirements.
      • PixelFormat

        public PixelFormat​(int alpha,
                           int depth,
                           int stencil)
      • PixelFormat

        public PixelFormat​(int alpha,
                           int depth,
                           int stencil,
                           int samples)
      • PixelFormat

        public PixelFormat​(int bpp,
                           int alpha,
                           int depth,
                           int stencil,
                           int samples)
      • PixelFormat

        public PixelFormat​(int bpp,
                           int alpha,
                           int depth,
                           int stencil,
                           int samples,
                           int num_aux_buffers,
                           int accum_bpp,
                           int accum_alpha,
                           boolean stereo)
      • PixelFormat

        public PixelFormat​(int bpp,
                           int alpha,
                           int depth,
                           int stencil,
                           int samples,
                           int num_aux_buffers,
                           int accum_bpp,
                           int accum_alpha,
                           boolean stereo,
                           boolean floating_point)
    • Method Detail

      • getBitsPerPixel

        public int getBitsPerPixel()
      • withBitsPerPixel

        public PixelFormat withBitsPerPixel​(int bpp)
        Returns a new PixelFormat object with the same properties as this PixelFormat and the new bits per pixel value.
        Parameters:
        bpp - the new bits per pixel value.
        Returns:
        the new PixelFormat
      • getAlphaBits

        public int getAlphaBits()
      • withAlphaBits

        public PixelFormat withAlphaBits​(int alpha)
        Returns a new PixelFormat object with the same properties as this PixelFormat and the new alpha bits value.
        Parameters:
        alpha - the new alpha bits value.
        Returns:
        the new PixelFormat
      • getDepthBits

        public int getDepthBits()
      • withDepthBits

        public PixelFormat withDepthBits​(int depth)
        Returns a new PixelFormat object with the same properties as this PixelFormat and the new depth bits value.
        Parameters:
        depth - the new depth bits value.
        Returns:
        the new PixelFormat
      • getStencilBits

        public int getStencilBits()
      • withStencilBits

        public PixelFormat withStencilBits​(int stencil)
        Returns a new PixelFormat object with the same properties as this PixelFormat and the new stencil bits value.
        Parameters:
        stencil - the new stencil bits value.
        Returns:
        the new PixelFormat
      • getSamples

        public int getSamples()
      • withSamples

        public PixelFormat withSamples​(int samples)
        Returns a new PixelFormat object with the same properties as this PixelFormat and the new samples value.
        Parameters:
        samples - the new samples value.
        Returns:
        the new PixelFormat
      • withCoverageSamples

        public PixelFormat withCoverageSamples​(int colorSamples)
        Returns a new PixelFormat object with the same properties as this PixelFormat and the new color samples values. A value greater than 0 is valid only if the samples property is also greater than 0. Additionally, the color samples value needs to be lower than or equal to the samples property.
        Parameters:
        colorSamples - the new color samples value.
        Returns:
        the new PixelFormat
      • withCoverageSamples

        public PixelFormat withCoverageSamples​(int colorSamples,
                                               int coverageSamples)
        Returns a new PixelFormat object with the same properties as this PixelFormat and the new color samples and coverage samples values.
        Parameters:
        colorSamples - the new color samples value. This value must be lower than or equal to the coverage samples value.
        coverageSamples - the new coverage samples value.
        Returns:
        the new PixelFormat
      • getAuxBuffers

        public int getAuxBuffers()
      • withAuxBuffers

        public PixelFormat withAuxBuffers​(int num_aux_buffers)
        Returns a new PixelFormat object with the same properties as this PixelFormat and the new auxiliary buffers value.
        Parameters:
        num_aux_buffers - the new auxiliary buffers value.
        Returns:
        the new PixelFormat
      • getAccumulationBitsPerPixel

        public int getAccumulationBitsPerPixel()
      • withAccumulationBitsPerPixel

        public PixelFormat withAccumulationBitsPerPixel​(int accum_bpp)
        Returns a new PixelFormat object with the same properties as this PixelFormat and the new bits per pixel in the accumulation buffer value.
        Parameters:
        accum_bpp - the new bits per pixel in the accumulation buffer value.
        Returns:
        the new PixelFormat
      • getAccumulationAlpha

        public int getAccumulationAlpha()
      • withAccumulationAlpha

        public PixelFormat withAccumulationAlpha​(int accum_alpha)
        Returns a new PixelFormat object with the same properties as this PixelFormat and the new alpha bits in the accumulation buffer value.
        Parameters:
        accum_alpha - the new alpha bits in the accumulation buffer value.
        Returns:
        the new PixelFormat
      • isStereo

        public boolean isStereo()
      • withStereo

        public PixelFormat withStereo​(boolean stereo)
        Returns a new PixelFormat object with the same properties as this PixelFormat and the new stereo value.
        Parameters:
        stereo - the new stereo value.
        Returns:
        the new PixelFormat
      • isFloatingPoint

        public boolean isFloatingPoint()
      • withFloatingPoint

        public PixelFormat withFloatingPoint​(boolean floating_point)
        Returns a new PixelFormat object with the same properties as this PixelFormat and the new floating point value. If floating_point is true, floating_point_packed will be reset to false.
        Parameters:
        floating_point - the new floating point value.
        Returns:
        the new PixelFormat
      • withFloatingPointPacked

        public PixelFormat withFloatingPointPacked​(boolean floating_point_packed)
        Returns a new PixelFormat object with the same properties as this PixelFormat and the new packed floating point value. If floating_point_packed is true, floating_point will be reset to false.
        Parameters:
        floating_point_packed - the new packed floating point value.
        Returns:
        the new PixelFormat
      • isSRGB

        public boolean isSRGB()
      • withSRGB

        public PixelFormat withSRGB​(boolean sRGB)
        Returns a new PixelFormat object with the same properties as this PixelFormat and the new sRGB value.
        Parameters:
        sRGB - the new floating point value.
        Returns:
        the new PixelFormat