Class OGL20Graphics
- All Implemented Interfaces:
OGLVersioned
- Direct Known Subclasses:
OGL21Graphics
OpenGL 2.0 Graphics Implementation.
- Author:
- Matthew Tropiano
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class OGL13Graphics
OGL13Graphics.Info13Nested classes/interfaces inherited from class OGL11Graphics
OGL11Graphics.Info11Nested classes/interfaces inherited from class OGLGraphics
OGLGraphics.ErrorHandlingType, OGLGraphics.Info, OGLGraphics.Options -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidattachProgramShaders(OGLProgram program, OGLProgramShader... shaders) Attaches a shader to a program.createFileSourceSupplier(File sourceFile) Creates a supplier that gets the source from a file.createFileSourceSupplier(File sourceFile, Charset encoding) Creates a supplier that gets the source from a file.protected OGLGraphics.InfoCalled once in order to fetch context info.Creates a new program object.Creates a new program builder.createProgramShader(ShaderType type, String streamName, String sourceCode) Creates a new shader object (vertex, fragment, etc.).createProgramShader(ShaderType type, String streamName, Supplier<String> sourceSupplier) Creates a new shader object (vertex, fragment, etc.).createReaderSourceSupplier(Reader reader) Creates a supplier that gets the source from a Reader.createStreamSourceSupplier(InputStream sourceStream) Creates a supplier that gets the source from an input stream.createStreamSourceSupplier(InputStream sourceStream, Charset encoding) Creates a supplier that gets the source from an input stream.voiddestroyProgram(OGLProgram program) Destroys a program.voiddestroyProgramShader(OGLProgramShader shader) Destroys a program shader.voiddetachProgramShaders(OGLProgram program, OGLProgramShader... shaders) Detaches a shader from a program.protected voidendFrame()Called on frame end - mostly does cleanup of objects that were abandoned in OpenGL.Gets the currently bound program.voidlinkProgram(OGLProgram program) Links the program with its attached program shaders.protected voidRefreshes an OGLProgram's link status, uniforms, and attributes.voidsetFrameBufferWrite(FrameBufferType... types) Sets the multiple buffers to write to for pixel drawing/rasterizing operations.voidsetPointSpritesEnabled(boolean enabled) Enables/Disables point sprite conversion.voidsetPointSpriteTexCoordGeneration(boolean enabled) Sets if texture coordinates are to be generated across point geometry dimensions.voidsetProgram(OGLProgram program) Binds a program to the current context.voidsetProgramUniformFloat(int locationId, float value) Sets a uniform float value on the currently-bound program.voidsetProgramUniformFloatArray(int locationId, float... values) Sets a uniform float array value on the currently-bound program.voidsetProgramUniformInt(int locationId, int value) Sets a uniform integer value on the currently-bound program.voidsetProgramUniformIntArray(int locationId, int... values) Sets a uniform integer value array on the currently-bound program.voidsetProgramUniformIVec2(int locationId, int value0, int value1) Sets a uniform integer vec2 value on the currently-bound program.voidsetProgramUniformIVec3(int locationId, int value0, int value1, int value2) Sets a uniform integer vec3 value on the currently-bound program.voidsetProgramUniformIVec4(int locationId, int value0, int value1, int value2, int value3) Sets a uniform integer vec4 value on the currently-bound program.voidsetProgramUniformMatrix2(int locationId, float[] matrix) Sets a uniform matrix (mat2) value on the currently-bound program.voidsetProgramUniformMatrix2(int locationId, float[][] matrix) Sets a uniform matrix (mat2) value on the currently-bound program.voidsetProgramUniformMatrix3(int locationId, float[] matrix) Sets a uniform matrix (mat3) value on the currently-bound program.voidsetProgramUniformMatrix3(int locationId, float[][] matrix) Sets a uniform matrix (mat3) value on the currently-bound program.voidsetProgramUniformMatrix4(int locationId, float[] matrix) Sets a uniform matrix (mat4) value on the currently-bound program.voidsetProgramUniformMatrix4(int locationId, float[][] matrix) Sets a uniform matrix (mat4) value on the currently-bound program.voidsetProgramUniformMatrix4(int locationId, MatrixMode matrixMode) Sets a uniform matrix (mat4) value on the currently-bound program using a matrix in the matrix stack.voidsetProgramUniformMatrix4(int locationId, Matrix4F matrix) Sets a uniform matrix (mat4) value on the currently-bound program.voidsetProgramUniformVec2(int locationId, float value0, float value1) Sets a uniform vec2 value on the currently-bound program.voidsetProgramUniformVec3(int locationId, float value0, float value1, float value2) Sets a uniform vec3 value on the currently-bound program.voidsetProgramUniformVec4(int locationId, float value0, float value1, float value2, float value3) Sets a uniform vec4 value on the currently-bound program.voidsetProgramVertexAttribLocation(OGLProgram program, String attribName, int index) Binds a specific index to a vertex attribute by name.voidsetVertexAttribBufferPointer(int index, DataType dataType, boolean normalize, int dimensions, int stride, int offset) Sets what positions in the currentBufferTargetType.GEOMETRY-bound buffer are used to draw polygonal information: This sets the vertex attribute pointers.voidsetVertexAttribEnabled(int index, boolean enable) Enables or disables the processing of bound vertex arrays and/or buffers at a specific attrib index.voidUnbinds a program from the current context.Methods inherited from class OGL15Graphics
createBuffer, createGeometryBuilder, createQuery, destroyBuffer, destroyQuery, endQuery, getBuffer, getCurrentBufferState, getQueryBooleanResult, getQueryResult, isQueryReady, mapByteBuffer, mapDoubleBuffer, mapFloatBuffer, mapIntBuffer, mapLongBuffer, mapShortBuffer, setBuffer, setBufferCapacity, setBufferData, setBufferData, setBufferData, setBufferData, setBufferData, setBufferData, setBufferSubData, setBufferSubData, setBufferSubData, setBufferSubData, setBufferSubData, setBufferSubData, setCurrentBufferState, setFogCoordinateSource, startQuery, unmapBuffer, unsetBufferMethods inherited from class OGL14Graphics
createTextureBuilder, setPointAttenuationFormula, setPointAttenuationMaximum, setPointAttenuationMinimum, setTextureFiltering, setTextureFiltering, setTextureLODBiasMethods inherited from class OGL13Graphics
getActiveTextureUnit, getCurrentActiveTextureUnitState, setActiveTextureUnit, setCurrentActiveTextureCoordArray, setCurrentActiveTextureUnitState, setTextureData, setTextureSubDataMethods inherited from class OGL12Graphics
drawGeometryElementRange, setTextureData, setTextureSubData, setTextureWrappingMethods inherited from class OGL11Graphics
accumulate, attribPop, attribPush, checkLightId, clear, clear, clientAttribPop, clientAttribPush, createTexture, destroyTexture, drawBitmap, drawGeometryArray, drawGeometryElements, finish, flush, getCurrentActiveTextureState, getCurrentMatrixId, getCurrentMatrixStack, getCurrentMatrixStack, getPixelPackAlignment, getPixelUnpackAlignment, getTexture, matrixAspectOrtho, matrixFrustum, matrixGet, matrixGet, matrixLookAt, matrixMode, matrixMultiply, matrixMultiply, matrixOrtho, matrixPerspective, matrixPop, matrixPush, matrixReset, matrixRotateX, matrixRotateY, matrixRotateZ, matrixScale, matrixSet, matrixSet, matrixTranslate, readFrameBuffer, resolveCurrentMatrixStack, setAutoNormalGen, setBackFillMode, setBlendingEnabled, setBlendingFunc, setBlendingFunc, setClearAccum, setClearColor, setClearDepth, setClearStencil, setColor, setColor, setColorARGB, setColorArrayEnabled, setColorArrayPointer, setColorMask, setColorMask, setCurrentActiveTextureState, setCurrentMatrixId, setDepthFunc, setDepthMask, setDepthTestEnabled, setFaceCullingEnabled, setFaceCullingSide, setFaceFront, setFillMode, setFogColor, setFogColor, setFogColor, setFogDensity, setFogEnabled, setFogEnd, setFogExponent, setFogExponentSquared, setFogFormula, setFogLinear, setFogStart, setFrameBufferRead, setFrameBufferWrite, setFrontFillMode, setHint, setLight, setLightAmbientColor, setLightAmbientColor, setLightAmbientColor, setLightAttenuation, setLightDiffuseColor, setLightDiffuseColor, setLightDiffuseColor, setLightEnabled, setLightingEnabled, setLightPosition, setLightShadeType, setLightSpecularColor, setLightSpecularColor, setLightSpecularColor, setLineSmoothingEnabled, setLineWidth, setMaterial, setMaterial, setMaterialAmbientColor, setMaterialAmbientColor, setMaterialAmbientColor, setMaterialDiffuseColor, setMaterialDiffuseColor, setMaterialDiffuseColor, setMaterialEmissionColor, setMaterialEmissionColor, setMaterialEmissionColor, setMaterialShininessFactor, setMaterialSpecularColor, setMaterialSpecularColor, setMaterialSpecularColor, setNormalArrayEnabled, setNormalArrayPointer, setPixelPackAlignment, setPixelUnpackAlignment, setPointSize, setPointSmoothingEnabled, setRasterPosition, setScissorBounds, setScissorTestEnabled, setStencilMask, setStencilTestEnabled, setStencilTestFunc, setStencilTestOperations, setTexGenEyePlane, setTexGenMode, setTexGenObjectPlane, setTexGenQEnabled, setTexGenREnabled, setTexGenSEnabled, setTexGenTEnabled, setTexture, setTextureCoordinateArrayEnabled, setTextureCoordinateArrayPointer, setTextureData, setTextureData, setTextureDataFromReadBuffer, setTextureDataFromReadBuffer, setTextureEnabled, setTextureEnvironment, setTextureFiltering, setTextureFiltering, setTextureSubData, setTextureSubData, setTextureSubDataFromReadBuffer, setTextureSubDataFromReadBuffer, setTextureWrapping, setTextureWrapping, setVertexArrayEnabled, setVertexArrayPointer, setViewport, unsetTextureMethods inherited from class OGLGraphics
checkError, clearError, currentBlit, currentFrame, currentNanos, currentTime, currentTimeMillis, currentTimeStepMillis, currentTimeStepNanos, destroyObject, fromGLBool, getCanvasAspect, getCanvasHeight, getCanvasWidth, getFloat, getFloats, getGLErrorName, getInfo, getInt, getInts, handleUndeletedObjects, isCore, setClientFlag, setFlag, supports, toGLBool, verifyFeatureSupport, verifyNonCore
-
Constructor Details
-
OGL20Graphics
-
-
Method Details
-
getVersion
- Specified by:
getVersionin interfaceOGLVersioned- Overrides:
getVersionin classOGL15Graphics- Returns:
- the version that this object or value is available for (and higher).
-
createInfo
Description copied from class:OGLGraphicsCalled once in order to fetch context info.- Overrides:
createInfoin classOGL13Graphics- Returns:
- the info object.
-
endFrame
protected void endFrame()Description copied from class:OGLGraphicsCalled on frame end - mostly does cleanup of objects that were abandoned in OpenGL.- Overrides:
endFramein classOGL15Graphics
-
setPointSpritesEnabled
public void setPointSpritesEnabled(boolean enabled) Enables/Disables point sprite conversion. Internally, OpenGL will convert point geometry into billboarded quads or actual polygonal information.- Parameters:
enabled- true to enable, false to disable.
-
setPointSpriteTexCoordGeneration
public void setPointSpriteTexCoordGeneration(boolean enabled) Sets if texture coordinates are to be generated across point geometry dimensions. Useful for Point Sprites, obviously.- Parameters:
enabled- true to enable, false to disable.
-
setFrameBufferWrite
Sets the multiple buffers to write to for pixel drawing/rasterizing operations. By default, this is just the BACK buffer in double-buffered contexts.- Parameters:
types- the buffers to write to from now on, made available to shader programs.- Throws:
GraphicsException- if one of the types is NONE, LEFT, RIGHT, FRONT, BACK, or FRONT_AND_BACK.
-
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.Limitations on this implementation version are: No fragment data binding.
- Returns:
- a new program builder.
-
createProgramShader
Creates a new shader object (vertex, fragment, etc.).- Parameters:
type- the shader type. if not a valid shader type, this throws an exception.streamName- the name of the originating stream (can appear in exceptions).sourceCode- the code to compile.- Returns:
- the instantiated shader.
- Throws:
UnsupportedOperationException- if the provided shader type is unavailable in this version.NullPointerException- if either string is null.
-
createProgramShader
public OGLProgramShader createProgramShader(ShaderType type, String streamName, Supplier<String> sourceSupplier) Creates a new shader object (vertex, fragment, etc.).- Parameters:
type- the shader type. if not a valid shader type, this throws an exception.streamName- the name of the originating stream (can appear in exceptions).sourceSupplier- the supplier function for the source code.- Returns:
- the instantiated shader.
- Throws:
UnsupportedOperationException- if the provided shader type is unavailable in this version.NullPointerException- if either string is null.
-
destroyProgramShader
Destroys a program shader.- Parameters:
shader- the shader to destroy.
-
createProgram
Creates a new program object.- Returns:
- a new program object.
- Throws:
GraphicsException- if the object could not be created.
-
destroyProgram
Destroys a program.- Parameters:
program- the program to destroy.
-
attachProgramShaders
Attaches a shader to a program. Throws an error if this program was already linked, or if a program of the same type was already attached.- Parameters:
program- the program to attach the shaders to.shaders- the shaders to attach.- Throws:
GraphicsException- if this program was already linked, or if a shader of the same type was already attached.
-
detachProgramShaders
Detaches a shader from a program. Throws an error if a program of the same type was already detached.- Parameters:
program- the program to detach shaders from.shaders- the shaders to detach.
-
refreshProgramLinkStatusAndUniforms
Refreshes an OGLProgram's link status, uniforms, and attributes. Should be called when a program is updated via binary upload.- Parameters:
program- the program to update.
-
setProgramVertexAttribLocation
Binds a specific index to a vertex attribute by name. Must be done before program link.- Parameters:
program- the program.attribName- the vertex attribute name in the shader.index- the desired index.- Throws:
GraphicsException- if the program shader has been linked already.
-
linkProgram
Links the program with its attached program shaders.- Parameters:
program- the program to link.- Throws:
GraphicsException- if an error occurred during link.
-
getProgram
Gets the currently bound program.- Returns:
- the program, or null if no bound program.
-
setProgram
Binds a program to the current context.- Parameters:
program- the program to bind.
-
setProgramUniformInt
public void setProgramUniformInt(int locationId, int value) Sets a uniform integer value on the currently-bound program.- Parameters:
locationId- the uniform location.value- the value to set.
-
setProgramUniformIntArray
public void setProgramUniformIntArray(int locationId, int... values) Sets a uniform integer value array on the currently-bound program.- Parameters:
locationId- the uniform location.values- the values to set.
-
setProgramUniformFloat
public void setProgramUniformFloat(int locationId, float value) Sets a uniform float value on the currently-bound program.- Parameters:
locationId- the uniform location.value- the value to set.
-
setProgramUniformFloatArray
public void setProgramUniformFloatArray(int locationId, float... values) Sets a uniform float array value on the currently-bound program.- Parameters:
locationId- the uniform location.values- the values to set.
-
setProgramUniformVec2
public void setProgramUniformVec2(int locationId, float value0, float value1) Sets a uniform vec2 value on the currently-bound program.- Parameters:
locationId- the uniform location.value0- the first value to set.value1- the second value to set.
-
setProgramUniformVec3
public void setProgramUniformVec3(int locationId, float value0, float value1, float value2) Sets a uniform vec3 value on the currently-bound program.- Parameters:
locationId- the uniform location.value0- the first value to set.value1- the second value to set.value2- the third value to set.
-
setProgramUniformVec4
public void setProgramUniformVec4(int locationId, float value0, float value1, float value2, float value3) Sets a uniform vec4 value on the currently-bound program.- 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.
-
setProgramUniformIVec2
public void setProgramUniformIVec2(int locationId, int value0, int value1) Sets a uniform integer vec2 value on the currently-bound program.- Parameters:
locationId- the uniform location.value0- the first value to set.value1- the second value to set.
-
setProgramUniformIVec3
public void setProgramUniformIVec3(int locationId, int value0, int value1, int value2) Sets a uniform integer vec3 value on the currently-bound program.- Parameters:
locationId- the uniform location.value0- the first value to set.value1- the second value to set.value2- the third value to set.
-
setProgramUniformIVec4
public void setProgramUniformIVec4(int locationId, int value0, int value1, int value2, int value3) Sets a uniform integer vec4 value on the currently-bound program.- 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.
-
setProgramUniformMatrix2
public void setProgramUniformMatrix2(int locationId, float[] matrix) Sets a uniform matrix (mat2) value on the currently-bound program.- Parameters:
locationId- the uniform location.matrix- the column-major array of values.- Throws:
ArrayIndexOutOfBoundsException- if matrix is not 4 elements or greater and a value is fetched out-of-bounds.
-
setProgramUniformMatrix2
public void setProgramUniformMatrix2(int locationId, float[][] matrix) Sets a uniform matrix (mat2) value on the currently-bound program.- Parameters:
locationId- the uniform location.matrix- the multidimensional array of values, each array as one row of values.- Throws:
ArrayIndexOutOfBoundsException- if matrix is not 2x2 or greater and a value is fetched out-of-bounds.
-
setProgramUniformMatrix3
public void setProgramUniformMatrix3(int locationId, float[] matrix) Sets a uniform matrix (mat3) value on the currently-bound program.- Parameters:
locationId- the uniform location.matrix- the column-major array of values.- Throws:
ArrayIndexOutOfBoundsException- if matrix is not 9 elements or greater and a value is fetched out-of-bounds.
-
setProgramUniformMatrix3
public void setProgramUniformMatrix3(int locationId, float[][] matrix) Sets a uniform matrix (mat3) value on the currently-bound program.- Parameters:
locationId- the uniform location.matrix- the multidimensional array of values, each array as one row of values.- Throws:
ArrayIndexOutOfBoundsException- if matrix is not 3x3 or greater and a value is fetched out-of-bounds.
-
setProgramUniformMatrix4
public void setProgramUniformMatrix4(int locationId, float[] matrix) Sets a uniform matrix (mat4) value on the currently-bound program.- Parameters:
locationId- the uniform location.matrix- the column-major array of values.- Throws:
ArrayIndexOutOfBoundsException- if matrix is not 16 elements or greater and a value is fetched out-of-bounds.
-
setProgramUniformMatrix4
public void setProgramUniformMatrix4(int locationId, float[][] matrix) Sets a uniform matrix (mat4) value on the currently-bound program.- Parameters:
locationId- the uniform location.matrix- the multidimensional array of values, each array as one row of values.- Throws:
ArrayIndexOutOfBoundsException- if matrix is not 4x4 or greater and a value is fetched out-of-bounds.
-
setProgramUniformMatrix4
Sets a uniform matrix (mat4) value on the currently-bound program.- Parameters:
locationId- the uniform location.matrix- the multidimensional array of values, each array as one row of values.
-
setProgramUniformMatrix4
Sets a uniform matrix (mat4) value on the currently-bound program using a matrix in the matrix stack.- Parameters:
locationId- the uniform location.matrixMode- the matrix to grab values from.- Throws:
UnsupportedOperationException- if matrix modes are unavailable in this version (core implementation).
-
unsetProgram
public void unsetProgram()Unbinds a program from the current context. -
setVertexAttribEnabled
public void setVertexAttribEnabled(int index, boolean enable) Enables or disables the processing of bound vertex arrays and/or buffers at a specific attrib index.- Parameters:
index- the attribute index or uniform location id.enable- true to enable, false to disable.
-
setVertexAttribBufferPointer
public void setVertexAttribBufferPointer(int index, DataType dataType, boolean normalize, int dimensions, int stride, int offset) Sets what positions in the currentBufferTargetType.GEOMETRY-bound buffer are used to draw polygonal information: This sets the vertex attribute pointers. The index on this can also be a uniform location for an attrib pointer.- Parameters:
index- the attribute index.dataType- the data type contained in the buffer that will be read (calculates actual sizes of data).normalize- if true, the data is normalized on read ([-1, 1] for signed values, [0, 1] for unsigned). Else, read as-is.dimensions- the dimensions of a full set of attribute components (in elements; 3-dimensional vertices = 3).stride- the distance (in elements) between each attribute.offset- the offset in each stride where each attribute starts (in elements).- See Also:
-
createFileSourceSupplier
public static Supplier<String> createFileSourceSupplier(File sourceFile) throws FileNotFoundException, IOException Creates a supplier that gets the source from a file. Assumes system encoding.- Parameters:
sourceFile- the source file.- Returns:
- a supplier function for retrieving the source data.
- Throws:
FileNotFoundException- if the source file was not found.IOException- if the file could not be opened.SecurityException- if the file could not be opened, due to OS restrictions.
-
createFileSourceSupplier
public static Supplier<String> createFileSourceSupplier(File sourceFile, Charset encoding) throws FileNotFoundException, IOException Creates a supplier that gets the source from a file.- Parameters:
sourceFile- the source file.encoding- the encoding type of the file.- Returns:
- a supplier function for retrieving the source data.
- Throws:
FileNotFoundException- if the source file was not found.IOException- if the file could not be opened.SecurityException- if the file could not be opened, due to OS restrictions.
-
createStreamSourceSupplier
Creates a supplier that gets the source from an input stream. Assumes system encoding.- Parameters:
sourceStream- the input stream.- Returns:
- a supplier function for retrieving the source data.
-
createStreamSourceSupplier
public static Supplier<String> createStreamSourceSupplier(InputStream sourceStream, Charset encoding) Creates a supplier that gets the source from an input stream.- Parameters:
sourceStream- the input stream.encoding- the encoding type of the incoming data.- Returns:
- a supplier function for retrieving the source data.
-
createReaderSourceSupplier
-