Package com.banuba.sdk.internal.gl
Class GlUtils
java.lang.Object
com.banuba.sdk.internal.gl.GlUtils
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final float
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final float
static final int
static final com.banuba.sdk.internal.gl.GlUtils.PrecisionEnum
static final int
static final int
static final int
static final int
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
calculateCameraMatrix
(float[] matrix, float angle, int flip) static void
checkGlError
(String op) Checks to see if a GLES error has been raised.static void
static void
checkLocation
(int location, String label) Checks to see if the location we obtained is valid.static void
copyMatrix
(float[] src, float[] dest) static int
static FloatBuffer
createFloatBuffer
(float[] coords) Allocates a direct float buffer, and populates it with the float array data.static int
createImageTexture
(ByteBuffer data, int width, int height, int format) Creates a texture from raw data.static int
createProgram
(String vertexSource, 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[]
static float[]
static void
initColorArray
(float[] colorArray, int iColor) static FloatBuffer
initFloatBuffer
(float[] inFloatArray) static int
loadProgram
(String vertShaderSrc, String fragShaderSrc) static int
loadShader
(int shaderType, String source) Compiles the provided shader source.static int
loadTextureFromBitmap
(android.graphics.Bitmap bitmap) static int
loadTextureFromFile
(File file) static int
loadTextureFromRawRes
(int resID, android.content.Context context) static int
loadTextureLuminance
(ByteBuffer buffer, int width, int height, int format) static void
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
static void
static void
setupSampler
(int samplerIndex, int location, int texture, boolean external) static int
setupVertexBuffer
(float[] vertexArray) static int[]
setupVertexTextureBuffers
(float[] vertexArray, float[] textureArray)
-
Field Details
-
PRECISION
public static final com.banuba.sdk.internal.gl.GlUtils.PrecisionEnum PRECISION -
MATRIX_SIZE
public static final int MATRIX_SIZE- See Also:
-
FLOAT_SIZE
public static final int FLOAT_SIZE- See Also:
-
SHORT_SIZE
public static final int SHORT_SIZE- See Also:
-
INT_SIZE
public static final int INT_SIZE- See Also:
-
OFFSET_ZERO
public static final int OFFSET_ZERO- See Also:
-
COUNT_ONE
public static final int COUNT_ONE- See Also:
-
DEPTH_NEAR
public static final int DEPTH_NEAR- See Also:
-
DEPTH_FAR
public static final int DEPTH_FAR- See Also:
-
VERTEX_PER_FACE
public static final int VERTEX_PER_FACE- See Also:
-
COORDS_PER_VERTEX
public static final int COORDS_PER_VERTEX- See Also:
-
COORDS_UV_PER_TEXTURE
public static final int COORDS_UV_PER_TEXTURE- See Also:
-
VERTEX_STRIDE
public static final int VERTEX_STRIDE- See Also:
-
TEXTURE_STRIDE
public static final int TEXTURE_STRIDE- See Also:
-
GL_DEFAULT_RENDER_BUFFER
public static final int GL_DEFAULT_RENDER_BUFFER- See Also:
-
GL_DEFAULT_TEXTURE_ID
public static final int GL_DEFAULT_TEXTURE_ID- See Also:
-
GL_DEFAULT_PROGRAM_ID
public static final int GL_DEFAULT_PROGRAM_ID- See Also:
-
GL_TEXTURE0
public static final int GL_TEXTURE0- See Also:
-
GL_TEXTURE1
public static final int GL_TEXTURE1- See Also:
-
GL_TEXTURE2
public static final int GL_TEXTURE2- See Also:
-
GL_TEXTURE3
public static final int GL_TEXTURE3- See Also:
-
GL_TEXTURE4
public static final int GL_TEXTURE4- See Also:
-
MAX_COLOR_FLOAT_VALUE
public static final float MAX_COLOR_FLOAT_VALUE- See Also:
-
DEFAULT_ALPHA
public static final float DEFAULT_ALPHA- See Also:
-
-
Method Details
-
copyMatrix
public static void copyMatrix(@NonNull float[] src, @NonNull float[] dest) -
getIdentityMatrix
public static float[] getIdentityMatrix() -
getNewIdentityMatrix
public static float[] getNewIdentityMatrix() -
initFloatBuffer
-
initColorArray
public static void initColorArray(float[] colorArray, int iColor) -
detectOpenGLES20
public static boolean detectOpenGLES20(android.content.Context context) -
loadShader
Compiles the provided shader source.- Returns:
- A handle to the shader, or 0 on failure.
-
loadProgram
-
loadTextureFromFile
-
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 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
Checks to see if a GLES error has been raised. -
checkGlErrorNoException
-
setupSampler
public static void setupSampler(int samplerIndex, int location, int texture, boolean external) -
createProgram
Creates a new program from the supplied vertex and fragment shaders.- Returns:
- A handle to the program, or 0 on failure.
-
checkLocation
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
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
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)
-