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 "Utils.h"
#include <jni.h>
#include <android/log.h>
#include <GLES3/gl3.h>
#include <EGL/egl.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <fstream>
#include "model3d.h"
#include "Matrix.h"

Go to the source code of this file.

Macros

#define FOVEATED
 
#define RATIO   0.3
 
#define MASK
 
#define RED
 
#define VIEWS   4
 
#define LOG_TAG   "Foveated_Sample"
 
#define LOGI(...)   __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
 
#define LOGE(...)   __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
 
#define GL_CHECK(x)
 
#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY   0x9102
 

Typedefs

typedef void(* PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVR )(GLenum, GLenum, GLuint, GLint, GLint, GLsizei)
 
typedef void(* PFNGLFRAMEBUFFERTEXTUREMULTISAMPLEMULTIVIEWOVR )(GLenum, GLenum, GLuint, GLint, GLsizei, GLint, GLsizei)
 
typedef void(* PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXT )(GLenum, GLenum, GLenum, GLuint, GLint, GLsizei)
 
typedef void(* PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXT )(GLenum, GLsizei, GLenum, GLsizei, GLsizei)
 

Functions

void generateDepthCircleVBO (const uint8_t circleStep, const float radius)
 
GLuint loadShader (GLenum shaderType, const char *shaderSource, const int *length=NULL)
 
char * loadShaderFromFile (const std::string &filename, int *shaderLength)
 
GLuint createProgram (const char *vertexSource, const char *fragmentSource, const int *vertexLength=NULL, const int *fragmentLength=NULL)
 
bool createTexture (std::string filename, GLuint *textureLocation)
 
bool setupFBO (int width, int height)
 
bool setupGraphics (int width, int height)
 
void renderToFBO (const int width, const int height, const GLuint frameBufferID)
 
void renderFrame ()
 
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_foveatedrendering_NativeLibrary_init (JNIEnv *env, jobject obj, jint width, jint height, jstring localPath)
 
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_foveatedrendering_NativeLibrary_step (JNIEnv *env, jobject obj)
 

Variables

GLuint fboWidth
 
GLuint fboHeight
 
GLuint screenWidth
 
GLuint screenHeight
 
GLuint frameBufferObjectId
 
GLuint frameBufferTextureId
 
GLuint frameBufferDepthTextureId
 
GLuint multiviewProgram
 
GLuint multiviewVertexLocation
 
GLuint multiviewVertexNormalLocation
 
GLuint multiviewVertexTangentLocation
 
GLuint multiviewVertexUVLocation
 
GLuint multiviewViewLocation
 
GLuint multiviewModelViewLocation
 
GLuint multiviewModelViewProjectionLocation
 
GLuint multiviewProjectionLocation
 
GLuint multiviewModelLocation
 
GLuint multiviewTimeLocation
 
GLuint textureIdDiffuse
 
GLuint multiviewTextureDiffuse
 
GLuint textureIdNormal
 
GLuint multiviewTextureNormal
 
GLuint textureIdMetallicRoughness
 
GLuint multiviewTextureMetallicRoughness
 
GLuint textureIdBump
 
GLuint multiviewTextureBump
 
GLuint texturedQuadProgram
 
GLuint texturedQuadVertexLocation
 
GLuint texturedQuadLowResTexCoordLocation
 
GLuint texturedQuadHighResTexCoordLocation
 
GLuint texturedQuadSamplerLocation
 
GLuint texturedQuadLayerIndexLocation
 
GLuint textureQuadFoveatedRatio
 
GLuint textureQuadWidthHeight
 
GLuint maskProgram
 
GLuint maskVertexLocation
 
GLuint maskTypeLocation
 
GLuint masklInsetVertexArray
 
GLuint maskOutsetVertexArray
 
Matrix projectionMatrix [VIEWS]
 
Matrix viewMatrix [VIEWS]
 
Matrix viewProjectionMatrix [VIEWS]
 
Matrix modelViewMatrix [VIEWS]
 
Matrix modelViewProjectionMatrix [VIEWS]
 
Matrix modelMatrix
 
float angle = 0
 
const uint8_t circleStepConst = 16
 
const uint16_t TextureSize = 2048
 
std::string assetFolder
 
Model3D::Model3D room
 
std::vector< GLushort > I_OutsetCircle
 
PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVR glFramebufferTextureMultiviewOVR
 
PFNGLFRAMEBUFFERTEXTUREMULTISAMPLEMULTIVIEWOVR glFramebufferTextureMultisampleMultiviewOVR
 
PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXT glFramebufferTexture2DMultisampleEXT
 
PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXT glRenderbufferStorageMultisampleEXT
 
static const char texturedQuadFragmentShader []
 
float texturedQuadCoordinates []
 
float texturedQuadLowResTexCoordinates []
 
float texturedQuadHighResTexCoordinates []
 

Macro Definition Documentation

#define FOVEATED

Definition at line 21 of file Native.cpp.

#define GL_CHECK (   x)
Value:
x; \
{ \
GLenum glError = glGetError(); \
if(glError != GL_NO_ERROR) { \
LOGE("glGetError() = %i (0x%.8x) at %s:%i\n", glError, glError, __FILE__, __LINE__); \
exit(1); \
} \
}
#define LOGE(...)
Definition: Native.cpp:62
GLint GLint GLint GLint GLint x
Definition: gl2ext.h:574
typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void)

Definition at line 64 of file Native.cpp.

#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY   0x9102

Definition at line 156 of file Native.cpp.

#define LOG_TAG   "Foveated_Sample"

Definition at line 60 of file Native.cpp.

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

Definition at line 62 of file Native.cpp.

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

Definition at line 61 of file Native.cpp.

#define MASK

Definition at line 23 of file Native.cpp.

#define RATIO   0.3

Definition at line 22 of file Native.cpp.

#define RED

Definition at line 24 of file Native.cpp.

#define VIEWS   4

Definition at line 31 of file Native.cpp.

Typedef Documentation

typedef void( * PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXT)(GLenum, GLenum, GLenum, GLuint, GLint, GLsizei)

Definition at line 166 of file Native.cpp.

typedef void( * PFNGLFRAMEBUFFERTEXTUREMULTISAMPLEMULTIVIEWOVR)(GLenum, GLenum, GLuint, GLint, GLsizei, GLint, GLsizei)

Definition at line 162 of file Native.cpp.

typedef void( * PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVR)(GLenum, GLenum, GLuint, GLint, GLint, GLsizei)

Definition at line 158 of file Native.cpp.

typedef void( * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXT)(GLenum, GLsizei, GLenum, GLsizei, GLsizei)

Definition at line 169 of file Native.cpp.

Function Documentation

GLuint createProgram ( const char *  vertexSource,
const char *  fragmentSource,
const int vertexLength = NULL,
const int fragmentLength = NULL 
)

Definition at line 399 of file Native.cpp.

bool createTexture ( std::string  filename,
GLuint textureLocation 
)

Definition at line 445 of file Native.cpp.

void generateDepthCircleVBO ( const uint8_t  circleStep,
const float  radius 
)

Definition at line 258 of file Native.cpp.

JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_foveatedrendering_NativeLibrary_init ( JNIEnv *  env,
jobject  obj,
jint  width,
jint  height,
jstring  localPath 
)

Definition at line 909 of file Native.cpp.

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

Definition at line 917 of file Native.cpp.

GLuint loadShader ( GLenum  shaderType,
const char *  shaderSource,
const int length = NULL 
)

Definition at line 353 of file Native.cpp.

char* loadShaderFromFile ( const std::string &  filename,
int shaderLength 
)

Definition at line 388 of file Native.cpp.

void renderFrame ( void  )

Definition at line 822 of file Native.cpp.

void renderToFBO ( const int  width,
const int  height,
const GLuint  frameBufferID 
)

Definition at line 729 of file Native.cpp.

bool setupFBO ( int  width,
int  height 
)

Definition at line 468 of file Native.cpp.

bool setupGraphics ( int  width,
int  height 
)

Definition at line 535 of file Native.cpp.

Variable Documentation

float angle = 0

Definition at line 143 of file Native.cpp.

std::string assetFolder

Definition at line 150 of file Native.cpp.

const uint8_t circleStepConst = 16

Definition at line 145 of file Native.cpp.

GLuint fboHeight

Definition at line 76 of file Native.cpp.

GLuint fboWidth

Definition at line 75 of file Native.cpp.

GLuint frameBufferDepthTextureId

Definition at line 95 of file Native.cpp.

GLuint frameBufferObjectId

Definition at line 86 of file Native.cpp.

GLuint frameBufferTextureId

Definition at line 94 of file Native.cpp.

PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXT glFramebufferTexture2DMultisampleEXT

Definition at line 167 of file Native.cpp.

PFNGLFRAMEBUFFERTEXTUREMULTISAMPLEMULTIVIEWOVR glFramebufferTextureMultisampleMultiviewOVR

Definition at line 163 of file Native.cpp.

PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVR glFramebufferTextureMultiviewOVR

Definition at line 159 of file Native.cpp.

PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXT glRenderbufferStorageMultisampleEXT

Definition at line 170 of file Native.cpp.

std::vector<GLushort> I_OutsetCircle

Definition at line 153 of file Native.cpp.

GLuint masklInsetVertexArray

Definition at line 134 of file Native.cpp.

GLuint maskOutsetVertexArray

Definition at line 135 of file Native.cpp.

GLuint maskProgram

Definition at line 131 of file Native.cpp.

GLuint maskTypeLocation

Definition at line 133 of file Native.cpp.

GLuint maskVertexLocation

Definition at line 132 of file Native.cpp.

Matrix modelMatrix

Definition at line 142 of file Native.cpp.

Matrix modelViewMatrix[VIEWS]

Definition at line 140 of file Native.cpp.

Matrix modelViewProjectionMatrix[VIEWS]

Definition at line 141 of file Native.cpp.

GLuint multiviewModelLocation

Definition at line 107 of file Native.cpp.

GLuint multiviewModelViewLocation

Definition at line 104 of file Native.cpp.

GLuint multiviewModelViewProjectionLocation

Definition at line 105 of file Native.cpp.

GLuint multiviewProgram

Definition at line 98 of file Native.cpp.

GLuint multiviewProjectionLocation

Definition at line 106 of file Native.cpp.

GLuint multiviewTextureBump

Definition at line 120 of file Native.cpp.

GLuint multiviewTextureDiffuse

Definition at line 111 of file Native.cpp.

GLuint multiviewTextureMetallicRoughness

Definition at line 117 of file Native.cpp.

GLuint multiviewTextureNormal

Definition at line 114 of file Native.cpp.

GLuint multiviewTimeLocation

Definition at line 108 of file Native.cpp.

GLuint multiviewVertexLocation

Definition at line 99 of file Native.cpp.

GLuint multiviewVertexNormalLocation

Definition at line 100 of file Native.cpp.

GLuint multiviewVertexTangentLocation

Definition at line 101 of file Native.cpp.

GLuint multiviewVertexUVLocation

Definition at line 102 of file Native.cpp.

GLuint multiviewViewLocation

Definition at line 103 of file Native.cpp.

Matrix projectionMatrix[VIEWS]

Definition at line 137 of file Native.cpp.

Definition at line 151 of file Native.cpp.

GLuint screenHeight

Definition at line 78 of file Native.cpp.

GLuint screenWidth

Definition at line 77 of file Native.cpp.

float texturedQuadCoordinates[]
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
}

Definition at line 223 of file Native.cpp.

const char texturedQuadFragmentShader[]
static

Definition at line 173 of file Native.cpp.

float texturedQuadHighResTexCoordinates[]
Initial value:
=
{
0, 0,
1, 0,
1, 1,
0, 0,
1, 1,
0, 1
}

Definition at line 247 of file Native.cpp.

GLuint texturedQuadHighResTexCoordLocation

Definition at line 125 of file Native.cpp.

GLuint texturedQuadLayerIndexLocation

Definition at line 127 of file Native.cpp.

float texturedQuadLowResTexCoordinates[]
Initial value:
=
{
0, 0,
1, 0,
1, 1,
0, 0,
1, 1,
0, 1
}

Definition at line 235 of file Native.cpp.

GLuint texturedQuadLowResTexCoordLocation

Definition at line 124 of file Native.cpp.

GLuint texturedQuadProgram

Definition at line 122 of file Native.cpp.

GLuint texturedQuadSamplerLocation

Definition at line 126 of file Native.cpp.

GLuint texturedQuadVertexLocation

Definition at line 123 of file Native.cpp.

GLuint textureIdBump

Definition at line 119 of file Native.cpp.

GLuint textureIdDiffuse

Definition at line 110 of file Native.cpp.

GLuint textureIdMetallicRoughness

Definition at line 116 of file Native.cpp.

GLuint textureIdNormal

Definition at line 113 of file Native.cpp.

GLuint textureQuadFoveatedRatio

Definition at line 128 of file Native.cpp.

GLuint textureQuadWidthHeight

Definition at line 129 of file Native.cpp.

const uint16_t TextureSize = 2048

Definition at line 148 of file Native.cpp.

Matrix viewMatrix[VIEWS]

Definition at line 138 of file Native.cpp.

Matrix viewProjectionMatrix[VIEWS]

Definition at line 139 of file Native.cpp.