OpenGL ES SDK for Android ARM Developer Center
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Native.cpp File Reference
#include <jni.h>
#include <android/log.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include "Matrix.h"
#include "Texture.h"

Go to the source code of this file.

Macros

#define LOG_TAG   "libNative"
 
#define LOGI(...)   __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
 
#define LOGE(...)   __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
 

Functions

GLuint loadShader (GLenum shaderType, const char *shaderSource)
 
GLuint createProgram (const char *vertexSource, const char *fragmentSource)
 
bool setupGraphics (int width, int height)
 
void renderFrame ()
 
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_normalmapping_NativeLibrary_init (JNIEnv *env, jobject obj, jint width, jint height)
 
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_normalmapping_NativeLibrary_step (JNIEnv *env, jobject obj)
 

Variables

static const char glVertexShader []
 
static const char glFragmentShader []
 
GLuint glProgram
 
GLuint vertexLocation
 
GLuint samplerLocation
 
GLuint projectionLocation
 
GLuint modelViewLocation
 
GLuint textureCordLocation
 
GLuint colorLocation
 
GLuint textureId
 
GLuint vertexNormalLocation
 
GLuint tangentLocation
 
GLuint biNormalLocation
 
float projectionMatrix [16]
 
float modelViewMatrix [16]
 
float angle = 0
 
GLfloat cubeVertices []
 
GLfloat normals []
 
GLfloat colour []
 
GLfloat tangents []
 
GLfloat biNormals []
 
GLfloat textureCords []
 
GLushort indicies [] = {0, 3, 2, 0, 1, 3, 4, 6, 7, 4, 7, 5, 8, 9, 10, 8, 11, 10, 12, 13, 14, 15, 12, 14, 16, 17, 18, 16, 19, 18, 20, 21, 22, 20, 23, 22}
 

Macro Definition Documentation

#define LOG_TAG   "libNative"

Definition at line 34 of file Native.cpp.

#define LOGE (   ...)    __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)

Definition at line 36 of file Native.cpp.

#define LOGI (   ...)    __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)

Definition at line 35 of file Native.cpp.

Function Documentation

GLuint createProgram ( const char *  vertexSource,
const char *  fragmentSource 
)

Definition at line 142 of file Native.cpp.

JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_normalmapping_NativeLibrary_init ( JNIEnv *  env,
jobject  obj,
jint  width,
jint  height 
)

Definition at line 459 of file Native.cpp.

JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_normalmapping_NativeLibrary_step ( JNIEnv *  env,
jobject  obj 
)

Definition at line 465 of file Native.cpp.

GLuint loadShader ( GLenum  shaderType,
const char *  shaderSource 
)

Definition at line 105 of file Native.cpp.

void renderFrame ( void  )

Definition at line 409 of file Native.cpp.

bool setupGraphics ( int  width,
int  height 
)

Definition at line 210 of file Native.cpp.

Variable Documentation

float angle = 0

Definition at line 208 of file Native.cpp.

GLuint biNormalLocation

Definition at line 203 of file Native.cpp.

GLfloat biNormals[]
Initial value:
= { 0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 0.0f, -1.0f,
0.0f, 0.0f, -1.0f,
0.0f, 0.0f, -1.0f,
0.0f, 0.0f, -1.0f,
0.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f
}

Definition at line 354 of file Native.cpp.

GLuint colorLocation

Definition at line 199 of file Native.cpp.

GLfloat colour[]
Initial value:
= {1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f,
1.0f, 1.0f, 0.0f,
1.0f, 1.0f, 0.0f,
1.0f, 1.0f, 0.0f,
1.0f, 1.0f, 0.0f,
0.0f, 1.0f, 1.0f,
0.0f, 1.0f, 1.0f,
0.0f, 1.0f, 1.0f,
0.0f, 1.0f, 1.0f,
1.0f, 0.0f, 1.0f,
1.0f, 0.0f, 1.0f,
1.0f, 0.0f, 1.0f,
1.0f, 0.0f, 1.0f
}

Definition at line 302 of file Native.cpp.

GLfloat cubeVertices[]
Initial value:
= {-1.0f, 1.0f, -1.0f,
1.0f, 1.0f, -1.0f,
-1.0f, -1.0f, -1.0f,
1.0f, -1.0f, -1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
-1.0f, -1.0f, 1.0f,
1.0f, -1.0f, 1.0f,
-1.0f, 1.0f, -1.0f,
-1.0f, -1.0f, -1.0f,
-1.0f, -1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f, -1.0f,
1.0f, -1.0f, -1.0f,
1.0f, -1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
-1.0f, 1.0f, -1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, 1.0f, -1.0f,
-1.0f, - 1.0f, -1.0f,
-1.0f, -1.0f, 1.0f,
1.0f, - 1.0f, 1.0f,
1.0f, -1.0f, -1.0f
}

Definition at line 250 of file Native.cpp.

const char glFragmentShader[]
static

Definition at line 72 of file Native.cpp.

GLuint glProgram

Definition at line 191 of file Native.cpp.

const char glVertexShader[]
static

Definition at line 39 of file Native.cpp.

GLushort indicies[] = {0, 3, 2, 0, 1, 3, 4, 6, 7, 4, 7, 5, 8, 9, 10, 8, 11, 10, 12, 13, 14, 15, 12, 14, 16, 17, 18, 16, 19, 18, 20, 21, 22, 20, 23, 22}

Definition at line 406 of file Native.cpp.

GLuint modelViewLocation

Definition at line 197 of file Native.cpp.

float modelViewMatrix[16]

Definition at line 207 of file Native.cpp.

GLfloat normals[]
Initial value:
= {0.0f, 0.0f, -1.0f,
0.0f, 0.0f, -1.0f,
0.0f, 0.0f, -1.0f,
0.0f, 0.0f, -1.0f,
0.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f,
-1.0f, 0.0, 0.0f,
-1.0f, 0.0f, 0.0f,
-1.0f, 0.0f, 0.0f,
-1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, -1.0f, 0.0f,
0.0f, -1.0f, 0.0f,
0.0f, -1.0f, 0.0f,
0.0f, -1.0f, 0.0f
}

Definition at line 276 of file Native.cpp.

GLuint projectionLocation

Definition at line 196 of file Native.cpp.

float projectionMatrix[16]

Definition at line 206 of file Native.cpp.

GLuint samplerLocation

Definition at line 195 of file Native.cpp.

GLuint tangentLocation

Definition at line 202 of file Native.cpp.

GLfloat tangents[]
Initial value:
= {-1.0f, 0.0f, 0.0f,
-1.0f, 0.0f, 0.0f,
-1.0f, 0.0f, 0.0f,
-1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f,
0.0f, 0.0f, -1.0f,
0.0f, 0.0f, -1.0f,
0.0f, 0.0f, -1.0f,
0.0f, 0.0f, -1.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f
}

Definition at line 328 of file Native.cpp.

GLuint textureCordLocation

Definition at line 198 of file Native.cpp.

GLfloat textureCords[]
Initial value:
= {1.0f, 1.0f,
0.0f, 1.0f,
1.0f, 0.0f,
0.0f, 0.0f,
0.0f, 1.0f,
1.0f, 1.0f,
0.0f, 0.0f,
1.0f, 0.0f,
0.0f, 1.0f,
0.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f,
1.0f, 1.0f,
1.0f, 0.0f,
0.0f, 0.0f,
0.0f, 1.0f,
0.0f, 1.0f,
0.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f,
0.0f, 0.0f,
0.0f, 1.0f,
1.0f, 1.0f,
1.0f, 0.0f
}

Definition at line 380 of file Native.cpp.

GLuint textureId

Definition at line 200 of file Native.cpp.

GLuint vertexLocation

Definition at line 194 of file Native.cpp.

GLuint vertexNormalLocation

Definition at line 201 of file Native.cpp.