Class QuadPipelineGL30

  • All Implemented Interfaces:
    QuadPipeline

    public final class QuadPipelineGL30
    extends Object
    QuadPipeline for use with OpenGL 3.

    QuadPipelineGL30 draws quads using OpenGL 3 features. It uses a Vertex Buffer Object to store vertices in graphics memory and a Vertex Array Object to quickly switch which vertex attributes are enabled.

    Since GL_QUAD has been deprecated in OpenGL 3, this implementation uses two triangles to represent one quad. An alternative implementation using one GL_FAN per quad was also tested, but proved slower in most cases. Apparently the penalty imposed by the extra work required by the driver outweighed the benefit of transferring less vertices.

    • Constructor Detail

      • QuadPipelineGL30

        public QuadPipelineGL30​(com.jogamp.opengl.GL3 gl,
                                int shaderProgram)
        Constructs a QuadPipelineGL30.
        Parameters:
        gl - Current OpenGL context
        shaderProgram - Shader program to render quads with
        Throws:
        NullPointerException - if context is null
        IllegalArgumentException - if shader program is less than one
    • Method Detail

      • beginRendering

        public void beginRendering​(com.jogamp.opengl.GL gl)
        Description copied from interface: QuadPipeline
        Starts a render cycle with this QuadPipeline.
        Specified by:
        beginRendering in interface QuadPipeline
        Parameters:
        gl - Current OpenGL context
      • dispose

        public void dispose​(com.jogamp.opengl.GL gl)
        Description copied from interface: QuadPipeline
        Frees resources used by this QuadPipeline.
        Specified by:
        dispose in interface QuadPipeline
        Parameters:
        gl - Current OpenGL context
      • endRendering

        public void endRendering​(com.jogamp.opengl.GL gl)
        Description copied from interface: QuadPipeline
        Finishes a render cycle with this QuadPipeline.
        Specified by:
        endRendering in interface QuadPipeline
        Parameters:
        gl - Current OpenGL context
      • addQuad

        public final void addQuad​(com.jogamp.opengl.GL gl,
                                  Quad quad)
        Description copied from interface: QuadPipeline
        Adds a quad to this QuadPipeline.
        Specified by:
        addQuad in interface QuadPipeline
        Parameters:
        gl - Current OpenGL context
        quad - Quad to add to pipeline
      • flush

        public final void flush​(com.jogamp.opengl.GL gl)
        Description copied from interface: QuadPipeline
        Draws all vertices in this QuadPipeline.
        Specified by:
        flush in interface QuadPipeline
        Parameters:
        gl - Current OpenGL context
      • getSize

        public final int getSize()
        Description copied from interface: QuadPipeline
        Returns number of quads in this QuadPipeline.
        Specified by:
        getSize in interface QuadPipeline
        Returns:
        Number of quads in this pipeline, not negative
      • isEmpty

        public final boolean isEmpty()
        Description copied from interface: QuadPipeline
        Checks if there aren't any quads in this QuadPipeline.
        Specified by:
        isEmpty in interface QuadPipeline
        Returns:
        True if there aren't any quads in this pipeline
      • getSizeInBytes

        public final int getSizeInBytes()
        Returns size of vertices in the pipeline in bytes.
      • getSizeInPrimitives

        public final int getSizeInPrimitives()
        Returns number of primitives in the pipeline.
      • getSizeInVertices

        public final int getSizeInVertices()
        Returns number of vertices in the pipeline.