OpenGL ES SDK for Android ARM Developer Center
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Native.cpp
Go to the documentation of this file.
1 /* Copyright (c) 2014-2017, ARM Limited and Contributors
2  *
3  * SPDX-License-Identifier: MIT
4  *
5  * Permission is hereby granted, free of charge,
6  * to any person obtaining a copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
9  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
14  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19  */
20 
37 #include <jni.h>
38 #include <android/log.h>
39 
40 #include <GLES3/gl3.h>
41 #include "Boids.h"
42 #include "Common.h"
43 #include "Shader.h"
44 #include "SphereModel.h"
45 #include "Timer.h"
46 #include <stdlib.h>
47 using namespace MaliSDK;
48 
49 
50 /* Instance of a timer used as input for path generation for leader. It is also used to keep the leader's velocity constant across different GPUs. */
52 
53 /* Program used for transforming vertices into world space. */
54 /* Fragment shader name. */
56 /* Vertex shader name. */
58 /* Program name. */
60 
61 /* Program is used for iteratively calculating translation and velocity of spheres by means of transform feedback. */
62 /* Fragment shader name. */
64 /* Vertex shader name. */
66 /* Program name. */
68 
69 /* Spheres. */
70 /* A sphere consists of \param numberOfSamples circles and \param numberOfSamples points lying on one circle. */
71 const int numberOfSamples = 20;
72 /* Number of spheres that are drawn on a screen. */
74 /* Number of coordinates written to sphereTrianglesCoordinates array*/
76 /* Number of points written to sphereTrianglesCoordinates array*/
78 /* Array holding coordinates of triangles which a sphere consists of. */
80 /* Size of vertexColors array. */
82 /* Array holding color values for each vertex of sphere triangle. */
83 float* vertexColors = NULL;
84 
85 /* Window. */
86 /* Height of window. */
87 int windowHeight = 0;
88 /* Width of window. */
89 int windowWidth = 0;
90 
91 /* Uniform and attribute locations. */
92 /* "Camera position" shader uniform which is used to set up a view. */
94 /* Shader uniform block index. */
96 /* "Perspective matrix" shader uniform's location. */
98 /* "Position" shader attribute's location. */
99 GLint positionLocation = 0;
100 /* "Scaling matrix" shader uniform's location. */
102 /* "Color" shader attribute's location. */
104 /* "Time" shader uniform is used to hold timer value. timeLocation provides information about the uniform's location. */
105 GLint timeLocation = 0;
106 
107 /* Buffer objects. */
108 /* If true - ping buffer object is used as transform feedback output. Otherwise pong buffer object should be used. */
110 /* Constant telling number of buffer objects that should be generated. */
112 /* Array of buffer object names. */
114 /* There are 4 coordinates for each uniform, and 2 uniforms (location and velocity) for each sphere. */
116 /* Name of buffer object which holds color of triangle vertices. */
118 /* Name of buffer object which holds coordinates of triangles making sphere. */
120 /* Name of buffer object which holds newly generated data containing location and velocity of spheres. */
122 /* Name of buffer object which holds location and velocity data from previous iteration. */
124 
125 /* Positions and velocities of spheres in 3D space. */
126 /* Array holding positions and velocities of spheres in 3D space which are used to draw spheres for the first time. */
128 
133 {
134  /* Fill the array with position data (starting at index 0). */
135  for (int allComponents = 0;
136  allComponents < 4 * numberOfSpheresToGenerate;
137  allComponents++)
138  {
139  /* Random data with range -20 to -10. */
140  startPositionAndVelocity[allComponents] = 10.0f * (float(rand()) / float(RAND_MAX)) - 20.0f;
141  }
142 
143  /* Fill array with velocity data (which follows position data). */
144  for (int allComponents = 4 * numberOfSpheresToGenerate;
145  allComponents < 4 * 2 * numberOfSpheresToGenerate;
146  allComponents++)
147  {
148  startPositionAndVelocity[allComponents] = 0;
149  }
150 }
151 
156 {
157  /*
158  * Number of vertices for all the spheres is equal to numberOfSphereTriangleCoordinates / 3 (3 verticies per triangle).
159  * For each vertex there are 4 color components (R, G, B and A values).
160  */
162 
163  /* Allocate memory for vertexColors array. */
164  vertexColors = (float*) malloc (colorArraySize * sizeof(float));
165 
166  ASSERT(vertexColors != NULL, "Could not allocate memory for vertexColors array.");
167 
168  for (int i = 0; i < colorArraySize; i++)
169  {
170  vertexColors[i] = float(rand()%RAND_MAX)/float(RAND_MAX);
171  }
172 }
173 
178 {
179  /* Radius of the spheres. */
180  const float radius = 10.0f;
181 
182  /* [Generate geometry] */
188  /* [Generate geometry] */
191 }
192 
197 {
198  /* Create all data needed to draw sphere. */
200 
201  /* Enable blending. */
202  GL_CHECK(glEnable(GL_BLEND));
203 
204  /* Settings for 3D shape drawing. */
205  GL_CHECK(glDisable(GL_CULL_FACE));
206  GL_CHECK(glEnable(GL_DEPTH_TEST));
207  GL_CHECK(glDepthFunc(GL_LEQUAL));
208 
209  /* [Generate buffer objects] */
210  /* Generate buffers. */
212 
217  /* [Generate buffer objects] */
218 
219  /* Fill buffer object with vertex data. */
220  /* Buffer holding coordinates of triangles which create a sphere. */
221  /* [Bind coordinates buffer object] */
222  GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER,
224  /* [Bind coordinates buffer object] */
225  /* [Set data for coordinates buffer object] */
226  GL_CHECK(glBufferData(GL_ARRAY_BUFFER,
229  GL_STATIC_DRAW));
230  /* [Set data for coordinates buffer object] */
231 
232  /* Buffer holding RGBA values of color for each vertex. */
233  GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER,
235  GL_CHECK(glBufferData(GL_ARRAY_BUFFER,
237  vertexColors,
238  GL_STATIC_DRAW));
239 
240  /* [Setup storage for buffer objects] */
241  /* Buffers holding coordinates of sphere positions and velocities which are used by transform feedback
242  * (to read from or write computed data). */
243  /* Set buffers' size and usage, but do not fill them with any data. */
244  GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER,
246  GL_CHECK(glBufferData(GL_ARRAY_BUFFER,
247  spherePositionsAndVelocitiesLength * sizeof(float),
248  NULL,
249  GL_STATIC_DRAW));
250  GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER,
252  GL_CHECK(glBufferData(GL_ARRAY_BUFFER,
253  spherePositionsAndVelocitiesLength * sizeof(float),
254  NULL,
255  GL_STATIC_DRAW));
256  /* [Setup storage for buffer objects] */
257 
258  /* Deallocate memory (data are now saved in buffer objects). */
259  free(vertexColors);
260  vertexColors = NULL;
261 
264 }
265 
266 /*
267 * \brief Create programs that will be used to rasterize the geometry and transforming the spheres.
268 *
269 */
271 {
272  /* [Array of varyings' names which are used by shader for transform feedback] */
273  const GLchar* varyingNames[] = {"location", "velocity"};
274  /* [Array of varyings' names which are used by shader for transform feedback] */
275 
276  /* Create program objects. */
277  movementProgramId = GL_CHECK(glCreateProgram());
278  /* [Create program object] */
279  renderingProgramId = GL_CHECK(glCreateProgram());
280  /* [Create program object] */
281 
282  /* Initialize movement program. */
285  GL_VERTEX_SHADER);
288  GL_FRAGMENT_SHADER);
289 
290  /* Attach vertex and fragment shaders to the program which is used for transform feedback. */
293 
294  /* [Specify transform feedback varyings] */
295  /*
296  * Specify varyings which are used with transform feedback buffer.
297  * In shader we are using uniform block for holding location and velocity data.
298  * Uniform block takes data from buffer object. Buffer object is filled with position data for each sphere first, and then with velocity data for each sphere.
299  * Setting mode to GL_SEPARATE_ATTRIBS indicates that data are written to output buffer in exactly the same way as in input buffer object.
300  */
301  GL_CHECK(glTransformFeedbackVaryings(movementProgramId,
302  2,
303  varyingNames,
304  GL_SEPARATE_ATTRIBS));
305  /* [Specify transform feedback varyings] */
306 
307  /* [Link movement program object] */
308  GL_CHECK(glLinkProgram(movementProgramId));
309  /* [Link movement program object] */
310  GL_CHECK(glUseProgram (movementProgramId));
311 
312  /* Get uniform locations from current program. */
313  GLuint transformationUniformBlockIndex = GL_CHECK(glGetUniformBlockIndex(movementProgramId, "inputData"));
314 
315  timeLocation = GL_CHECK(glGetUniformLocation(movementProgramId, "time"));
316 
317  /* Check if the uniform was found in the vertex shader. */
318  ASSERT(timeLocation != -1, "Could not retrieve uniform location: timeLocation");
319  ASSERT(transformationUniformBlockIndex != GL_INVALID_INDEX, "Could not find uniform block: inputData");
320 
321  GL_CHECK(glUniformBlockBinding(movementProgramId, transformationUniformBlockIndex, 0));
322 
323  /* Initialize rendering program. */
326  GL_VERTEX_SHADER);
329  GL_FRAGMENT_SHADER);
330 
331  /* [Attach shaders to program object] */
332  /* Attach vertex and fragment shaders to rendering program. */
333  GL_CHECK(glAttachShader(renderingProgramId, vertexShaderId));
334  GL_CHECK(glAttachShader(renderingProgramId, fragmentShaderId));
335  /* [Attach shaders to program object] */
336 
337  /* Link and use rendering program object. */
338  /* [Link program object] */
339  GL_CHECK(glLinkProgram(renderingProgramId));
340  /* [Link program object] */
341  /* [Select active program object] */
342  GL_CHECK(glUseProgram (renderingProgramId));
343  /* [Select active program object] */
344 
345  /* Get uniform, attribute and uniform block locations from current program. */
346  /* [Get attribute location: attributePosition] */
347  positionLocation = GL_CHECK(glGetAttribLocation (renderingProgramId, "attributePosition"));
348  /* [Get attribute location: attributePosition] */
349  sphereVertexColorLocation = GL_CHECK(glGetAttribLocation (renderingProgramId, "attributeColor"));
350  /* [Get uniform locations] */
351  scalingMatrixLocation = GL_CHECK(glGetUniformLocation (renderingProgramId, "scalingVector"));
352  perspectiveMatrixLocation = GL_CHECK(glGetUniformLocation (renderingProgramId, "perspectiveVector"));
353  cameraPositionLocation = GL_CHECK(glGetUniformLocation (renderingProgramId, "cameraVector"));
354  /* [Get uniform locations] */
355  movementUniformBlockIndex = GL_CHECK(glGetUniformBlockIndex(renderingProgramId, "BoidsUniformBlock"));
356 
357  /* [Check if all uniforms, attributes and uniform blocks were found in vertex shader] */
358  ASSERT(positionLocation != -1, "Could not retrieve attribute location: attributePosition");
359  ASSERT(sphereVertexColorLocation != -1, "Could not retrieve attribute location: attributeColor");
360  ASSERT(scalingMatrixLocation != -1, "Could not retrieve uniform location: scalingMatrixLocation");
361  ASSERT(perspectiveMatrixLocation != -1, "Could not retrieve uniform location: perspectiveMatrixLocation");
362  ASSERT(cameraPositionLocation != -1, "Could not retrieve uniform location: cameraPositionLocation");
363  ASSERT(movementUniformBlockIndex != GL_INVALID_INDEX, "Could not retrieve uniform block index: BoidsUniformBlock")
364  /* [Check if all uniforms, attributes and uniform blocks were found in vertex shader] */
365 
366  GL_CHECK(glUniformBlockBinding(renderingProgramId, movementUniformBlockIndex, 0));
367  /* [Fill position and velocity buffer with data] */
368  GL_CHECK(glBindBuffer (GL_ARRAY_BUFFER,
370  GL_CHECK(glBufferSubData(GL_ARRAY_BUFFER,
371  0,
372  sizeof(startPositionAndVelocity),
374  /* [Fill position and velocity buffer with data] */
375 }
376 
381 {
382  /* Clear contents of back buffer. */
383  GL_CHECK(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
384 
385  /* Value of time returned by timer used for determining leader's position and to keep the leader's velocity constant across different GPUs. */
386  float timerTime = timer.getTime();
387 
388  /*
389  * Transform feedback is used for setting position and velocity for each of the spheres.
390  * You cannot read from and write to the same buffer object at a time, so we use a ping-pong approach.
391  * During first call, ping buffer is used for reading and pong buffer for writing.
392  * During second call, pong buffer is used for reading and ping buffer for writing.
393  */
394 
395  /* [Set output buffer] */
396  /*
397  * Configure transform feedback.
398  * Bind buffer object to first varying (location) of GL_TRANSFORM_FEEDBACK_BUFFER - binding point index equal to 0.
399  * Use the first half of the data array, 0 -> sizeof(float) * 4 * numberOfSpheresToGenerate (4 floating point position coordinates per sphere).
400  * Bind buffer object to first varying (velocity) of GL_TRANSFORM_FEEDBACK_BUFFER - binding point index equal to 1.
401  * Use the second half of the data array, from the end of the position data until the end of the velocity data.
402  * The size of the velocity data is sizeof(float) * 4 * numberOfSpheresToGenerate values (4 floating point velocity coordinates per sphere).
403  *
404  * The buffer bound here is used as an output from the movement vertex shader. The output variables in the shader that are bound to this buffer are
405  * given by the call to glTransformFeedbackVaryings earlier.
406  */
408  {
409  GL_CHECK(glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER,
410  0,
412  0,
413  sizeof(float) * 4 * numberOfSpheresToGenerate));
414  GL_CHECK(glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER,
415  1,
417  sizeof(float) * 4 * numberOfSpheresToGenerate,
418  sizeof(float) * 4 * numberOfSpheresToGenerate));
419  }
420  else
421  {
422  GL_CHECK(glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER,
423  0,
425  0,
426  sizeof(float) * 4 * numberOfSpheresToGenerate));
427  GL_CHECK(glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER,
428  1,
430  sizeof(float) * 4 * numberOfSpheresToGenerate,
431  sizeof(float) * 4 * numberOfSpheresToGenerate));
432  }
433  /* [Set output buffer] */
434 
435  /* [Set input buffer] */
436  /*
437  * The buffer bound here is used as the input to the movement vertex shader. The data is mapped to the uniform block, and as the size of the
438  * arrays inside the uniform block is known, the data is mapped to the correct variables.
439  */
441  {
442  GL_CHECK(glBindBufferBase(GL_UNIFORM_BUFFER, 0, spherePongPositionAndVelocityBufferObjectId));
443  }
444  else
445  {
446  GL_CHECK(glBindBufferBase(GL_UNIFORM_BUFFER, 0, spherePingPositionAndVelocityBufferObjectId));
447  }
448  /* [Set input buffer] */
449 
450  /* [Use the transform feedback] */
451  /*
452  * Perform the boids transformation.
453  * This takes the current boid data in the buffers and passes it through the movement vertex shader.
454  * This fills the output buffer with the updated location and velocity information for each boid.
455  */
456  GL_CHECK(glEnable(GL_RASTERIZER_DISCARD));
457  {
458  GL_CHECK(glUseProgram(movementProgramId));
459  GL_CHECK(glBeginTransformFeedback(GL_POINTS));
460  {
461  GL_CHECK(glUniform1f(timeLocation, timerTime));
462  GL_CHECK(glDrawArraysInstanced(GL_POINTS, 0, 1, numberOfSpheresToGenerate));
463  }
464  GL_CHECK(glEndTransformFeedback());
465  }
466  GL_CHECK(glDisable(GL_RASTERIZER_DISCARD));
467  /* [Use the transform feedback] */
468 
469  /* Clean up. */
470  GL_CHECK(glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0));
471  GL_CHECK(glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 1, 0));
472  GL_CHECK(glBindBufferBase(GL_UNIFORM_BUFFER, 0, 0));
473  /*
474  * Rasterizer pass.
475  * Render the scene using the calculated locations of the boids.
476  */
477 
478  /* Set input buffer for rendering program. */
479  GL_CHECK(glUseProgram(renderingProgramId));
480 
481  /* Bind the data calculated during transform feedback to the input of the shader. */
483  {
484  GL_CHECK(glBindBufferBase(GL_UNIFORM_BUFFER,
485  0,
487  }
488  else
489  {
490  GL_CHECK(glBindBufferBase(GL_UNIFORM_BUFFER,
491  0,
493  }
494 
495  /* [Draw spheres] */
496  GL_CHECK(glDrawArraysInstanced(GL_TRIANGLES,
497  0,
500  /* [Draw spheres] */
501 
502  /* Swap the ping and pong buffer objects. */
504 }
505 
506 void setupGraphics(int width, int height)
507 {
509  windowWidth = width;
510 
511  /* Initialize data used for rendering. */
512  initializeData();
513  /* Create programs. */
514  setupPrograms();
515  /* Start counting time. */
516  timer.reset();
517 
518  /* Scale factor for displaying 3D shape. */
519  const float scalingFactor = 0.1f;
520  /* Array used for setting scale matrix in vertex shader. */
521  float scalingVector[] = {scalingFactor, scalingFactor, scalingFactor};
522  /* Array used for setting perspective matrix in vertex shader. */
523  float perspectiveVector[] = {45.0f, float(windowWidth) / float(windowHeight), 0.1f, 1000.0f};
524  /* Array used for view configuration in vertex shader. */
525  float cameraVector[] = {0.0f, 0.0f, -60.0f};
526 
527  /* Set values for uniforms for model-view program. */
528  GL_CHECK(glUseProgram(renderingProgramId));
529  /* [Set uniform values] */
530  GL_CHECK(glUniform3fv(scalingMatrixLocation, 1, scalingVector));
531  GL_CHECK(glUniform4fv(perspectiveMatrixLocation, 1, perspectiveVector));
532  GL_CHECK(glUniform3fv(cameraPositionLocation, 1, cameraVector));
533  /* [Set uniform values] */
534  /* Enable VAAs */
535  /* [Enable VAA for sphere coordinates] */
536  GL_CHECK(glBindBuffer (GL_ARRAY_BUFFER,
538  GL_CHECK(glEnableVertexAttribArray(positionLocation));
539  GL_CHECK(glVertexAttribPointer (positionLocation,
540  3,
541  GL_FLOAT,
542  GL_FALSE,
543  0,
544  0));
545  /* [Enable VAA for sphere coordinates] */
546 
547  GL_CHECK(glBindBuffer (GL_ARRAY_BUFFER,
549  GL_CHECK(glEnableVertexAttribArray(sphereVertexColorLocation));
550  GL_CHECK(glVertexAttribPointer (sphereVertexColorLocation,
551  4,
552  GL_FLOAT,
553  GL_FALSE,
554  0,
555  0));
556 }
557 
558 void uninit()
559 {
560  /* Delete buffers. */
562 
563  /* Delete program and shader objects. */
564  GL_CHECK(glUseProgram(0));
565 
566  GL_CHECK(glDeleteShader (fragmentShaderId));
567  GL_CHECK(glDeleteShader (movementFragmentShaderId));
568  GL_CHECK(glDeleteShader (movementVertexShaderId));
569  GL_CHECK(glDeleteShader (vertexShaderId));
570  GL_CHECK(glDeleteProgram(renderingProgramId));
571  GL_CHECK(glDeleteProgram(movementProgramId));
572 }
573 
574 extern "C"
575 {
576  JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_boids_NativeLibrary_init (JNIEnv * env, jobject obj, jint width, jint height);
577  JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_boids_NativeLibrary_step (JNIEnv * env, jobject obj);
578  JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_boids_NativeLibrary_uninit(JNIEnv * env, jobject obj);
579 };
580 
582  JNIEnv * env, jobject obj, jint width, jint height)
583 {
584  setupGraphics(width, height);
585 }
586 
588  JNIEnv * env, jobject obj)
589 {
590  uninit();
591 }
592 
593 
595  JNIEnv * env, jobject obj)
596 {
597  renderFrame();
598 }
void setupGraphics(int width, int height)
Definition: Native.cpp:1256
int numberOfSphereTrianglePoints
Definition: Native.cpp:77
Vec4f perspectiveVector
Definition: Native.cpp:112
GLint perspectiveMatrixLocation
Definition: Native.cpp:97
GLuint sphereCoordinatesBufferObjectId
Definition: Native.cpp:119
GLint cameraPositionLocation
Definition: Native.cpp:93
#define GL_CHECK(x)
Definition: Native.cpp:64
float getTime()
Returns the time passed since object creation or since reset() was last called.
Definition: Timer.cpp:109
GLuint spherePingPositionAndVelocityBufferObjectId
Definition: Native.cpp:121
void generateStartPositionAndVelocity()
Generate random positions and velocities of spheres which are used during first draw call...
Definition: Native.cpp:132
static void getTriangleRepresentation(const float radius, const int numberOfSamples, int *numberOfCoordinates, float **coordinates)
Create triangular representation of a sphere.
int windowHeight
Definition: Native.cpp:574
GLint GLsizei GLsizei height
Definition: gl2ext.h:179
GLint positionLocation
Definition: Native.cpp:99
GLuint vertexShaderId
Definition: Native.cpp:57
const int numberOfSpheresToGenerate
Definition: Native.cpp:73
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_boids_NativeLibrary_step(JNIEnv *env, jobject obj)
Definition: Native.cpp:594
Vec3f cameraVector
Definition: Native.cpp:114
precision highp int
Definition: hiz_cull.cs:38
Provides a platform independent high resolution timer.
Definition: Timer.h:37
GLuint renderingProgramId
Definition: Native.cpp:59
void setupPrograms()
Definition: Native.cpp:270
GLuint movementProgramId
Definition: Native.cpp:67
#define MOVEMENT_VERTEX_SHADER_FILE_NAME
Definition: Boids.h:33
#define VERTEX_SHADER_FILE_NAME
Definition: Boids.h:29
int colorArraySize
Definition: Native.cpp:81
float * vertexColors
Definition: Native.cpp:83
float scalingFactor
Definition: Native.cpp:138
GLuint movementUniformBlockIndex
Definition: Native.cpp:95
float startPositionAndVelocity[spherePositionsAndVelocitiesLength]
Definition: Native.cpp:127
void reset()
Resets the timer to 0.0f.
Definition: Timer.cpp:100
void uninit()
Delete created objects and free allocated memory.
Definition: Native.cpp:1706
GLfloat GLfloat f
Definition: gl2ext.h:2707
const int spherePositionsAndVelocitiesLength
Definition: Native.cpp:115
float * sphereTrianglesCoordinates
Definition: Native.cpp:79
int numberOfSphereTriangleCoordinates
Definition: Native.cpp:75
void renderFrame(void)
Definition: Native.cpp:1536
#define FRAGMENT_SHADER_FILE_NAME
Definition: Boids.h:27
GLint scalingMatrixLocation
Definition: Native.cpp:101
void initializeData()
Initializes data used for rendering.
Definition: Native.cpp:196
bool usePingBufferForTransformFeedbackOutput
Definition: Native.cpp:109
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_boids_NativeLibrary_init(JNIEnv *env, jobject obj, jint width, jint height)
Definition: Native.cpp:581
void createSpheresData()
Initialize data for spheres.
Definition: Native.cpp:177
#define MOVEMENT_FRAGMENT_SHADER_FILE_NAME
Definition: Boids.h:31
Timer timer
Definition: Native.cpp:1059
int windowWidth
Definition: Native.cpp:575
void fillVertexColorsArray()
Fill vertexColors array with random color for each triangle vertex.
Definition: Native.cpp:155
GLuint bufferObjectIds[numberOfBufferObjectIds]
Definition: Native.cpp:113
GLuint sphereColorsBufferObjectId
Definition: Native.cpp:117
GLuint spherePongPositionAndVelocityBufferObjectId
Definition: Native.cpp:123
const int numberOfSamples
Definition: Native.cpp:71
GLint timeLocation
Definition: Native.cpp:105
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_boids_NativeLibrary_uninit(JNIEnv *env, jobject obj)
Definition: Native.cpp:587
GLuint movementFragmentShaderId
Definition: Native.cpp:63
#define ASSERT(x, s)
Definition: common.h:45
precision highp float
Definition: hiz_cull.cs:37
GLuint fragmentShaderId
Definition: Native.cpp:55
GLint GLsizei width
Definition: gl2ext.h:179
const GLuint numberOfBufferObjectIds
Definition: Native.cpp:111
static void processShader(GLuint *shader, const char *filename, GLint shaderType)
Create shader, load in source, compile, and dump debug as necessary.
Definition: Shader.cpp:29
GLuint movementVertexShaderId
Definition: Native.cpp:65
typedef GLuint(GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count
GLint sphereVertexColorLocation
Definition: Native.cpp:103