31 #include <android/log.h>
33 #include <GLES3/gl3.h>
41 using namespace MaliSDK;
139 for (
int allComponents = 0;
162 for (
int allComponents = 0;
185 "Could not retrieve triangle representation of a cube");
219 GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER,
221 GL_CHECK(glBufferData(GL_ARRAY_BUFFER,
228 GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER,
230 GL_CHECK(glBufferData(GL_ARRAY_BUFFER,
237 GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER,
239 GL_CHECK(glBufferData(GL_ARRAY_BUFFER,
244 GL_CHECK(glBufferSubData(GL_ARRAY_BUFFER,
248 GL_CHECK(glBufferSubData(GL_ARRAY_BUFFER,
328 GL_CHECK(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
339 GL_CHECK(glDrawArraysInstanced(GL_TRIANGLES,
368 GL_CHECK(glBindBuffer (GL_ARRAY_BUFFER,
379 GL_CHECK(glBindBuffer (GL_ARRAY_BUFFER,
406 GL_CHECK(glBindBufferBase (GL_UNIFORM_BUFFER,
441 JNIEnv * env, jobject obj, jint
width, jint
height)
447 JNIEnv * env, jobject obj)
454 JNIEnv * env, jobject obj)
const int numberOfValuesInCubeColorsArray
GLint perspectiveMatrixLocation
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_instancing_NativeLibrary_init(JNIEnv *env, jobject obj, jint width, jint height)
GLint cameraPositionLocation
float getTime()
Returns the time passed since object creation or since reset() was last called.
void fillCubeColorsArray()
Fill cubeColors array with random color (used for setting random color for each cube).
GLfloat cubeColors[numberOfValuesInCubeColorsArray]
GLint GLsizei GLsizei height
GLuint uniformBlockDataBufferObjectId
Provides a platform independent high resolution timer.
#define NUMBER_OF_COLOR_COMPONENTS
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_instancing_NativeLibrary_uninit(JNIEnv *env, jobject obj)
GLuint renderingProgramId
GLuint cubeCoordinatesBufferObjectId
#define VERTEX_SHADER_FILE_NAME
A 3D floating point vector.
void reset()
Resets the timer to 0.0f.
int numberOfCubeTriangleCoordinates
void uninit()
Delete created objects and free allocated memory.
void generateStartPosition()
Generate positions of cubes which are used during first draw call.
GLint cubeVertexColorLocation
GLfloat startPosition[NUMBER_OF_CUBES]
static void getTriangleRepresentation(float scalingFactor, int *numberOfCoordinates, float **coordinates)
Compute coordinates of points which make up a cube.
#define M_PI
The value of pi.
#define FRAGMENT_SHADER_FILE_NAME
void initializeData()
Initializes data used for rendering.
GLuint cubeColorsBufferObjectId
void fillVertexColorsArray()
Fill vertexColors array with random color for each triangle vertex.
GLuint bufferObjectIds[numberOfBufferObjectIds]
float * cubeTrianglesCoordinates
int numberOfValuesInVertexColorsArray
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_instancing_NativeLibrary_step(JNIEnv *env, jobject obj)
#define NUMBER_OF_POINT_COORDINATES
Number of coordinates for a point in 3D space.
typedef GLfloat(GL_APIENTRYP PFNGLGETPATHLENGTHNVPROC)(GLuint path
const GLuint numberOfBufferObjectIds
static void processShader(GLuint *shader, const char *filename, GLint shaderType)
Create shader, load in source, compile, and dump debug as necessary.
typedef GLuint(GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count
A 4D floating point vector.