OpenGL ES SDK for Android ARM Developer Center
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AstcTextures.cpp File Reference
#include <jni.h>
#include <GLES3/gl3.h>
#include <cstdlib>
#include <cmath>
#include <string>
#include "Text.h"
#include "AstcTextures.h"
#include "Timer.h"
#include "SolidSphere.h"

Go to the source code of this file.

Functions

const string resource_directory ("/data/data/com.arm.malideveloper.openglessdk.astctextureslowprecision/files/")
 
GLint get_and_check_attrib_location (GLuint program, const GLchar *attrib_name)
 Invoke glGetAttribLocation(), if it has returned a positive value. Otherwise, print a message and exit. Function used for clarity reasons. More...
 
GLint get_and_check_uniform_location (GLuint program, const GLchar *uniform_name)
 Invoke glGetUniformLocation, if it has returned a positive value. Otherwise, print a message and exit. Function used for clarity reasons. More...
 
GLuint load_shader (GLenum shader_type, const char *shader_source)
 Create shader object and compile its source code. More...
 
GLuint create_program (const char *vertex_source, const char *fragment_source)
 Create program object, attach vertex and fragment shader to it. Link program object and check whether it has succeeded. More...
 
void update_texture_bindings (bool force_switch_texture)
 Update texture bindings and text presented by text renderer. More...
 
GLuint load_texture (const char *file_name, GLenum decode_format, GLenum compressed_data_internal_format)
 Define and retrieve compressed texture image. More...
 
void load_textures (void)
 Define 32 texture sets that the demo will switch between every 5 seconds. More...
 
void setup_program (void)
 This function sets up a program object that will be used for rendering, as well as retrieves attribute & uniform locations. More...
 
void load_buffer_data (void)
 Sets up a buffer object that will hold mesh data (vertex positions, normal vectors, textures UV coordinates). More...
 
void setup_graphics (int width, int height)
 
void render_frame (void)
 Renders a single frame. More...
 
void cleanup_graphics (void)
 Perform graphics clean-up actions. More...
 
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_astctextureslowprecision_NativeLibrary_init (JNIEnv *, jobject, jint width, jint height)
 
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_astctextureslowprecision_NativeLibrary_step (JNIEnv *, jobject)
 
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_astctextureslowprecision_NativeLibrary_uninit (JNIEnv *, jobject)
 

Variables

Timer timer
 
Timer fps_timer
 
Texttext_displayer = NULL
 
SolidSpheresolid_sphere = NULL
 
int window_width = 0
 
int window_height = 0
 
const float field_of_view = M_PI * 60.0f / 180.0f
 
float x_to_y_ratio = 0
 
const float z_near = 0.01f
 
const float z_far = 100.0f
 
GLint cloud_texture_location = 0
 
GLint daytime_texture_location = 0
 
GLint nighttime_texture_location = 0
 
GLint mv_location = 0
 
GLint mvp_location = 0
 
GLint normal_location = 0
 
GLint position_location = 0
 
GLint texture_coords_location = 0
 
GLuint bo_id = 0
 
GLuint vert_shader_id = 0
 
GLuint frag_shader_id = 0
 
GLuint program_id = 0
 
GLuint vao_id = 0
 
float angle_x = 0
 
float angle_y = 0
 
float angle_z = 0
 
float current_time = 0
 
Matrix model_view_matrix
 
Matrix mvp_matrix
 
Matrix perspective_matrix
 
Matrix rotate_matrix
 
unsigned int current_texture_set_id = 0
 
int sphere_indices_size = 0
 
unsigned short * sphere_indices = NULL
 
static bool astc_decode_mode_supported = false
 
static bool astc_decode_mode_rgb9e5_supported = false
 
texture_set_info texture_sets_info []
 
const int n_texture_ids = sizeof(texture_sets_info) / sizeof(texture_sets_info[0])
 
texture_set texture_ids [n_texture_ids] = { 0 }
 

Function Documentation

void cleanup_graphics ( void  )

Perform graphics clean-up actions.

Definition at line 676 of file AstcTextures.cpp.

GLuint create_program ( const char *  vertex_source,
const char *  fragment_source 
)

Create program object, attach vertex and fragment shader to it. Link program object and check whether it has succeeded.

Parameters
[in]vertex_sourceVertex or fragment shader.
[in]fragment_sourceShader source code.
Returns
Program object ID.

Definition at line 232 of file AstcTextures.cpp.

GLint get_and_check_attrib_location ( GLuint  program,
const GLchar *  attrib_name 
)

Invoke glGetAttribLocation(), if it has returned a positive value. Otherwise, print a message and exit. Function used for clarity reasons.

Parameters
[in]programOpenGL ES specific.
[in]attrib_nameOpenGL ES specific.

Definition at line 163 of file AstcTextures.cpp.

GLint get_and_check_uniform_location ( GLuint  program,
const GLchar *  uniform_name 
)

Invoke glGetUniformLocation, if it has returned a positive value. Otherwise, print a message and exit. Function used for clarity reasons.

Parameters
[in]programOpenGL ES specific.
[in]uniform_nameOpenGL ES specific.

Definition at line 177 of file AstcTextures.cpp.

JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_astctextureslowprecision_NativeLibrary_init ( JNIEnv *  ,
jobject  ,
jint  width,
jint  height 
)

Definition at line 716 of file AstcTextures.cpp.

JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_astctextureslowprecision_NativeLibrary_step ( JNIEnv *  ,
jobject   
)

Definition at line 721 of file AstcTextures.cpp.

JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_astctextureslowprecision_NativeLibrary_uninit ( JNIEnv *  ,
jobject   
)

Definition at line 726 of file AstcTextures.cpp.

void load_buffer_data ( void  )

Sets up a buffer object that will hold mesh data (vertex positions, normal vectors, textures UV coordinates).

Definition at line 489 of file AstcTextures.cpp.

GLuint load_shader ( GLenum  shader_type,
const char *  shader_source 
)

Create shader object and compile its source code.

Parameters
[in]shader_typeVertex or fragment shader.
[in]shader_sourceShader source code.
Returns
Shader object ID.

Definition at line 191 of file AstcTextures.cpp.

GLuint load_texture ( const char *  file_name,
GLenum  decode_format,
GLenum  compressed_data_internal_format 
)

Define and retrieve compressed texture image.

Parameters
[in]file_nameTexture file name.
[in]decode_formatASTC internal decode format
[in]compressed_data_internal_formatASTC compression internal format.

Definition at line 333 of file AstcTextures.cpp.

void load_textures ( void  )

Define 32 texture sets that the demo will switch between every 5 seconds.

Definition at line 438 of file AstcTextures.cpp.

void render_frame ( void  )

Renders a single frame.

Definition at line 629 of file AstcTextures.cpp.

const string resource_directory ( "/data/data/com.arm.malideveloper.openglessdk.astctextureslowprecision/files/"  )
void setup_graphics ( int  width,
int  height 
)

Definition at line 566 of file AstcTextures.cpp.

void setup_program ( void  )

This function sets up a program object that will be used for rendering, as well as retrieves attribute & uniform locations.

Definition at line 465 of file AstcTextures.cpp.

void update_texture_bindings ( bool  force_switch_texture)

Update texture bindings and text presented by text renderer.

Parameters
[in]force_switch_textureIf true texture is immediately switched, if false texture is switched after interval passes.

Definition at line 285 of file AstcTextures.cpp.

Variable Documentation

float angle_x = 0

Definition at line 94 of file AstcTextures.cpp.

float angle_y = 0

Definition at line 95 of file AstcTextures.cpp.

float angle_z = 0

Definition at line 96 of file AstcTextures.cpp.

bool astc_decode_mode_rgb9e5_supported = false
static

Definition at line 120 of file AstcTextures.cpp.

bool astc_decode_mode_supported = false
static

Definition at line 119 of file AstcTextures.cpp.

GLuint bo_id = 0

Definition at line 81 of file AstcTextures.cpp.

GLint cloud_texture_location = 0

Definition at line 67 of file AstcTextures.cpp.

unsigned int current_texture_set_id = 0

Definition at line 114 of file AstcTextures.cpp.

float current_time = 0

Definition at line 99 of file AstcTextures.cpp.

GLint daytime_texture_location = 0

Definition at line 68 of file AstcTextures.cpp.

const float field_of_view = M_PI * 60.0f / 180.0f

Definition at line 57 of file AstcTextures.cpp.

Timer fps_timer

Definition at line 40 of file AstcTextures.cpp.

GLuint frag_shader_id = 0

Definition at line 85 of file AstcTextures.cpp.

Matrix model_view_matrix

Definition at line 102 of file AstcTextures.cpp.

GLint mv_location = 0

Definition at line 72 of file AstcTextures.cpp.

GLint mvp_location = 0

Definition at line 73 of file AstcTextures.cpp.

Matrix mvp_matrix

Definition at line 105 of file AstcTextures.cpp.

const int n_texture_ids = sizeof(texture_sets_info) / sizeof(texture_sets_info[0])

Definition at line 157 of file AstcTextures.cpp.

GLint nighttime_texture_location = 0

Definition at line 69 of file AstcTextures.cpp.

GLint normal_location = 0

Definition at line 76 of file AstcTextures.cpp.

Matrix perspective_matrix

Definition at line 108 of file AstcTextures.cpp.

GLint position_location = 0

Definition at line 77 of file AstcTextures.cpp.

GLuint program_id = 0

Definition at line 88 of file AstcTextures.cpp.

Matrix rotate_matrix

Definition at line 111 of file AstcTextures.cpp.

SolidSphere* solid_sphere = NULL

Definition at line 47 of file AstcTextures.cpp.

unsigned short* sphere_indices = NULL

Definition at line 117 of file AstcTextures.cpp.

int sphere_indices_size = 0

Definition at line 116 of file AstcTextures.cpp.

Text* text_displayer = NULL

Definition at line 44 of file AstcTextures.cpp.

GLint texture_coords_location = 0

Definition at line 78 of file AstcTextures.cpp.

texture_set texture_ids[n_texture_ids] = { 0 }

Definition at line 160 of file AstcTextures.cpp.

texture_set_info texture_sets_info[]

Definition at line 123 of file AstcTextures.cpp.

Timer timer

Definition at line 37 of file AstcTextures.cpp.

GLuint vao_id = 0

Definition at line 91 of file AstcTextures.cpp.

GLuint vert_shader_id = 0

Definition at line 84 of file AstcTextures.cpp.

int window_height = 0

Definition at line 54 of file AstcTextures.cpp.

int window_width = 0

Definition at line 53 of file AstcTextures.cpp.

float x_to_y_ratio = 0

Definition at line 60 of file AstcTextures.cpp.

const float z_far = 100.0f

Definition at line 64 of file AstcTextures.cpp.

const float z_near = 0.01f

Definition at line 63 of file AstcTextures.cpp.