45 #include <android/log.h>
47 #include <GLES3/gl3.h>
59 using namespace MaliSDK;
126 unsigned int nComponents,
164 unsigned int nComponents,
167 ASSERT(textureData != NULL,
"Null data passed");
169 for(
unsigned int channelIndex = 0; channelIndex < nComponents; ++channelIndex)
171 (*(
unsigned char**)textureData)[(height - 1) * width * nComponents + xoffset * nComponents + channelIndex] = 255;
180 unsigned int nComponents,
183 ASSERT(textureData != NULL,
"Null data passed");
185 for (
unsigned int texelIndex = 0; texelIndex <
width; ++texelIndex)
187 bool setWhite = (rand() % 2 == 0) ?
true :
false;
191 for (
unsigned int channelIndex = 0; channelIndex < nComponents; ++channelIndex)
193 (*(
unsigned char**)textureData)[(height - 1) * width * nComponents + texelIndex * nComponents + channelIndex] = 255;
205 float inputVerticalOffset = 0.0f;
219 bool isEvenLineBeingRendered = (
y % 2 == 0) ? (
true) : (
false);
227 if (isEvenLineBeingRendered)
230 GL_CHECK(glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER,
231 GL_COLOR_ATTACHMENT0,
242 GL_CHECK(glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER,
243 GL_COLOR_ATTACHMENT0,
253 GL_CHECK(glDrawArrays(GL_LINES, 0, 2));
256 inputVerticalOffset = verticalOffset;
260 GL_CHECK(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0));
274 GL_CHECK(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
286 const GLuint offscreenFBODrawBuffers[] = {GL_COLOR_ATTACHMENT0};
295 -(
float) windowHeight * 2,
296 (
float) windowHeight * 2,
316 GLuint textureIDs[] = {0, 0};
319 GL_CHECK(glGenTextures(2, textureIDs));
328 GL_CHECK(glBindTexture (GL_TEXTURE_2D,
330 GL_CHECK(glTexImage2D (GL_TEXTURE_2D,
339 GL_CHECK(glTexParameteri(GL_TEXTURE_2D,
342 GL_CHECK(glTexParameteri(GL_TEXTURE_2D,
345 GL_CHECK(glTexParameteri(GL_TEXTURE_2D,
346 GL_TEXTURE_MAG_FILTER,
348 GL_CHECK(glTexParameteri(GL_TEXTURE_2D,
349 GL_TEXTURE_MIN_FILTER,
356 GL_CHECK(glBindTexture (GL_TEXTURE_2D,
358 GL_CHECK(glTexStorage2D (GL_TEXTURE_2D,
363 GL_CHECK(glTexParameteri(GL_TEXTURE_2D,
366 GL_CHECK(glTexParameteri(GL_TEXTURE_2D,
369 GL_CHECK(glTexParameteri(GL_TEXTURE_2D,
370 GL_TEXTURE_MAG_FILTER,
372 GL_CHECK(glTexParameteri(GL_TEXTURE_2D,
373 GL_TEXTURE_MIN_FILTER,
378 GLuint fragmentMergeShaderID = 0;
379 GLuint fragmentRule30ShaderID = 0;
380 GLuint vertexRule30ShaderID = 0;
381 GLuint vertexMergeShaderID = 0;
410 GLuint boIDs[] = {0, 0, 0, 0};
424 GL_CHECK(glBindFramebuffer(GL_DRAW_FRAMEBUFFER,
427 offscreenFBODrawBuffers));
469 1.0f / windowWidth) );
474 GL_CHECK(glBindBuffer (GL_ARRAY_BUFFER,
476 GL_CHECK(glBufferData (GL_ARRAY_BUFFER,
491 GL_CHECK(glBindBuffer (GL_ARRAY_BUFFER,
493 GL_CHECK(glBufferData (GL_ARRAY_BUFFER,
536 GL_CHECK(glBindBuffer (GL_ARRAY_BUFFER,
538 GL_CHECK(glBufferData (GL_ARRAY_BUFFER,
551 GL_CHECK(glBindBuffer (GL_ARRAY_BUFFER,
553 GL_CHECK(glBufferData (GL_ARRAY_BUFFER,
597 GL_CHECK(glActiveTexture(GL_TEXTURE0));
598 GL_CHECK(glTexSubImage2D(GL_TEXTURE_2D,
625 JNIEnv * env, jobject obj, jint
width, jint
height)
631 JNIEnv * env, jobject obj)
638 JNIEnv * env, jobject obj)
void renderToBackBuffer()
float getTime()
Returns the time passed since object creation or since reset() was last called.
static const float quadVertices[]
#define VERTEX_RULE_30_SHADER_FILENAME
static void createTexture(unsigned int width, unsigned int height, GLvoid **textureData)
Create a texture using random data.
GLint inputTextureLocation
Matrix modelViewProjectionMatrix[VIEWS]
GLint GLsizei GLsizei height
GLint inputVerticalOffsetLocation
GLint verticalOffsetLocation
const GLuint pongTextureUnit
Functions for manipulating matrices.
static const float lineVertices[]
#define VERTEX_MERGE_SHADER_FILENAME
GLint pongTextureLocation
Provides a platform independent high resolution timer.
static Matrix matrixOrthographic(float left, float right, float bottom, float top, float zNear, float zFar)
Create and return an orthographic projection matrix.
static Matrix createScaling(float x, float y, float z)
Create and return a scaling matrix.
static void deleteTextureData(GLvoid **textureData)
Deletes previously created texture.
const GLuint pingTextureUnit
float * getAsArray(void)
Get the matrix elements as a column major order array.
static const float lineTextureCoordinates[]
GLint pingTextureLocation
static mat4 orthographic(float left, float right, float bottom, float top, float near, float far)
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_integerLogic_NativeLibrary_uninit(JNIEnv *env, jobject obj)
void reset()
Resets the timer to 0.0f.
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...
void uninit()
Delete created objects and free allocated memory.
Rule30ProgramLocations rule30ProgramLocations
MergeProgramLocations mergeProgramLocations
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_integerLogic_NativeLibrary_step(JNIEnv *env, jobject obj)
unsigned char * textureData
#define FRAGMENT_RULE_30_SHADER_FILENAME
static const float quadTextureCoordinates[]
#define FRAGMENT_MERGE_SHADER_FILENAME
GLint inputNeighbourLocation
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
void performOffscreenRendering()
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_integerLogic_NativeLibrary_init(JNIEnv *env, jobject obj, jint width, jint height)