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 
44 #include <jni.h>
45 #include <android/log.h>
46 
47 #include <GLES3/gl3.h>
48 #include "Common.h"
49 #include "CubeModel.h"
50 #include "Mathematics.h"
51 #include "Matrix.h"
52 #include "PlaneModel.h"
53 #include "IntegerLogic.h"
54 #include "Shader.h"
55 #include "Texture.h"
56 #include "Timer.h"
57 #include <cstring>
58 
59 using namespace MaliSDK;
60 
61 /* Window resolution: height. */
62 GLsizei windowHeight = 0;
63 /* Window resolution: width. */
64 GLsizei windowWidth = 0;
65 
66 /* ID assigned by GL ES for "rule 30" program. */
68 /* ID assigned by GL ES for "merge" program. */
70 
71 /* [Define texture units] */
72 /* Texture unit used for configuring 2D texture binding for ping textures. */
74 /* Texture unit used for configuring 2D texture binding for pong textures. */
76 /* [Define texture units] */
77 
78 /* Data for the initial line of the ping texture. */
79 GLvoid* pingTextureData = NULL;
80 /* ID of ping texture that holds the input data. */
82 /* ID of pong texture whose entire input depend on the ping texture. */
84 
85 /* OpenGL ES ID for a frame-buffer we use for off-screen rendering. */
87 /* OpenGL ES ID for a buffer object used for storing line vertex position data. */
89 /* OpenGL ES ID for a buffer object used for storing line U/V texture coordinate data. */
91 /* OpenGL ES ID for a buffer object used for storing quad vertex position data. */
93 /* OpenGL ES ID for a buffer object used for storing quad U/V texture coordinate data. */
95 /* OpengGL ES ID for a Vertex Array object that we use for storing line vertex attribute assignments. */
97 /* OpenGL ES ID for a Vertex Array object that we use for storing quad vertex attribute assignments. */
99 
100 /* Cached projection matrix. */
102 
103 /* Merge program locations. */
105 /* Merge program locations. */
107 /* Instance of a timer that will be used to switch between textures being displayed. */
109 /* Time interval in seconds. */
110 const float timeInterval = 5.0f;
111 
112 
123 void generateRule30Input(unsigned int xoffset,
124  unsigned int width,
125  unsigned int height,
126  unsigned int nComponents,
127  GLvoid** textureData);
136 void generateRule30Input(unsigned int width, unsigned int height, unsigned int nComponents, GLvoid** textureData);
137 
138 /* Renders to the texture attached to a custom framebuffer, following the Rule 30. */
140 
141 /* Perform rendering on a single frame. */
142 void renderFrame();
143 
144 /* Renders to the back buffer. */
145 void renderToBackBuffer();
146 
147 /* Reset the textures, so a new pattern can be generated. */
148 void resetTextures();
149 
150 /* Initializes all the required components.
151  * \param width Width of a rendering window.
152  * \param height Height of a rendering window.
153  */
154 void setupGraphics(int width, int height);
155 
156 /* Perform a clean up. */
157 void uninit();
158 
159 /* [Generate input texture data] */
160 /* Please see the specification above. */
161 void generateRule30Input(unsigned int xoffset,
162  unsigned int width,
163  unsigned int height,
164  unsigned int nComponents,
165  GLvoid** textureData)
166 {
167  ASSERT(textureData != NULL, "Null data passed");
168 
169  for(unsigned int channelIndex = 0; channelIndex < nComponents; ++channelIndex)
170  {
171  (*(unsigned char**)textureData)[(height - 1) * width * nComponents + xoffset * nComponents + channelIndex] = 255;
172  }
173 }
174 /* [Generate input texture data] */
175 
176 /* [Generate input texture data for next steps] */
177 /* Please see the specification above. */
178 void generateRule30Input(unsigned int width,
179  unsigned int height,
180  unsigned int nComponents,
181  GLvoid** textureData)
182 {
183  ASSERT(textureData != NULL, "Null data passed");
184 
185  for (unsigned int texelIndex = 0; texelIndex < width; ++texelIndex)
186  {
187  bool setWhite = (rand() % 2 == 0) ? true : false;
188 
189  if (setWhite)
190  {
191  for (unsigned int channelIndex = 0; channelIndex < nComponents; ++channelIndex)
192  {
193  (*(unsigned char**)textureData)[(height - 1) * width * nComponents + texelIndex * nComponents + channelIndex] = 255;
194  }
195  }
196  }
197 }
198 /* [Generate input texture data for next steps] */
199 
200 /* [Perform the offscreen rendering] */
201 /* Please see the specification above. */
203 {
204  /* Offset of the input line passed to the appropriate uniform. */
205  float inputVerticalOffset = 0.0f;
206 
207  /* Activate the first program. */
208  GL_CHECK(glUseProgram(rule30ProgramID));
209  GL_CHECK(glBindVertexArray(lineVAOID));
210 
211  /* [Bind the framebuffer object] */
212  GL_CHECK(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebufferID));
213  /* [Bind the framebuffer object] */
214 
215  /* Render each line, beginning from the 2nd one, using the input from the previous line.*/
216  for (unsigned int y = 1; y <= windowHeight; ++y)
217  {
218  /* Even lines should be taken from the ping texture, odd from the pong. */
219  bool isEvenLineBeingRendered = (y % 2 == 0) ? (true) : (false);
220  /* Vertical offset of the currently rendered line. */
221  float verticalOffset = (float) y / (float) windowHeight;
222 
223  /* Pass data to uniforms. */
224  GL_CHECK(glUniform1f(rule30ProgramLocations.verticalOffsetLocation, verticalOffset));
225  GL_CHECK(glUniform1f(rule30ProgramLocations.inputVerticalOffsetLocation, inputVerticalOffset));
226 
227  if (isEvenLineBeingRendered)
228  {
229  /* [Bind ping texture to the framebuffer] */
230  GL_CHECK(glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER,
231  GL_COLOR_ATTACHMENT0,
232  GL_TEXTURE_2D,
234  0) );
235  /* [Bind ping texture to the framebuffer] */
237  pongTextureUnit) );
238  }
239  else
240  {
241  /* [Bind pong texture to the framebuffer] */
242  GL_CHECK(glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER,
243  GL_COLOR_ATTACHMENT0,
244  GL_TEXTURE_2D,
246  0));
247  /* [Bind pong texture to the framebuffer] */
249  pingTextureUnit) );
250  }
251 
252  /* Drawing a horizontal line defined by 2 vertices. */
253  GL_CHECK(glDrawArrays(GL_LINES, 0, 2));
254 
255  /* Update the input vertical offset after the draw call, so it points to the previous line. */
256  inputVerticalOffset = verticalOffset;
257  }
258 
259  /* Unbind the framebuffer. */
260  GL_CHECK(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0));
261 }
262 /* [Perform the offscreen rendering] */
263 
264 
265 /* [Perform textures' merging] */
266 /* Please see the specification above. */
268 {
269  /* Activate the second program. */
270  GL_CHECK(glUseProgram (mergeProgramID));
271  GL_CHECK(glBindVertexArray(quadVAOID));
272 
273  /* Draw a quad as a triangle strip defined by 4 vertices. */
274  GL_CHECK(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
275 }
276 /* [Perform textures' merging] */
277 
278 /* Please see the specification above. */
279 void setupGraphics(int width, int height)
280 {
281  /* Store window resolution. */
283  windowWidth = width;
284 
285  /* Array specifying the draw buffers to which render. */
286  const GLuint offscreenFBODrawBuffers[] = {GL_COLOR_ATTACHMENT0};
287 
288  /* Initialize matrices. */
290  (float) windowHeight,
291  1.0f);
292  /* Multiplication by 2 for vertical boundaries are caused by setting 0.5 as w coordinate in vertices array. */
293  Matrix orthographic = Matrix::matrixOrthographic(-(float) windowWidth,
294  (float) windowWidth,
295  -(float) windowHeight * 2,
296  (float) windowHeight * 2,
297  -1.0f,
298  1.0f);
299 
300  modelViewProjectionMatrix = orthographic * scale;
301 
302  /* Create Input data for the ping texture. */
303  Texture::createTexture(windowWidth,
304  windowHeight,
305  0,
306  &pingTextureData);
307  /* [Generate the original data for ping texture] */
308  generateRule30Input (windowWidth / 2,
309  windowWidth,
310  windowHeight,
311  1,
312  &pingTextureData);
313  /* [Generate the original data for ping texture] */
314 
315  /* Generate textures. */
316  GLuint textureIDs[] = {0, 0};
317 
318  /* [Generate texture objects] */
319  GL_CHECK(glGenTextures(2, textureIDs));
320 
321  pingTextureID = textureIDs[0];
322  pongTextureID = textureIDs[1];
323  /* [Generate texture objects] */
324 
325  /* [Ping texture: Bind texture object to specific texture unit and set its property] */
326  /* Load ping texture data. */
327  GL_CHECK(glActiveTexture(GL_TEXTURE0 + pingTextureUnit));
328  GL_CHECK(glBindTexture (GL_TEXTURE_2D,
329  pingTextureID));
330  GL_CHECK(glTexImage2D (GL_TEXTURE_2D,
331  0,
332  GL_R8UI,
333  windowWidth,
334  windowHeight,
335  0,
336  GL_RED_INTEGER,
337  GL_UNSIGNED_BYTE,
338  pingTextureData));
339  GL_CHECK(glTexParameteri(GL_TEXTURE_2D,
340  GL_TEXTURE_WRAP_S,
341  GL_CLAMP_TO_EDGE));
342  GL_CHECK(glTexParameteri(GL_TEXTURE_2D,
343  GL_TEXTURE_WRAP_T,
344  GL_CLAMP_TO_EDGE));
345  GL_CHECK(glTexParameteri(GL_TEXTURE_2D,
346  GL_TEXTURE_MAG_FILTER,
347  GL_NEAREST));
348  GL_CHECK(glTexParameteri(GL_TEXTURE_2D,
349  GL_TEXTURE_MIN_FILTER,
350  GL_NEAREST));
351  /* [Ping texture: Bind texture object to specific texture unit and set its property] */
352 
353  /* [Pong texture: Bind texture object to specific texture unit and set its property] */
354  /* Prepare pong texture object. */
355  GL_CHECK(glActiveTexture(GL_TEXTURE0 + pongTextureUnit));
356  GL_CHECK(glBindTexture (GL_TEXTURE_2D,
357  pongTextureID));
358  GL_CHECK(glTexStorage2D (GL_TEXTURE_2D,
359  1,
360  GL_R8UI,
361  windowWidth,
362  windowHeight));
363  GL_CHECK(glTexParameteri(GL_TEXTURE_2D,
364  GL_TEXTURE_WRAP_S,
365  GL_CLAMP_TO_EDGE));
366  GL_CHECK(glTexParameteri(GL_TEXTURE_2D,
367  GL_TEXTURE_WRAP_T,
368  GL_CLAMP_TO_EDGE));
369  GL_CHECK(glTexParameteri(GL_TEXTURE_2D,
370  GL_TEXTURE_MAG_FILTER,
371  GL_NEAREST));
372  GL_CHECK(glTexParameteri(GL_TEXTURE_2D,
373  GL_TEXTURE_MIN_FILTER,
374  GL_NEAREST));
375  /* [Pong texture: Bind texture object to specific texture unit and set its property] */
376 
377  /* Code to setup shaders, geometry, and to initialise OpenGL ES states. */
378  GLuint fragmentMergeShaderID = 0;
379  GLuint fragmentRule30ShaderID = 0;
380  GLuint vertexRule30ShaderID = 0;
381  GLuint vertexMergeShaderID = 0;
382 
383  /* Process shaders. */
384  Shader::processShader(&vertexRule30ShaderID, VERTEX_RULE_30_SHADER_FILENAME, GL_VERTEX_SHADER);
385  Shader::processShader(&vertexMergeShaderID, VERTEX_MERGE_SHADER_FILENAME, GL_VERTEX_SHADER);
386  Shader::processShader(&fragmentRule30ShaderID, FRAGMENT_RULE_30_SHADER_FILENAME, GL_FRAGMENT_SHADER);
387  Shader::processShader(&fragmentMergeShaderID, FRAGMENT_MERGE_SHADER_FILENAME, GL_FRAGMENT_SHADER);
388 
389  /* Create programs. */
390  /* [Create program object]*/
391  rule30ProgramID = GL_CHECK(glCreateProgram());
392  /* [Create program object]*/
393  mergeProgramID = GL_CHECK(glCreateProgram());
394 
395  /* Attach shaders. */
396  /* [Attach shaders to program object] */
397  GL_CHECK(glAttachShader(rule30ProgramID, vertexRule30ShaderID));
398  GL_CHECK(glAttachShader(rule30ProgramID, fragmentRule30ShaderID));
399  /* [Attach shaders to program object] */
400  GL_CHECK(glAttachShader(mergeProgramID, vertexMergeShaderID));
401  GL_CHECK(glAttachShader(mergeProgramID, fragmentMergeShaderID));
402 
403  /* Link programs. */
404  /* [Link program object] */
405  GL_CHECK(glLinkProgram(rule30ProgramID));
406  /* [Link program object] */
407  GL_CHECK(glLinkProgram(mergeProgramID) );
408 
409  /* Set up buffer objects. */
410  GLuint boIDs[] = {0, 0, 0, 0};
411 
412  /* [Generate buffer objects] */
413  GL_CHECK(glGenBuffers(4, boIDs));
414 
415  linePositionBOID = boIDs[0];
416  lineUVBOID = boIDs[1];
417  quadPositionBOID = boIDs[2];
418  quadUVBOID = boIDs[3];
419  /* [Generate buffer objects] */
420 
421  /* [Set up framebuffer object] */
422  GL_CHECK(glGenFramebuffers(1,
423  &framebufferID));
424  GL_CHECK(glBindFramebuffer(GL_DRAW_FRAMEBUFFER,
425  framebufferID));
426  GL_CHECK(glDrawBuffers (1,
427  offscreenFBODrawBuffers));
428  /* [Set up framebuffer object] */
429 
430  /* Set up VAO for line data. */
431  /* [Generate vertex array object] */
432  GL_CHECK(glGenVertexArrays(1, &lineVAOID));
433  /* [Generate vertex array object] */
434  /* [Bind vertex array object] */
435  GL_CHECK(glBindVertexArray(lineVAOID));
436  /* [Bind vertex array object] */
437 
438  /* Retrieve vertex attributes and uniforms locations in "rule30" program. */
439  /* [Select active program object] */
440  GL_CHECK(glUseProgram(rule30ProgramID) );
441  /* [Select active program object] */
442 
443  /* [Retrieve attrib and uniform locations] */
444  rule30ProgramLocations.inputNeighbourLocation = GL_CHECK(glGetUniformLocation(rule30ProgramID, "inputNeighbour") );
445  rule30ProgramLocations.inputTextureLocation = GL_CHECK(glGetUniformLocation(rule30ProgramID, "inputTexture") );
446  rule30ProgramLocations.inputVerticalOffsetLocation = GL_CHECK(glGetUniformLocation(rule30ProgramID, "inputVerticalOffset") );
447  rule30ProgramLocations.mvpMatrixLocation = GL_CHECK(glGetUniformLocation(rule30ProgramID, "mvpMatrix") );
448  rule30ProgramLocations.positionLocation = GL_CHECK(glGetAttribLocation (rule30ProgramID, "position") );
449  rule30ProgramLocations.texCoordLocation = GL_CHECK(glGetAttribLocation (rule30ProgramID, "vertexTexCoord") );
450  rule30ProgramLocations.verticalOffsetLocation = GL_CHECK(glGetUniformLocation(rule30ProgramID, "verticalOffset") );
451  /* [Retrieve attrib and uniform locations] */
452 
453  /* [Check location values] */
454  ASSERT(rule30ProgramLocations.inputNeighbourLocation != -1, "Could not find location of a uniform in rule30 program: inputNeighbour" );
455  ASSERT(rule30ProgramLocations.inputTextureLocation != -1, "Could not find location of a uniform in rule30 program: inputTexture" );
456  ASSERT(rule30ProgramLocations.inputVerticalOffsetLocation != -1, "Could not find location of a uniform in rule30 program: inputVerticalOffset");
457  ASSERT(rule30ProgramLocations.mvpMatrixLocation != -1, "Could not find location of a uniform in rule30 program: mvpMatrix" );
458  ASSERT(rule30ProgramLocations.positionLocation != -1, "Could not find location of an attribute in rule30 program: position" );
459  ASSERT(rule30ProgramLocations.texCoordLocation != -1, "Could not find location of an attribute in rule30 program: vertexTexCoord" );
460  ASSERT(rule30ProgramLocations.verticalOffsetLocation != -1, "Could not find location of a uniform in rule30 program: verticalOffset" );
461  /* [Check location values] */
462 
463  /* [Pass data to uniforms] */
465  1,
466  GL_FALSE,
469  1.0f / windowWidth) );
470  /* [Pass data to uniforms] */
471 
472  /* [Fill buffer object with quad coordinates data] */
473  /* Fill buffers with line vertices attribute data. */
474  GL_CHECK(glBindBuffer (GL_ARRAY_BUFFER,
476  GL_CHECK(glBufferData (GL_ARRAY_BUFFER,
477  sizeof(lineVertices),
478  lineVertices,
479  GL_STATIC_DRAW));
480  GL_CHECK(glVertexAttribPointer (rule30ProgramLocations.positionLocation,
481  4,
482  GL_FLOAT,
483  GL_FALSE,
484  0,
485  0));
486  GL_CHECK(glEnableVertexAttribArray(rule30ProgramLocations.positionLocation));
487  /* [Fill buffer object with quad coordinates data] */
488 
489  /* [Fill buffer object with texture UVs data] */
490  /* Fill buffers with line U/V attribute data. */
491  GL_CHECK(glBindBuffer (GL_ARRAY_BUFFER,
492  lineUVBOID));
493  GL_CHECK(glBufferData (GL_ARRAY_BUFFER,
494  sizeof(lineTextureCoordinates),
496  GL_STATIC_DRAW));
497  GL_CHECK(glVertexAttribPointer (rule30ProgramLocations.texCoordLocation,
498  2,
499  GL_FLOAT,
500  GL_FALSE,
501  0,
502  0));
503  GL_CHECK(glEnableVertexAttribArray(rule30ProgramLocations.texCoordLocation));
504  /* [Fill buffer object with texture UVs data] */
505 
506  /* Set up VAO for quad data. */
507  GL_CHECK(glGenVertexArrays(1, &quadVAOID));
508  GL_CHECK(glBindVertexArray(quadVAOID));
509 
510  /* Retrieve vertex attributes and uniforms locations in "merge" program. */
511  GL_CHECK(glUseProgram(mergeProgramID) );
512 
513  mergeProgramLocations.mvpMatrixLocation = GL_CHECK(glGetUniformLocation(mergeProgramID, "mvpMatrix") );
514  mergeProgramLocations.pingTextureLocation = GL_CHECK(glGetUniformLocation(mergeProgramID, "pingTexture") );
515  mergeProgramLocations.pongTextureLocation = GL_CHECK(glGetUniformLocation(mergeProgramID, "pongTexture") );
516  mergeProgramLocations.positionLocation = GL_CHECK(glGetAttribLocation (mergeProgramID, "position") );
517  mergeProgramLocations.texCoordLocation = GL_CHECK(glGetAttribLocation (mergeProgramID, "vertexTexCoord") );
518 
519  ASSERT(mergeProgramLocations.mvpMatrixLocation != -1, "Could not find location of a uniform in merge program: mvpMatrix");
520  ASSERT(mergeProgramLocations.pingTextureLocation != -1, "Could not find location of a uniform in merge program: pingTexture");
521  ASSERT(mergeProgramLocations.pongTextureLocation != -1, "Could not find location of a uniform in merge program: pongTexture");
522  ASSERT(mergeProgramLocations.positionLocation != -1, "Could not find location of an attribute in merge program: position");
523  ASSERT(mergeProgramLocations.texCoordLocation != -1, "Could not find location of an attribute in merge program: vertexTexCoord");
524 
525  /* Pass data to uniforms. */
527  1,
528  GL_FALSE,
531  0) );
533  1) );
534 
535  /* Fill buffers with quad vertices attribute data. */
536  GL_CHECK(glBindBuffer (GL_ARRAY_BUFFER,
538  GL_CHECK(glBufferData (GL_ARRAY_BUFFER,
539  sizeof(quadVertices),
540  quadVertices,
541  GL_STATIC_DRAW));
542  GL_CHECK(glVertexAttribPointer (mergeProgramLocations.positionLocation,
543  4,
544  GL_FLOAT,
545  GL_FALSE,
546  0,
547  0));
548  GL_CHECK(glEnableVertexAttribArray(mergeProgramLocations.positionLocation));
549 
550  /* Fill buffers with quad U/V attribute data. */
551  GL_CHECK(glBindBuffer (GL_ARRAY_BUFFER,
552  quadUVBOID));
553  GL_CHECK(glBufferData (GL_ARRAY_BUFFER,
554  sizeof(quadTextureCoordinates),
556  GL_STATIC_DRAW));
557  GL_CHECK(glVertexAttribPointer (mergeProgramLocations.texCoordLocation,
558  2,
559  GL_FLOAT,
560  GL_FALSE,
561  0,
562  0));
563  GL_CHECK(glEnableVertexAttribArray(mergeProgramLocations.texCoordLocation));
564 
565  /* Set line width to 1.5, to avoid rounding errors. */
566  GL_CHECK(glLineWidth(1.5));
567 
568  timer.reset();
569 }
570 
571 /* Please see the specification above. */
573 {
576 
577  if (timer.getTime()> timeInterval)
578  {
579  resetTextures();
580  timer.reset();
581  }
582 }
583 
584 /* Please see the specification above. */
586 {
587  /* Delete existing texture data. */
589 
590  /* Create new texture data. */
593 
594  /* [Substitute ping texture data] */
595  /* Since texture objects have already been created, we can substitute ping image using glTexSubImage2D call.
596  * Pong texture does not require reset, because its content depends entirely on the first line of the ping texture. */
597  GL_CHECK(glActiveTexture(GL_TEXTURE0));
598  GL_CHECK(glTexSubImage2D(GL_TEXTURE_2D,
599  0,
600  0,
601  0,
602  windowWidth,
603  windowHeight,
604  GL_RED_INTEGER,
605  GL_UNSIGNED_BYTE,
606  pingTextureData));
607  /* [Substitute ping texture data] */
608 }
609 
610 /* Please see the specification above. */
611 void uninit()
612 {
613  /* Delete texture data. */
615 }
616 
617 extern "C"
618 {
619  JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_integerLogic_NativeLibrary_init (JNIEnv * env, jobject obj, jint width, jint height);
620  JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_integerLogic_NativeLibrary_step (JNIEnv * env, jobject obj);
621  JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_integerLogic_NativeLibrary_uninit(JNIEnv * env, jobject obj);
622 };
623 
625  JNIEnv * env, jobject obj, jint width, jint height)
626 {
627  setupGraphics(width, height);
628 }
629 
631  JNIEnv * env, jobject obj)
632 {
633  uninit();
634 }
635 
636 
638  JNIEnv * env, jobject obj)
639 {
640  renderFrame();
641 }
void setupGraphics(int width, int height)
Definition: Native.cpp:1256
GLvoid * pingTextureData
Definition: Native.cpp:79
const float timeInterval
Definition: Native.cpp:110
void renderToBackBuffer()
Definition: Native.cpp:267
#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
static const float quadVertices[]
Definition: IntegerLogic.h:96
#define VERTEX_RULE_30_SHADER_FILENAME
Definition: IntegerLogic.h:31
static void createTexture(unsigned int width, unsigned int height, GLvoid **textureData)
Create a texture using random data.
Definition: Texture.cpp:103
int windowHeight
Definition: Native.cpp:574
Matrix modelViewProjectionMatrix[VIEWS]
Definition: Native.cpp:141
GLuint quadUVBOID
Definition: Native.cpp:94
GLint GLsizei GLsizei height
Definition: gl2ext.h:179
void resetTextures()
Definition: Native.cpp:585
GLuint pongTextureID
Definition: Native.cpp:83
const GLuint pongTextureUnit
Definition: Native.cpp:75
Functions for manipulating matrices.
Definition: Matrix.h:31
static const float lineVertices[]
Definition: IntegerLogic.h:86
#define VERTEX_MERGE_SHADER_FILENAME
Definition: IntegerLogic.h:33
Provides a platform independent high resolution timer.
Definition: Timer.h:37
static Matrix matrixOrthographic(float left, float right, float bottom, float top, float zNear, float zFar)
Create and return an orthographic projection matrix.
Definition: Matrix.cpp:483
static Matrix createScaling(float x, float y, float z)
Create and return a scaling matrix.
Definition: Matrix.cpp:403
GLuint framebufferID
Definition: Native.cpp:86
GLuint rule30ProgramID
Definition: Native.cpp:67
static void deleteTextureData(GLvoid **textureData)
Deletes previously created texture.
Definition: Texture.cpp:162
const GLuint pingTextureUnit
Definition: Native.cpp:73
float * getAsArray(void)
Get the matrix elements as a column major order array.
Definition: Matrix.cpp:78
static const float lineTextureCoordinates[]
Definition: IntegerLogic.h:105
static mat4 orthographic(float left, float right, float bottom, float top, float near, float far)
Definition: matrix.h:172
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_integerLogic_NativeLibrary_uninit(JNIEnv *env, jobject obj)
Definition: Native.cpp:630
void reset()
Resets the timer to 0.0f.
Definition: Timer.cpp:100
void generateRule30Input(unsigned int xoffset, unsigned int width, unsigned int height, unsigned int nComponents, GLvoid **textureData)
Generates input for Rule 30 Cellular Automaton, setting a white dot in the top line of the texture on...
Definition: Native.cpp:161
void uninit()
Delete created objects and free allocated memory.
Definition: Native.cpp:1706
Rule30ProgramLocations rule30ProgramLocations
Definition: Native.cpp:106
GLfloat GLfloat f
Definition: gl2ext.h:2707
MergeProgramLocations mergeProgramLocations
Definition: Native.cpp:104
GLuint mergeProgramID
Definition: Native.cpp:69
void renderFrame(void)
Definition: Native.cpp:1536
Matrix scale
Definition: RotoZoom.cpp:64
GLuint quadVAOID
Definition: Native.cpp:98
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_integerLogic_NativeLibrary_step(JNIEnv *env, jobject obj)
Definition: Native.cpp:637
unsigned char * textureData
Definition: ThreadSync.cpp:109
GLuint linePositionBOID
Definition: Native.cpp:88
GLint GLint xoffset
Definition: gl2ext.h:573
#define FRAGMENT_RULE_30_SHADER_FILENAME
Definition: IntegerLogic.h:35
static const float quadTextureCoordinates[]
Definition: IntegerLogic.h:112
Timer timer
Definition: Native.cpp:1059
int windowWidth
Definition: Native.cpp:575
#define FRAGMENT_MERGE_SHADER_FILENAME
Definition: IntegerLogic.h:37
GLuint lineVAOID
Definition: Native.cpp:96
GLuint pingTextureID
Definition: Native.cpp:81
#define ASSERT(x, s)
Definition: common.h:45
precision highp float
Definition: hiz_cull.cs:37
GLint GLsizei width
Definition: gl2ext.h:179
GLuint lineUVBOID
Definition: Native.cpp:90
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
typedef GLuint(GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count
GLint y
Definition: gl2ext.h:179
void performOffscreenRendering()
Definition: Native.cpp:202
GLuint quadPositionBOID
Definition: Native.cpp:92
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_integerLogic_NativeLibrary_init(JNIEnv *env, jobject obj, jint width, jint height)
Definition: Native.cpp:624