![]() |
Mali OpenGL ES SDK v2.4.4
Mali Developer Center
Use of the code snippets present within these pages are subject to these EULA terms
|
#include <cstdio>#include <cstdlib>#include <cmath>#include "Platform.h"#include "EGLRuntime.h"#include <GLES3/gl3.h>#include "Text.h"#include "AstcTextures.h"#include "Shader.h"#include "Timer.h"#include "SolidSphere.h"Functions | |
| void | update_texture_bindings (bool force_switch_texture) |
| Update texture bindings and text presented by text renderer. | |
| GLuint | load_texture (string file_name, int texture_compression) |
| Define and retrieve compressed texture image. | |
| void | load_textures (void) |
| Define 32 texture sets that the demo will switch between every 5 seconds. | |
| 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. | |
| 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. | |
| void | setup_program (void) |
| This function sets up a program object that will be used for rendering, as well as retrieves attribute & uniform locations. | |
| void | load_buffer_data (void) |
| Sets up a buffer object that will hold mesh data (vertex positions, normal vectors, textures UV coordinates). | |
| void | render_frame (void) |
| Renders a single frame. | |
| int | main (void) |
| 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.
| [in] | program | OpenGL ES specific. |
| [in] | attrib_name | OpenGL ES specific. |
| 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.
| [in] | program | OpenGL ES specific. |
| [in] | uniform_name | OpenGL ES specific. |
| void load_buffer_data | ( | void | ) |
Sets up a buffer object that will hold mesh data (vertex positions, normal vectors, textures UV coordinates).
| GLuint load_texture | ( | string | file_name, |
| int | texture_compression | ||
| ) |
Define and retrieve compressed texture image.
| [in] | file_name | Texture file name. |
| [in] | texture_compression | Compression type (ETC1/ETC2/ASTC). |
| void load_textures | ( | void | ) |
Define 32 texture sets that the demo will switch between every 5 seconds.
| int main | ( | void | ) |
| void render_frame | ( | void | ) |
Renders a single frame.
| void setup_program | ( | void | ) |
This function sets up a program object that will be used for rendering, as well as retrieves attribute & uniform locations.
| void update_texture_bindings | ( | bool | force_switch_texture | ) |
Update texture bindings and text presented by text renderer.
| [in] | force_switch_texture | If true texture is immediately switched, if false texture is switched after interval passes. |
| float angle_x = START_ANGLE_X_ROTATION |
| float angle_y = 0 |
| float angle_z = 0 |
| GLuint bo_id = 0 |
| GLint cloud_texture_location = 0 |
| unsigned int current_texture_set_id = 0 |
| float current_time = 0 |
| GLint daytime_texture_location = 0 |
| Timer fps_timer |
| GLuint frag_shader_id = 0 |
| Matrix model_view_matrix |
| GLint mv_location = 0 |
| GLint mvp_location = 0 |
| Matrix mvp_matrix |
| const int n_texture_ids = sizeof(texture_ids) / sizeof(texture_ids[0]) |
| GLint nighttime_texture_location = 0 |
| GLint normal_location = 0 |
| Matrix perspective_matrix = Matrix::matrixPerspective(field_of_view, x_to_y_ratio, z_near, z_far) |
| GLint position_location = 0 |
| GLuint program_id = 0 |
| Matrix rotate_matrix |
| SolidSphere* solid_sphere = NULL |
| unsigned short* sphere_indices = NULL |
| int sphere_indices_size = 0 |
| Text* text_displayer = NULL |
| GLint texture_coords_location = 0 |
| texture_set texture_ids[NUM_OF_TEXTURE_IDS] = { 0 } |
| texture_set_info texture_sets_info[] |
| Timer timer |
| GLuint vao_id = 0 |
| GLuint vert_shader_id = 0 |
| const unsigned int window_height = 768 |
| const unsigned int window_width = 1024 |
| const float x_to_y_ratio = (float) window_width / (float) window_height |
| const float z_far = 100.0f |
| const float z_near = 0.01f |