OpenGL ES SDK for Android ARM Developer Center
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Native.cpp File Reference

Demonstration of ETC2 texture compression support in OpenGL ES 3.0. More...

#include <jni.h>
#include <android/log.h>
#include <GLES3/gl3.h>
#include "Common.h"
#include "ETCHeader.h"
#include "EtcTexture.h"
#include "Matrix.h"
#include "Shader.h"
#include "Text.h"
#include "Texture.h"
#include "Timer.h"

Go to the source code of this file.

Classes

struct  Image
 

Functions

void initializeTexture (int textureIndex)
 
void setupTextures ()
 
void draw ()
 
void setupGraphics (int width, int height)
 
void renderFrame (void)
 
void uninit ()
 
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_etcTexture_NativeLibrary_init (JNIEnv *env, jobject obj, jint width, jint height)
 
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_etcTexture_NativeLibrary_step (JNIEnv *env, jobject obj)
 
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_etcTexture_NativeLibrary_uninit (JNIEnv *env, jobject obj)
 

Variables

Image image0
 
Image image1
 
Image image2
 
Image image3
 
Image image4
 
Image image5
 
Image image6
 
Image image7
 
Image image8
 
Image image9
 
Image imageArray []
 
GLuint bufferObjectIds [2] = {0}
 
GLuint currentAssetIndex = 0
 
const float displayInterval = 5.0f
 
GLuint fragmentShaderId = 0
 
TextinternalformatTextDisplayer = NULL
 
GLint modelViewMatrixLocation = 0
 
const int numberOfTextures = sizeof(imageArray) / sizeof(imageArray[0])
 
GLint positionLocation = 0
 
GLuint programId = 0
 
float scalingFactor = 0.75f
 
GLint textureCoordinateLocation = 0
 
GLint textureLocation = 0
 
Timer timer
 
int windowHeight = 0
 
int windowWidth = 0
 
GLuint vertexShaderId = 0
 
GLuint vertexArrayId = 0
 
float vertexData []
 
float textureCoordinatesData []
 

Detailed Description

Demonstration of ETC2 texture compression support in OpenGL ES 3.0.

Compressed textures are loaded and displayed on the screen. The internal format of each texture is displayed at the bottom of the screen. The application cycles through all of the texture formats supported by OpenGL ES 3.0.

Formats:

  • GL_COMPRESSED_R11_EAC: 11 bits for a single channel. Useful for single channel data where higher than 8 bit precision is needed. For example, heightmaps.
  • GL_COMPRESSED_SIGNED_R11_EAC: Signed version of GL_COMPRESSED_SIGNED_R11_EAC, useful when signed data is needed.
  • GL_COMPRESSED_RG11_EAC: 11 bits for two channels. Useful for two channel data where higher than 8 bit precision is needed. For example, normalised bump maps, the third component can be reconstructed from the other two components.
  • GL_COMPRESSED_SIGNED_RG11_EAC: Signed version of GL_COMPRESSED_RG11_EAC, useful when signed data is needed.
  • GL_COMPRESSED_RGB8_ETC2: 8 bits for three channels. Useful for normal textures without alpha values.
  • GL_COMPRESSED_SRGB8_ETC2: sRGB version of GL_COMPRESSED_RGB8_ETC2.
  • GL_COMPRESSED_RGBA8_ETC2_EAC: 8 bits for four channels. Useful for normal textures with varying alpha values.
  • GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: sRGB version of GL_COMPRESSED_RGBA8_ETC2_EAC.
  • GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 8 bits for three channels and a 1 bit alpha channel. Useful for normal textures with binary alpha values.
  • GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: sRGB version of GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2.

Definition in file Native.cpp.

Function Documentation

void draw ( void  )

Draw image and text into back buffer.

Definition at line 267 of file Native.cpp.

void initializeTexture ( int  textureIndex)

Generate and fill texture objects with data.

Parameters
textureIndexholds index of an imageArray (indicates which texture is to be created).

Definition at line 169 of file Native.cpp.

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

Definition at line 471 of file Native.cpp.

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

Definition at line 484 of file Native.cpp.

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

Definition at line 477 of file Native.cpp.

void renderFrame ( void  )

Render new frame's contents into back buffer.

Definition at line 416 of file Native.cpp.

void setupGraphics ( int  width,
int  height 
)

Create program that will be used to rasterize the geometry.

Definition at line 300 of file Native.cpp.

void setupTextures ( )

Initializes data used for rendering.

Definition at line 224 of file Native.cpp.

void uninit ( )

Definition at line 441 of file Native.cpp.

Variable Documentation

GLuint bufferObjectIds[2] = {0}

Definition at line 129 of file Native.cpp.

GLuint currentAssetIndex = 0

Definition at line 130 of file Native.cpp.

const float displayInterval = 5.0f

Definition at line 131 of file Native.cpp.

GLuint fragmentShaderId = 0

Definition at line 132 of file Native.cpp.

Image image0
Initial value:
= {GL_COMPRESSED_R11_EAC,
"GL_COMPRESSED_R11_EAC",
0}
#define TEXTURE_GL_COMPRESSED_R11_EAC_FILE_NAME
Definition: EtcTexture.h:35

Definition at line 76 of file Native.cpp.

Image image1
Initial value:
= {GL_COMPRESSED_SIGNED_R11_EAC,
"GL_COMPRESSED_SIGNED_R11_EAC",
0}
#define TEXTURE_GL_COMPRESSED_SIGNED_R11_EAC_FILE_NAME
Definition: EtcTexture.h:37

Definition at line 80 of file Native.cpp.

Image image2
Initial value:
= {GL_COMPRESSED_RG11_EAC,
"GL_COMPRESSED_RG11_EAC",
0}
#define TEXTURE_GL_COMPRESSED_RG11_EAC_FILE_NAME
Definition: EtcTexture.h:39

Definition at line 84 of file Native.cpp.

Image image3
Initial value:
= {GL_COMPRESSED_SIGNED_RG11_EAC,
"GL_COMPRESSED_SIGNED_RG11_EAC",
0}
#define TEXTURE_GL_COMPRESSED_SIGNED_RG11_EAC_FILE_NAME
Definition: EtcTexture.h:41

Definition at line 88 of file Native.cpp.

Image image4
Initial value:
= {GL_COMPRESSED_RGB8_ETC2,
"GL_COMPRESSED_RGB8_ETC2",
0}
#define TEXTURE_GL_COMPRESSED_RGB8_ETC2_FILE_NAME
Definition: EtcTexture.h:43

Definition at line 92 of file Native.cpp.

Image image5
Initial value:
= {GL_COMPRESSED_SRGB8_ETC2,
"GL_COMPRESSED_SRGB8_ETC2",
0}
#define TEXTURE_GL_COMPRESSED_SRGB8_ETC2_FILE_NAME
Definition: EtcTexture.h:45

Definition at line 96 of file Native.cpp.

Image image6
Initial value:
= {GL_COMPRESSED_RGBA8_ETC2_EAC,
"GL_COMPRESSED_RGBA8_ETC2_EAC",
0}
#define TEXTURE_GL_COMPRESSED_RGBA8_ETC2_EAC_FILE_NAME
Definition: EtcTexture.h:47

Definition at line 100 of file Native.cpp.

Image image7
Initial value:
= {GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
"GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",
0}
#define TEXTURE_GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC_FILE_NAME
Definition: EtcTexture.h:49

Definition at line 104 of file Native.cpp.

Image image8
Initial value:
= {GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
"GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",
0}
#define TEXTURE_GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2_FILE_NAME
Definition: EtcTexture.h:51

Definition at line 108 of file Native.cpp.

Image image9
Initial value:
= {GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
"GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",
0}
#define TEXTURE_GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2_FILE_NAME
Definition: EtcTexture.h:53

Definition at line 112 of file Native.cpp.

Image imageArray[]
Initial value:
= {image0,
Image image1
Definition: Native.cpp:80
Image image8
Definition: Native.cpp:108
Image image2
Definition: Native.cpp:84
Image image6
Definition: Native.cpp:100
Image image4
Definition: Native.cpp:92
Image image3
Definition: Native.cpp:88
Image image0
Definition: Native.cpp:76
Image image5
Definition: Native.cpp:96
Image image9
Definition: Native.cpp:112
Image image7
Definition: Native.cpp:104

Definition at line 118 of file Native.cpp.

Text* internalformatTextDisplayer = NULL

Definition at line 133 of file Native.cpp.

GLint modelViewMatrixLocation = 0

Definition at line 134 of file Native.cpp.

const int numberOfTextures = sizeof(imageArray) / sizeof(imageArray[0])

Definition at line 135 of file Native.cpp.

GLint positionLocation = 0

Definition at line 136 of file Native.cpp.

GLuint programId = 0

Definition at line 137 of file Native.cpp.

float scalingFactor = 0.75f

Definition at line 138 of file Native.cpp.

GLint textureCoordinateLocation = 0

Definition at line 139 of file Native.cpp.

float textureCoordinatesData[]
Initial value:
= {0.0f, 1.0f,
1.0f, 1.0f,
0.0f, 0.0f,
0.0f, 0.0f,
1.0f, 1.0f,
1.0f, 0.0f}

Definition at line 157 of file Native.cpp.

GLint textureLocation = 0

Definition at line 140 of file Native.cpp.

Timer timer

Definition at line 141 of file Native.cpp.

GLuint vertexArrayId = 0

Definition at line 145 of file Native.cpp.

float vertexData[]
Initial value:
= {-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, -1.0f, 0.0f,
1.0f, 1.0f, 0.0f}

Definition at line 148 of file Native.cpp.

GLuint vertexShaderId = 0

Definition at line 144 of file Native.cpp.

int windowHeight = 0

Definition at line 142 of file Native.cpp.

int windowWidth = 0

Definition at line 143 of file Native.cpp.