Class OGL30Graphics

All Implemented Interfaces:
OGLVersioned
Direct Known Subclasses:
OGL31Graphics

public class OGL30Graphics extends OGL21Graphics
OpenGL 3.0 Graphics Implementation.
Author:
Matthew Tropiano
  • Constructor Details

  • Method Details

    • getVersion

      public OGLVersion getVersion()
      Specified by:
      getVersion in interface OGLVersioned
      Overrides:
      getVersion in class OGL21Graphics
      Returns:
      the version that this object or value is available for (and higher).
    • createInfo

      protected OGLGraphics.Info createInfo()
      Description copied from class: OGLGraphics
      Called once in order to fetch context info.
      Overrides:
      createInfo in class OGL20Graphics
      Returns:
      the info object.
    • endFrame

      protected void endFrame()
      Description copied from class: OGLGraphics
      Called on frame end - mostly does cleanup of objects that were abandoned in OpenGL.
      Overrides:
      endFrame in class OGL20Graphics
    • matrixMode

      public void matrixMode(MatrixMode mode)
      Description copied from class: OGL11Graphics
      Sets the current matrix for matrix operations.
      Overrides:
      matrixMode in class OGL11Graphics
      Parameters:
      mode - the matrix mode to set.
    • matrixGet

      public void matrixGet(MatrixMode matrixType, float[] outArray)
      Description copied from class: OGL11Graphics
      Reads a current matrix into an array.

      This is technically not available in Core OpenGL, but is instead implemented using MatrixStack for core implementations.

      Overrides:
      matrixGet in class OGL11Graphics
      Parameters:
      matrixType - the type of matrix to load.
      outArray - the output array. Must be length 16 or greater.
    • matrixGet

      public void matrixGet(MatrixMode matrixType, Matrix4F matrix)
      Description copied from class: OGL11Graphics
      Reads a current matrix into a matrix.

      This is technically not available in Core OpenGL, but is instead implemented using MatrixStack for core implementations.

      Overrides:
      matrixGet in class OGL11Graphics
      Parameters:
      matrixType - the type of matrix to load.
      matrix - the output matrix.
    • setProgramUniformMatrix4

      public void setProgramUniformMatrix4(int locationId, MatrixMode matrixMode)
      Sets a uniform matrix (mat4) value on the currently-bound program using a matrix in the matrix stack.
      Overrides:
      setProgramUniformMatrix4 in class OGL20Graphics
      Parameters:
      locationId - the uniform location.
      matrixMode - the matrix to grab values from.
      Throws:
      UnsupportedOperationException - if matrix modes are unavailable in this version (core implementation).
    • setTextureFiltering

      public void setTextureFiltering(TextureTargetType target, TextureMinFilter minFilter, TextureMagFilter magFilter, boolean genMipmaps)
      Description copied from class: OGL14Graphics
      Sets the filtering for the current texture bound to the specified target.
      Overrides:
      setTextureFiltering in class OGL14Graphics
      Parameters:
      target - the texture target.
      minFilter - the minification filter.
      magFilter - the magnification filter.
      genMipmaps - if this generates mipmaps automatically.
    • setTextureFiltering

      public void setTextureFiltering(TextureTargetType target, TextureMinFilter minFilter, TextureMagFilter magFilter, float anisotropy, boolean genMipmaps)
      Description copied from class: OGL14Graphics
      Sets the filtering for the current texture bound to the specified target.
      Overrides:
      setTextureFiltering in class OGL14Graphics
      Parameters:
      target - the texture target.
      minFilter - the minification filter.
      magFilter - the magnification filter.
      anisotropy - the anisotropic filtering (2.0 or greater to enable, 1.0 or less is "off").
      genMipmaps - if this generates mipmaps automatically.
    • createProgramBuilder

      public ProgramBuilder createProgramBuilder()
      Creates a new program builder.

      This program builder aids in building shader program objects, and its ProgramBuilder.create() method will compile and link all of the shaders and return the new object.

      Overrides:
      createProgramBuilder in class OGL20Graphics
      Returns:
      a new program builder.
    • matrixId

      public void matrixId(int id)
      Sets the current matrix index.

      Use this if you want matrix stack functionality in a core profile.

      Parameters:
      id - the new current matrix id.
      Throws:
      UnsupportedOperationException - if this profile is not core OpenGL.
    • matrixGet

      public void matrixGet(int matrixId, float[] outArray)
      Reads a current matrix into an array.

      This is technically not available in Core OpenGL, but is instead implemented using MatrixStack for core implementations.

      Parameters:
      matrixId - the matrix id to fetch.
      outArray - the output array. Must be length 16 or greater.
      Throws:
      ArrayIndexOutOfBoundsException - if the array length is less than 16.
    • matrixGet

      public void matrixGet(int matrixId, Matrix4F matrix)
      Reads a current matrix into a matrix.

      This is technically not available in Core OpenGL, but is instead implemented using MatrixStack for core implementations.

      Parameters:
      matrixId - the matrix id to fetch.
      matrix - the output matrix.
    • setTransformFeedbackVaryingNames

      public void setTransformFeedbackVaryingNames(OGLProgram program, FeedbackBufferType type, String... variableNames)
      Sets the transform feedback varying variables for the bound shader program. Must be called before OGL20Graphics.linkProgram(OGLProgram) for the provided program.
      Parameters:
      program - the program to set the variables for.
      type - the feedback output type.
      variableNames - the names of the varying variables.
      Throws:
      IllegalStateException - if the provided program was already linked.
    • setProgramUniformMatrix4

      public void setProgramUniformMatrix4(int locationId, int matrixId)
      Sets a uniform matrix (mat4) value on the currently-bound program using a matrix in the matrix stack.
      Parameters:
      locationId - the uniform location.
      matrixId - the matrix stack id.
    • generateMipmaps

      public void generateMipmaps(TextureTargetType target)
      Generates mipmaps on-demand internally for the current texture bound to the provided target.
      Parameters:
      target - the texture target.
    • setShaderUniformUnsignedInt

      public void setShaderUniformUnsignedInt(int locationId, int value)
      Sets a uniform unsigned integer value on the currently-bound shader.
      Parameters:
      locationId - the uniform location.
      value - the value to set.
    • setShaderUniformUnsignedIntArray

      public void setShaderUniformUnsignedIntArray(int locationId, int... values)
      Sets a uniform unsigned integer value array on the currently-bound shader.
      Parameters:
      locationId - the uniform location.
      values - the values to set.
    • setShaderUniformUnsignedIVec2

      public void setShaderUniformUnsignedIVec2(int locationId, int value0, int value1)
      Sets a uniform integer vec2 value on the currently-bound shader.
      Parameters:
      locationId - the uniform location.
      value0 - the first value to set.
      value1 - the second value to set.
    • setShaderUniformUnsignedIVec3

      public void setShaderUniformUnsignedIVec3(int locationId, int value0, int value1, int value2)
      Sets a uniform integer vec3 value on the currently-bound shader.
      Parameters:
      locationId - the uniform location.
      value0 - the first value to set.
      value1 - the second value to set.
      value2 - the third value to set.
    • setShaderUniformUnsignedIVec4

      public void setShaderUniformUnsignedIVec4(int locationId, int value0, int value1, int value2, int value3)
      Sets a uniform integer vec4 value on the currently-bound shader.
      Parameters:
      locationId - the uniform location.
      value0 - the first value to set.
      value1 - the second value to set.
      value2 - the third value to set.
      value3 - the fourth value to set.
    • createVertexArrayState

      public OGLVertexArrayState createVertexArrayState(OGLBuffer buffer, GeometryBuilder builder)
      Creates a vertex array state object, which maintains the state of bound vertex attributes and bound buffer targets. This uses the content of a GeometryBuilder and the buffer it created to set the pointers used by the array state.
      Parameters:
      buffer - the buffer created by the builder.
      builder - the builder to get the attribute data from.
      Returns:
      the new object.
    • createVertexArrayState

      public OGLVertexArrayState createVertexArrayState()
      Creates a vertex array state object, which maintains the state of bound vertex attributes and bound buffer targets.
      Returns:
      the new object.
    • destroyVertexArrayState

      public void destroyVertexArrayState(OGLVertexArrayState arrayState)
      Destroys a vertex array state.
      Parameters:
      arrayState - the vertex array state to destroy.
    • setVertexArrayState

      public void setVertexArrayState(OGLVertexArrayState state)
      Sets the current vertex array state, which also restores all of the vertex attribute pointer and buffer target bindings associated with it. The following is saved by a vertex array state:
      Parameters:
      state - the state to set.
    • unsetVertexArrayState

      public void unsetVertexArrayState()
      Unbinds a vertex array state from the current context.
    • setProgramFragmentDataLocation

      public void setProgramFragmentDataLocation(OGLProgram program, String outVariableName, int colorIndex)
      Sets the location of a fragment output. Must be done before program link.
      Parameters:
      program - the shader to set it on.
      outVariableName - the name of the output variable.
      colorIndex - the color index (draw buffer index).
      Throws:
      GraphicsException - if the program shader has been linked already.
    • createRenderbuffer

      public OGLRenderbuffer createRenderbuffer()
      Creates a new render buffer object.
      Returns:
      a new, uninitialized render buffer object.
    • destroyRenderbuffer

      public void destroyRenderbuffer(OGLRenderbuffer renderBuffer)
      Destroys a render buffer.
      Parameters:
      renderBuffer - the render buffer to destroy.
    • setRenderbuffer

      public void setRenderbuffer(OGLRenderbuffer renderbuffer)
      Binds a FrameRenderBuffer to the current context.
      Parameters:
      renderbuffer - the render buffer to bind to the current render buffer.
    • setRenderbufferSize

      public void setRenderbufferSize(RenderbufferFormat format, int width, int height)
      Sets a render buffer's internal format and size.
      Parameters:
      format - the buffer format.
      width - the width in pixel data.
      height - the height in pixel data.
    • unsetRenderbuffer

      public void unsetRenderbuffer()
      Unbinds a FrameRenderBuffer from the current context.
    • createFramebuffer

      public OGLFramebuffer createFramebuffer()
      Creates a new framebuffer object.
      Returns:
      a new, uninitialized framebuffer object.
      Throws:
      GraphicsException - if the object could not be created.
    • destroyFramebuffer

      public void destroyFramebuffer(OGLFramebuffer frameBuffer)
      Destroys a framebuffer.
      Parameters:
      frameBuffer - the framebuffer to destroy.
    • setFramebuffer

      public void setFramebuffer(OGLFramebuffer framebuffer)
      Binds a FrameBuffer for rendering.
      Parameters:
      framebuffer - the framebuffer to set as the current one.
    • checkFramebufferStatus

      public void checkFramebufferStatus()
      Tests for frame buffer completeness on the bound framebuffer. If incomplete, this throws an exception.
      Throws:
      GraphicsException - if the framebuffer is incomplete.
    • attachFramebufferTexture2D

      public void attachFramebufferTexture2D(AttachPoint attachPoint, OGLTexture texture)
      Attaches a texture to this frame buffer for rendering directly to a texture.
      Parameters:
      attachPoint - the attachment source point.
      texture - the texture to attach this to.
    • detachFramebufferTexture2D

      public void detachFramebufferTexture2D(AttachPoint attachPoint)
      Detaches a texture from this frame buffer.
      Parameters:
      attachPoint - the attachment source point.
    • attachFramebufferRenderbuffer

      public void attachFramebufferRenderbuffer(AttachPoint attachPoint, OGLRenderbuffer renderBuffer)
      Attaches a render buffer to the current frame buffer.
      Parameters:
      attachPoint - the attachment source point.
      renderBuffer - the render buffer to attach this to.
    • detachFramebufferRenderbuffer

      public void detachFramebufferRenderbuffer(AttachPoint attachPoint)
      Detaches a render buffer from the current frame buffer.
      Parameters:
      attachPoint - the attachment source point.
    • unsetFramebuffer

      public void unsetFramebuffer()
      Unbinds a FrameBuffer for rendering. The current draw buffer will then be the default target buffer.
    • startConditionalRender

      public void startConditionalRender(OGLQuery query, QueryWaitType waitType)
      Starts a conditional render.
      Parameters:
      query - the query object to use.
      waitType - the wait type for query results.
      Throws:
      IllegalStateException - if a conditional render is already active.
    • endConditionalRender

      public void endConditionalRender()
      Ends a conditional render.
      Throws:
      IllegalStateException - if a conditional render is not active.
    • startTransformFeedback

      public void startTransformFeedback(PrimitiveMode primitiveMode)
      Starts a transform feedback. Requires batch calling for draw, an attached geometry program, and a bound BufferTargetType.TRANSFORM_FEEDBACK buffer for the results.
      Parameters:
      primitiveMode - the primitive draw mode.
      See Also:
    • endTransformFeedback

      public void endTransformFeedback()
      Ends a transform feedback.