Package com.banuba.sdk.internal.gl
Class GlUtils
- java.lang.Object
-
- com.banuba.sdk.internal.gl.GlUtils
-
public final class GlUtils extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static int
COORDS_PER_VERTEX
static int
COORDS_UV_PER_TEXTURE
static int
COUNT_ONE
static float
DEFAULT_ALPHA
static int
DEPTH_FAR
static int
DEPTH_NEAR
static int
FLOAT_SIZE
static int
GL_DEFAULT_PROGRAM_ID
static int
GL_DEFAULT_RENDER_BUFFER
static int
GL_DEFAULT_TEXTURE_ID
static int
GL_TEXTURE0
static int
GL_TEXTURE1
static int
GL_TEXTURE2
static int
GL_TEXTURE3
static int
GL_TEXTURE4
static int
INT_SIZE
static int
MATRIX_SIZE
static float
MAX_COLOR_FLOAT_VALUE
static int
OFFSET_ZERO
static com.banuba.sdk.internal.gl.GlUtils.PrecisionEnum
PRECISION
static int
SHORT_SIZE
static int
TEXTURE_STRIDE
static int
VERTEX_PER_FACE
static int
VERTEX_STRIDE
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
calculateCameraMatrix(float[] matrix, float angle, int flip)
static void
checkGlError(java.lang.String op)
Checks to see if a GLES error has been raised.static void
checkGlErrorNoException(java.lang.String op)
static void
checkLocation(int location, java.lang.String label)
Checks to see if the location we obtained is valid.static void
copyMatrix(float[] src, float[] dest)
static int
createExternalTextureObject()
static java.nio.FloatBuffer
createFloatBuffer(float[] coords)
Allocates a direct float buffer, and populates it with the float array data.static int
createImageTexture(java.nio.ByteBuffer data, int width, int height, int format)
Creates a texture from raw data.static int
createProgram(java.lang.String vertexSource, java.lang.String fragmentSource)
Creates a new program from the supplied vertex and fragment shaders.static int
createTextureFromDrawable(android.graphics.drawable.Drawable drawable, int width, int height)
static boolean
detectOpenGLES20(android.content.Context context)
static float[]
getIdentityMatrix()
static float[]
getNewIdentityMatrix()
static void
initColorArray(float[] colorArray, int iColor)
static java.nio.FloatBuffer
initFloatBuffer(float[] inFloatArray)
static int
loadProgram(java.lang.String vertShaderSrc, java.lang.String fragShaderSrc)
static int
loadShader(int shaderType, java.lang.String source)
Compiles the provided shader source.static int
loadTextureFromBitmap(android.graphics.Bitmap bitmap)
static int
loadTextureFromFile(java.io.File file)
static int
loadTextureFromRawRes(int resID, android.content.Context context)
static int
loadTextureLuminance(java.nio.ByteBuffer buffer, int width, int height, int format)
static void
logVersionInfo()
Writes GL version info to the log.static void
multiplyMM(float[] result, float[] lhs, float[] rhs)
static void
multiplyMM4(float[] result, float[] mat1, float[] mat2, float[] mat3, float[] mat4)
static void
printGlInfo()
static void
setupBlend()
static void
setupSampler(int samplerIndex, int location, int texture, boolean external)
static int
setupVertexBuffer(float[] vertexArray)
static int[]
setupVertexTextureBuffers(float[] vertexArray, float[] textureArray)
-
-
-
Field Detail
-
PRECISION
public static final com.banuba.sdk.internal.gl.GlUtils.PrecisionEnum PRECISION
-
MATRIX_SIZE
public static final int MATRIX_SIZE
- See Also:
- Constant Field Values
-
FLOAT_SIZE
public static final int FLOAT_SIZE
- See Also:
- Constant Field Values
-
SHORT_SIZE
public static final int SHORT_SIZE
- See Also:
- Constant Field Values
-
INT_SIZE
public static final int INT_SIZE
- See Also:
- Constant Field Values
-
OFFSET_ZERO
public static final int OFFSET_ZERO
- See Also:
- Constant Field Values
-
COUNT_ONE
public static final int COUNT_ONE
- See Also:
- Constant Field Values
-
DEPTH_NEAR
public static final int DEPTH_NEAR
- See Also:
- Constant Field Values
-
DEPTH_FAR
public static final int DEPTH_FAR
- See Also:
- Constant Field Values
-
VERTEX_PER_FACE
public static final int VERTEX_PER_FACE
- See Also:
- Constant Field Values
-
COORDS_PER_VERTEX
public static final int COORDS_PER_VERTEX
- See Also:
- Constant Field Values
-
COORDS_UV_PER_TEXTURE
public static final int COORDS_UV_PER_TEXTURE
- See Also:
- Constant Field Values
-
VERTEX_STRIDE
public static final int VERTEX_STRIDE
- See Also:
- Constant Field Values
-
TEXTURE_STRIDE
public static final int TEXTURE_STRIDE
- See Also:
- Constant Field Values
-
GL_DEFAULT_RENDER_BUFFER
public static final int GL_DEFAULT_RENDER_BUFFER
- See Also:
- Constant Field Values
-
GL_DEFAULT_TEXTURE_ID
public static final int GL_DEFAULT_TEXTURE_ID
- See Also:
- Constant Field Values
-
GL_DEFAULT_PROGRAM_ID
public static final int GL_DEFAULT_PROGRAM_ID
- See Also:
- Constant Field Values
-
GL_TEXTURE0
public static final int GL_TEXTURE0
- See Also:
- Constant Field Values
-
GL_TEXTURE1
public static final int GL_TEXTURE1
- See Also:
- Constant Field Values
-
GL_TEXTURE2
public static final int GL_TEXTURE2
- See Also:
- Constant Field Values
-
GL_TEXTURE3
public static final int GL_TEXTURE3
- See Also:
- Constant Field Values
-
GL_TEXTURE4
public static final int GL_TEXTURE4
- See Also:
- Constant Field Values
-
MAX_COLOR_FLOAT_VALUE
public static final float MAX_COLOR_FLOAT_VALUE
- See Also:
- Constant Field Values
-
DEFAULT_ALPHA
public static final float DEFAULT_ALPHA
- See Also:
- Constant Field Values
-
-
Method Detail
-
copyMatrix
public static void copyMatrix(@NonNull float[] src, @NonNull float[] dest)
-
getIdentityMatrix
public static float[] getIdentityMatrix()
-
getNewIdentityMatrix
public static float[] getNewIdentityMatrix()
-
initFloatBuffer
public static java.nio.FloatBuffer initFloatBuffer(float[] inFloatArray)
-
initColorArray
public static void initColorArray(float[] colorArray, int iColor)
-
detectOpenGLES20
public static boolean detectOpenGLES20(android.content.Context context)
-
loadShader
public static int loadShader(int shaderType, java.lang.String source)
Compiles the provided shader source.- Returns:
- A handle to the shader, or 0 on failure.
-
loadProgram
public static int loadProgram(@NonNull java.lang.String vertShaderSrc, @NonNull java.lang.String fragShaderSrc)
-
loadTextureFromFile
public static int loadTextureFromFile(@NonNull java.io.File file)
-
loadTextureFromBitmap
public static int loadTextureFromBitmap(@NonNull android.graphics.Bitmap bitmap)
-
loadTextureFromRawRes
public static int loadTextureFromRawRes(@RawRes int resID, android.content.Context context)
-
createTextureFromDrawable
public static int createTextureFromDrawable(android.graphics.drawable.Drawable drawable, int width, int height)
-
loadTextureLuminance
public static int loadTextureLuminance(@NonNull java.nio.ByteBuffer buffer, int width, int height, int format)
-
createExternalTextureObject
public static int createExternalTextureObject()
-
setupBlend
public static void setupBlend()
-
printGlInfo
public static void printGlInfo()
-
setupVertexBuffer
public static int setupVertexBuffer(float[] vertexArray)
-
setupVertexTextureBuffers
public static int[] setupVertexTextureBuffers(float[] vertexArray, float[] textureArray)
-
multiplyMM
public static void multiplyMM(float[] result, float[] lhs, float[] rhs)
-
multiplyMM4
public static void multiplyMM4(float[] result, float[] mat1, float[] mat2, float[] mat3, float[] mat4)
-
checkGlError
public static void checkGlError(java.lang.String op)
Checks to see if a GLES error has been raised.
-
checkGlErrorNoException
public static void checkGlErrorNoException(java.lang.String op)
-
setupSampler
public static void setupSampler(int samplerIndex, int location, int texture, boolean external)
-
createProgram
public static int createProgram(java.lang.String vertexSource, java.lang.String fragmentSource)
Creates a new program from the supplied vertex and fragment shaders.- Returns:
- A handle to the program, or 0 on failure.
-
checkLocation
public static void checkLocation(int location, java.lang.String label)
Checks to see if the location we obtained is valid. GLES returns -1 if a label could not be found, but does not set the GL error. Throws a RuntimeException if the location is invalid.
-
createImageTexture
public static int createImageTexture(java.nio.ByteBuffer data, int width, int height, int format)
Creates a texture from raw data.- Parameters:
data
- Image data, in a "direct" ByteBuffer.width
- Texture width, in pixels (not bytes).height
- Texture height, in pixels.format
- Image data format (use constant appropriate for glTexImage2D(), e.g. GL_RGBA).- Returns:
- Handle to texture.
-
createFloatBuffer
public static java.nio.FloatBuffer createFloatBuffer(float[] coords)
Allocates a direct float buffer, and populates it with the float array data.
-
logVersionInfo
public static void logVersionInfo()
Writes GL version info to the log.
-
calculateCameraMatrix
public static void calculateCameraMatrix(float[] matrix, float angle, int flip)
-
-