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

The application shows a bloom effect implementation. It draws cubes arranged in a two-dimensional 5x5 array, from which only the diagonal ones are bloomed. The intensity of the bloom effect changes from very weak, where each cube affected by the effect looks exactly as the normal ones, to very strong, when bloomed cubes make up an X shape. More...

#include <jni.h>
#include <android/log.h>
#include <GLES3/gl3.h>
#include "CubeModel.h"
#include "Matrix.h"
#include "Shader.h"

Go to the source code of this file.

Classes

struct  BlendingProgramLocations
 Structure holding locations of uniforms used by a program object responsible for applying the blend effect. More...
 
struct  BlurringObjects
 Structure holding ID of objects which were generated for blurring. More...
 
struct  BlurringProgramLocations
 Structure holding locations of uniforms used by a program object responsible for blurring. More...
 
struct  GetLuminanceImageBloomObjects
 Structure holding IDs of objects which were generated for generating downscaled texture with luminance image. More...
 
struct  ProgramAndShadersIds
 Structure holding program object ID and IDs of two shader objects (fragment and vertex). It is assumed that shader objects are/will be attached to program object. More...
 
struct  SceneRenderingObjects
 Structure holding ID of objects which were generated to support scene rendering. More...
 
struct  SceneRenderingProgramLocations
 Structure holding locations of attributes and uniforms used by a program object responsible for scene rendering. More...
 
struct  StrongerBlurObjects
 Structure holding IDs of objects which were generated for stronger texture blurring. More...
 

Macros

#define WINDOW_RESOLUTION_DIVISOR   (2)
 
#define NUMBER_OF_CUBES   (25)
 
#define CUBE_SCALAR   (0.8f)
 
#define BLUR_RADIUS   (3)
 
#define NUMBER_OF_COMPONENTS_PER_VERTEX   (3)
 
#define MAX_NUMBER_OF_BLUR_PASSES   (10)
 
#define MIN_NUMBER_OF_BLUR_PASSES   (2)
 
#define BLUR_MIX_FACTOR_STEP_VALUE   (0.05f)
 
#define BLUR_EFFECT_INCREASE   (1)
 
#define BLUR_EFFECT_DECREASE   (-1)
 
#define TIME_INTERVAL   (1.0f)
 
#define TEXTURE_UNIT_COLOR_TEXTURE   (0)
 
#define TEXTURE_UNIT_BLOOM_SOURCE_TEXTURE   (1)
 
#define TEXTURE_UNIT_HORIZONTAL_BLUR_TEXTURE   (2)
 
#define TEXTURE_UNIT_BLURRED_TEXTURE   (3)
 
#define TEXTURE_UNIT_STRONGER_BLUR_TEXTURE   (4)
 
#define HORIZONTAL_POSITION_CAMERA_DEPTH_LOCATION   (15.0f)
 
#define VERTICAL_POSITION_CAMERA_DEPTH_LOCATION   (20.0f)
 

Functions

static void deleteBlurringObjects (BlurringObjects *objectIdsStoragePtr)
 Delete objects which were generated for blurring purposes. According to the OpenGL ES specification, objects will not be deleted if bound. It is the user's responsibility to call glBindBuffer(), glBindFramebuffer() and glBindTexture() with default object ids (id = 0) at some point. More...
 
static void deleteGetLuminanceImageBloomObjects (GetLuminanceImageBloomObjects *objectIdsStoragePtr)
 Delete objects which were generated for getting downscaled luminance image. According to the OpenGL ES specification, objects will not be deleted if bound. It is the user's responsibility to call glBindFramebuffer() and glBindTexture() with default object ids (id = 0) at some point. More...
 
static void deleteProgramShaderObjects (ProgramAndShadersIds *objectsToBeDeletedPtr)
 Delete program and shader objects. According to the OpenGL ES specification, program object will not be deleted if it is active. It is the user's responsibility to call glUseProgram(0) at some point. More...
 
static void deleteSceneRenderingObjects (SceneRenderingObjects *objectIdsStoragePtr)
 Delete objects which were generated for scene rendering purposes. According to the OpenGL ES specification, objects will not be deleted if bound. It is the user's responsibility to call glBindBuffer(), glBindFramebuffer() and glBindTexture() with default object ids (id = 0) at some point. More...
 
static void deleteStrongerBlurObjects (StrongerBlurObjects *objectIdsStoragePtr)
 Delete objects which were generated for performing the stronger blur effect on downscaled textures. According to the OpenGL ES specification, objects will not be deleted if bound. It is the user's responsibility to call glBindFramebuffer() and glBindTexture() with default object ids (id = 0) at some point. More...
 
static void generateAndPrepareObjectsUsedForBlurring (GLuint *framebufferObjectIdPtr, GLuint *horizontalTextureObjectIdPtr, GLuint *verticalTextureObjectIdPtr)
 Generate texture and framebuffer objects, configure texture parameters. Finally, reset GL_TEXTURE_2D texture binding to 0 for active texture unit. Objects will be used for applying blur effect. More...
 
static void generateAndPrepareObjectsUsedForSceneRendering (GLuint *framebufferObjectIdPtr, GLuint *originalTextureObjectIdPtr, GLuint *depthToIdPtr)
 Generate texture and framebuffer objects and configure texture parameters accordingly. Finally, reset GL_FRAEMBUFFER and GL_TEXTURE_2D bindings to 0. Objects will be used for rendering the scene into texture. More...
 
static void generateDownscaledObjects (GLuint *fboIdPtr, GLuint *toIdPtr)
 Generate texture and framebuffer objects and configure texture parameters accordingly. Finally, reset GL_FRAEMBUFFER and GL_TEXTURE_2D bindings to 0. Texture size is equal to window resolution / WINDOW_RESOLUTION_DIVISOR. More...
 
static GLfloatgetCubeLocations (GLint numberOfColumns, GLint numberOfRows, GLfloat cubeScalar, GLfloat distanceBetweenCubes, GLint *numberOfCubeLocationCoordinatesPtr)
 Calculate the world space locations of all the cubes that we will be rendering. The cubes are arranged in a 2D array consisting of numberOfColumns columns and numberOfRows rows with the requested space between cubes. It is the user's responsibility to free allocated memory. More...
 
static void getLocationsForBlendingProgram (GLuint programObjectId, BlendingProgramLocations *locationsStoragePtr)
 Retrieve the locations of uniforms for the program object responsible for applying the blend effect. Can be called only if programObjectId is currently active. More...
 
static void getLocationsForBlurringProgram (GLuint programObjectId, BlurringProgramLocations *locationsStoragePtr)
 Retrieve the locations of uniforms for the program object responsible for applying the blur effect. Can be called only if programObjectId is currently active. More...
 
static void getLocationsForSceneRenderingProgram (GLuint programObjectId, SceneRenderingProgramLocations *locationsStoragePtr)
 Retrieve the locations of attributes and uniforms for the program object responsible for scene rendering. Can be called only if programObjectId is currently active. More...
 
static void initializeProgramObject (ProgramAndShadersIds *objectIdsPtr, const char *fragmentShaderSource, const char *vertexShaderSource)
 Create and compile shader objects. If successful, they are attached to the program object, which is then linked. More...
 
static void renderDowscaledLuminanceTexture ()
 
static void renderSceneColourTexture ()
 
static void setUniformValuesForSceneRenderingProgram (const SceneRenderingProgramLocations *locationsPtr, Matrix mvMatrix, Matrix mvpMatrix, Vec3f cameraPosition, Vec3f lightPosition)
 Configure the scene rendering program's uniforms. More...
 
void setupGraphics (int width, int height)
 Setup the environment: create and prepare objects for rendering purposes. More...
 
void renderFrame (float time)
 Render one frame. More...
 
void uninit ()
 Delete created objects and free allocated memory. More...
 
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_bloom_NativeLibrary_init (JNIEnv *env, jobject obj, jint width, jint height)
 
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_bloom_NativeLibrary_step (JNIEnv *env, jobject obj, jfloat time)
 
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_bloom_NativeLibrary_uninit (JNIEnv *env, jobject obj)
 

Variables

static const char blendFragmentShaderSource []
 
static const char blurHorizontalFragmentShaderSource []
 
static const char blurVerticalFragmentShaderSource []
 
static const char getLuminanceImageFragmentShaderSource []
 
static const char renderSceneFragmentShaderSource []
 
static const char renderSceneVertexShaderSource []
 
static const char renderTextureVertexShaderSource []
 
Matrix cameraLookAtMatrix
 
Vec3f cameraPosition
 
Matrix cameraProjectionMatrix
 
Matrix cameraViewMatrix
 
Matrix cameraViewProjectionMatrix
 
const float farPlane = 100.f
 
Vec3f lightPosition = {0.0f, 0.0f, 10.0f}
 
const Vec3f lookAtPoint = {0.0f, 0.0f, 0.0f}
 
int max_window_dimension = 0
 
int min_window_dimension = 0
 
const float nearPlane = 0.01f
 
const Vec3f upVector = {0.0f, 1.0f, 0.0f}
 
int windowHeight = 0
 
int windowWidth = 0
 
int lastNumberOfIterations = 0
 
GLfloatcubeCoordinates = NULL
 
GLfloatcubeLocations = NULL
 
GLfloatcubeNormals = NULL
 
int nOfCubeCoordinates = 0
 
int nOfCubeLocations = 0
 
int nOfCubeNormals = 0
 
BlendingProgramLocations blendingProgramLocations
 
ProgramAndShadersIds blendingProgramShaderObjects
 
BlurringProgramLocations blurringHorizontalProgramLocations
 
ProgramAndShadersIds blurringHorizontalProgramShaderObjects
 
BlurringProgramLocations blurringVerticalProgramLocations
 
ProgramAndShadersIds blurringVerticalProgramShaderObjects
 
ProgramAndShadersIds getLuminanceImageProgramShaderObjects
 
SceneRenderingProgramLocations sceneRenderingProgramLocations
 
ProgramAndShadersIds sceneRenderingProgramShaderObjects
 
BlurringObjects blurringObjects
 
GetLuminanceImageBloomObjects getLuminanceImageBloomObjects
 
SceneRenderingObjects sceneRenderingObjects
 
StrongerBlurObjects strongerBlurObjects
 

Detailed Description

The application shows a bloom effect implementation. It draws cubes arranged in a two-dimensional 5x5 array, from which only the diagonal ones are bloomed. The intensity of the bloom effect changes from very weak, where each cube affected by the effect looks exactly as the normal ones, to very strong, when bloomed cubes make up an X shape.

The bloom effect is implemented as follows:

  1. A scene (5x5 array of cubes: cubes on diagonals are white, others are blue) is drawn to a render target.
  2. Elements that should be bloomed (the brighter ones, in this case cubes placed on diagonals) are drawn into downscaled texture object (where the rest of the scene is black).
  3. The result texture from step 2 is horizontally blurred - the outcome is stored in a texture which is then used for the vertical blur. This step can be repeated as described later (*).
  4. Both the texture in which the vertically & horizontally blurred image has been stored (result of step 3), and the texture from step 1 are blended (horizontally & vertically) and drawn into the back buffer.

(*) The blend effect is not constant during the rendering process: it changes from very weak to very strong. This is achieved by repeating step 3 a varying amount of times (depending on the required intensity of the effect) - the only difference is that for the n-th iteration the generated result of (n-th - 1) is taken as a source for the horizontal blur. To make the bloom effect more smooth, we also use continuous sampling of the textures. The results of the last two iterations from step 3 are used for the final combination pass. The colours of those two textures are mixed together with an appropriate factor value. (for more details please see the mix() function description in the OpenGL ES Shading Language documentation).

Besides the bloom effect, the application also shows:

  • matrix calculations (e.g. used for perspective view),
  • instanced drawing (each cube drawn on a screen is an instance of the same object),
  • lighting (the model is lit by a directional light),
  • rendering into a texture.

Definition in file Native.cpp.

Macro Definition Documentation

#define BLUR_EFFECT_DECREASE   (-1)

Indicates negative sign, used in blur calculations when the effect should be decreased.

Definition at line 96 of file Native.cpp.

#define BLUR_EFFECT_INCREASE   (1)

Indicates positive sign, used in blur calculations when the effect should be increased.

Definition at line 94 of file Native.cpp.

#define BLUR_MIX_FACTOR_STEP_VALUE   (0.05f)

Step which is used for changing mix factor values (used while mixing colour textures to get a continuous sampling effect).

Definition at line 92 of file Native.cpp.

#define BLUR_RADIUS   (3)

Radius of the blur effect (in pixels).

Definition at line 81 of file Native.cpp.

#define CUBE_SCALAR   (0.8f)

Cube size scalar.

Definition at line 77 of file Native.cpp.

#define HORIZONTAL_POSITION_CAMERA_DEPTH_LOCATION   (15.0f)

Camera depth location for horizontal position (should be used when the window width is greater than window height).

Definition at line 118 of file Native.cpp.

#define MAX_NUMBER_OF_BLUR_PASSES   (10)

Maximum number of blur passes.

Definition at line 87 of file Native.cpp.

#define MIN_NUMBER_OF_BLUR_PASSES   (2)

Minimum number of blur passes.

Definition at line 89 of file Native.cpp.

#define NUMBER_OF_COMPONENTS_PER_VERTEX   (3)

Number of vertex coordinates. Each vertex is described in 3D space with 3 values: xyz.

Definition at line 84 of file Native.cpp.

#define NUMBER_OF_CUBES   (25)

Number of cubes drawn on screen.

Definition at line 72 of file Native.cpp.

#define TEXTURE_UNIT_BLOOM_SOURCE_TEXTURE   (1)

Texture unit which a texture with bloomed elements will be bound to.

Definition at line 106 of file Native.cpp.

#define TEXTURE_UNIT_BLURRED_TEXTURE   (3)

Texture unit which a texture with weaker blur effect will be bound to.

Definition at line 111 of file Native.cpp.

#define TEXTURE_UNIT_COLOR_TEXTURE   (0)

Texture unit which a color texture will be bound to.

Definition at line 102 of file Native.cpp.

#define TEXTURE_UNIT_HORIZONTAL_BLUR_TEXTURE   (2)

Texture unit which a texture with horizontally blurred elements will be bound to.

Definition at line 109 of file Native.cpp.

#define TEXTURE_UNIT_STRONGER_BLUR_TEXTURE   (4)

Texture unit which a texture with stronger blur effect will be bound to.

Definition at line 113 of file Native.cpp.

#define TIME_INTERVAL   (1.0f)

Indicates how much time should it take to switch between number of blur passes.

Definition at line 98 of file Native.cpp.

#define VERTICAL_POSITION_CAMERA_DEPTH_LOCATION   (20.0f)

Camera depth location for vertical position (should be used when the window height is greater than window width).

Definition at line 122 of file Native.cpp.

#define WINDOW_RESOLUTION_DIVISOR   (2)

Window resolution divisor will be used for downscaling the texture used for blurring.

Definition at line 68 of file Native.cpp.

Function Documentation

static void deleteBlurringObjects ( BlurringObjects objectIdsStoragePtr)
static

Delete objects which were generated for blurring purposes. According to the OpenGL ES specification, objects will not be deleted if bound. It is the user's responsibility to call glBindBuffer(), glBindFramebuffer() and glBindTexture() with default object ids (id = 0) at some point.

Parameters
objectIdsStoragePtrObjects described by the structure will be deleted by the function. Cannot be NULL.

Definition at line 613 of file Native.cpp.

static void deleteGetLuminanceImageBloomObjects ( GetLuminanceImageBloomObjects objectIdsStoragePtr)
static

Delete objects which were generated for getting downscaled luminance image. According to the OpenGL ES specification, objects will not be deleted if bound. It is the user's responsibility to call glBindFramebuffer() and glBindTexture() with default object ids (id = 0) at some point.

Parameters
objectIdsStoragePtrObjects described by the structure will be deleted by the function. Cannot be NULL.

Definition at line 634 of file Native.cpp.

static void deleteProgramShaderObjects ( ProgramAndShadersIds objectsToBeDeletedPtr)
static

Delete program and shader objects. According to the OpenGL ES specification, program object will not be deleted if it is active. It is the user's responsibility to call glUseProgram(0) at some point.

Parameters
objectsToBeDeletedPtrObjects described by the structure will be deleted by the function. Cannot be NULL.

Definition at line 652 of file Native.cpp.

static void deleteSceneRenderingObjects ( SceneRenderingObjects objectIdsStoragePtr)
static

Delete objects which were generated for scene rendering purposes. According to the OpenGL ES specification, objects will not be deleted if bound. It is the user's responsibility to call glBindBuffer(), glBindFramebuffer() and glBindTexture() with default object ids (id = 0) at some point.

Parameters
objectIdsStoragePtrObjects described by the structure will be deleted by the function. Cannot be NULL.

Definition at line 673 of file Native.cpp.

static void deleteStrongerBlurObjects ( StrongerBlurObjects objectIdsStoragePtr)
static

Delete objects which were generated for performing the stronger blur effect on downscaled textures. According to the OpenGL ES specification, objects will not be deleted if bound. It is the user's responsibility to call glBindFramebuffer() and glBindTexture() with default object ids (id = 0) at some point.

Parameters
objectIdsStoragePtrObjects described by the structure will be deleted by the function. Cannot be NULL.

Definition at line 700 of file Native.cpp.

static void generateAndPrepareObjectsUsedForBlurring ( GLuint framebufferObjectIdPtr,
GLuint horizontalTextureObjectIdPtr,
GLuint verticalTextureObjectIdPtr 
)
static

Generate texture and framebuffer objects, configure texture parameters. Finally, reset GL_TEXTURE_2D texture binding to 0 for active texture unit. Objects will be used for applying blur effect.

Parameters
framebufferObjectIdPtrDeref will be used to store generated framebuffer object ID. Cannot be NULL.
horizontalTextureObjectIdPtrDeref will be used to store generated horizontal texture object ID. Cannot be NULL.
verticalTextureObjectIdPtrDeref will be used to store generated vertical texture object ID. Cannot be NULL.

Definition at line 722 of file Native.cpp.

static void generateAndPrepareObjectsUsedForSceneRendering ( GLuint framebufferObjectIdPtr,
GLuint originalTextureObjectIdPtr,
GLuint depthToIdPtr 
)
static

Generate texture and framebuffer objects and configure texture parameters accordingly. Finally, reset GL_FRAEMBUFFER and GL_TEXTURE_2D bindings to 0. Objects will be used for rendering the scene into texture.

Parameters
framebufferObjectIdPtrDeref will be used to store generated framebuffer object ID. Cannot be NULL.
originalTextureObjectIdPtrDeref will be used to store generated original texture object ID. Cannot be NULL.
depthToIdPtrDeref will be used to store generated depth texture object ID. Cannot be NULL.

Definition at line 802 of file Native.cpp.

static void generateDownscaledObjects ( GLuint fboIdPtr,
GLuint toIdPtr 
)
static

Generate texture and framebuffer objects and configure texture parameters accordingly. Finally, reset GL_FRAEMBUFFER and GL_TEXTURE_2D bindings to 0. Texture size is equal to window resolution / WINDOW_RESOLUTION_DIVISOR.

Parameters
fboIdPtrDeref will be used to store generated framebuffer object ID. Cannot be NULL.
toIdPtrDeref will be used to store generated texture object ID. Cannot be NULL.

Definition at line 903 of file Native.cpp.

static GLfloat* getCubeLocations ( GLint  numberOfColumns,
GLint  numberOfRows,
GLfloat  cubeScalar,
GLfloat  distanceBetweenCubes,
GLint *  numberOfCubeLocationCoordinatesPtr 
)
static

Calculate the world space locations of all the cubes that we will be rendering. The cubes are arranged in a 2D array consisting of numberOfColumns columns and numberOfRows rows with the requested space between cubes. It is the user's responsibility to free allocated memory.

Parameters
numberOfColumnsNumber of columns that cubes will be placed in.
numberOfRowsNumber of rows that cubes will be placed in.
cubeScalarCube size scalar.
distanceBetweenCubesDistance between cubes.
numberOfCubeLocationCoordinatesPtrDeref will be used to store number of generated cubes. Cannot be NULL.
Returns
Pointer to calculated cube positions if successful, NULL otherwise.

Definition at line 968 of file Native.cpp.

static void getLocationsForBlendingProgram ( GLuint  programObjectId,
BlendingProgramLocations locationsStoragePtr 
)
static

Retrieve the locations of uniforms for the program object responsible for applying the blend effect. Can be called only if programObjectId is currently active.

Parameters
programObjectIdA valid program object ID. Indicates the program object for which locations are queried.
locationsStoragePtrDeref will be used to store retrieved info. Cannot be NULL.

Definition at line 1017 of file Native.cpp.

static void getLocationsForBlurringProgram ( GLuint  programObjectId,
BlurringProgramLocations locationsStoragePtr 
)
static

Retrieve the locations of uniforms for the program object responsible for applying the blur effect. Can be called only if programObjectId is currently active.

Parameters
programObjectIdA valid program object ID. Indicates the program object for which locations are queried.
locationsStoragePtrDeref will be used to store retrieved info. Cannot be NULL.

Definition at line 1041 of file Native.cpp.

static void getLocationsForSceneRenderingProgram ( GLuint  programObjectId,
SceneRenderingProgramLocations locationsStoragePtr 
)
static

Retrieve the locations of attributes and uniforms for the program object responsible for scene rendering. Can be called only if programObjectId is currently active.

Parameters
programObjectIdA valid program object ID. Indicates the program object for which locations are queried.
locationsStoragePtrDeref will be used to store retrieved info. Cannot be NULL.

Definition at line 1061 of file Native.cpp.

static void initializeProgramObject ( ProgramAndShadersIds objectIdsPtr,
const char *  fragmentShaderSource,
const char *  vertexShaderSource 
)
static

Create and compile shader objects. If successful, they are attached to the program object, which is then linked.

Parameters
objectIdsPtrDeref where generated program and shader objects IDs will be stored. Cannot be NULL.
fragmentShaderSourceFragment shader source code. Cannot be NULL.
vertexShaderSourceVertex shader source code. Cannot be NULL.

Definition at line 1126 of file Native.cpp.

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

Definition at line 1765 of file Native.cpp.

JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_bloom_NativeLibrary_step ( JNIEnv *  env,
jobject  obj,
jfloat  time 
)

Definition at line 1778 of file Native.cpp.

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

Definition at line 1771 of file Native.cpp.

static void renderDowscaledLuminanceTexture ( )
static

Definition at line 1155 of file Native.cpp.

void renderFrame ( float  time)

Render one frame.

Parameters
timeTime passed from the beginning of the rendering to the current frame render request (in seconds).

Definition at line 1529 of file Native.cpp.

static void renderSceneColourTexture ( )
static

Definition at line 1178 of file Native.cpp.

static void setUniformValuesForSceneRenderingProgram ( const SceneRenderingProgramLocations locationsPtr,
Matrix  mvMatrix,
Matrix  mvpMatrix,
Vec3f  cameraPosition,
Vec3f  lightPosition 
)
static

Configure the scene rendering program's uniforms.

Parameters
locationsPtrPointer to structure object where uniform locations are stored. Cannot be NULL.
mvMatrixModel-View matrix.
mvpMatrixModel-View-Projection matrix.
cameraPositionCamera (eye) position in space.
lightPositionLight position in space.

Definition at line 1220 of file Native.cpp.

void setupGraphics ( int  width,
int  height 
)

Setup the environment: create and prepare objects for rendering purposes.

Parameters
widthWindow resolution: width.
heightWindow resolution: height.
Returns
True if successful, false otherwise.

Definition at line 1274 of file Native.cpp.

static void uninit ( )

Delete created objects and free allocated memory.

Definition at line 1706 of file Native.cpp.

Variable Documentation

const char blendFragmentShaderSource[]
static
Initial value:
= "#version 300 es\n"
"precision mediump float;\n"
"/* UNIFORMS */\n"
"/** Factor which will be used for mixing higher and lower blur effect texture colours. */\n"
"uniform float mix_factor;\n"
"/** Texture storing colour data (with all the cubes). */\n"
"uniform sampler2D original_texture;\n"
"/** Texture in which (n+1) blur operations have been applied to the input texture. */\n"
"uniform sampler2D stronger_blur_texture;\n"
"/** Texture in which (n) blur operations have been applied to the input texture. */\n"
"uniform sampler2D weaker_blur_texture;\n"
"/* INPUTS */\n"
"/** Texture coordinates. */\n"
"in vec2 texture_coordinates;\n"
"/* OUTPUTS */\n"
"/** Fragment colour to be returned. */\n"
"out vec4 color;\n"
"void main()\n"
"{\n"
" vec4 stronger_blur_texture_color = texture(stronger_blur_texture, texture_coordinates);\n"
" vec4 weaker_blur_texture_color = texture(weaker_blur_texture, texture_coordinates);\n"
" vec4 mixed_blur_color = mix(weaker_blur_texture_color, stronger_blur_texture_color, mix_factor);\n"
" vec4 original_color = texture(original_texture, texture_coordinates);\n"
" /* Return blended colour. */\n"
" color = original_color + mixed_blur_color;\n"
"}\n"

Definition at line 295 of file Native.cpp.

BlendingProgramLocations blendingProgramLocations

Definition at line 589 of file Native.cpp.

ProgramAndShadersIds blendingProgramShaderObjects

Definition at line 590 of file Native.cpp.

const char blurHorizontalFragmentShaderSource[]
static

Definition at line 323 of file Native.cpp.

BlurringProgramLocations blurringHorizontalProgramLocations

Definition at line 591 of file Native.cpp.

ProgramAndShadersIds blurringHorizontalProgramShaderObjects

Definition at line 592 of file Native.cpp.

BlurringObjects blurringObjects

Definition at line 600 of file Native.cpp.

BlurringProgramLocations blurringVerticalProgramLocations

Definition at line 593 of file Native.cpp.

ProgramAndShadersIds blurringVerticalProgramShaderObjects

Definition at line 594 of file Native.cpp.

const char blurVerticalFragmentShaderSource[]
static

Definition at line 359 of file Native.cpp.

Matrix cameraLookAtMatrix

Definition at line 562 of file Native.cpp.

Vec3f cameraPosition

Definition at line 563 of file Native.cpp.

Matrix cameraProjectionMatrix

Definition at line 564 of file Native.cpp.

Matrix cameraViewMatrix

Definition at line 565 of file Native.cpp.

Matrix cameraViewProjectionMatrix

Definition at line 566 of file Native.cpp.

GLfloat* cubeCoordinates = NULL

Definition at line 581 of file Native.cpp.

GLfloat* cubeLocations = NULL

Definition at line 582 of file Native.cpp.

GLfloat* cubeNormals = NULL

Definition at line 583 of file Native.cpp.

const float farPlane = 100.f

Definition at line 567 of file Native.cpp.

GetLuminanceImageBloomObjects getLuminanceImageBloomObjects

Definition at line 601 of file Native.cpp.

const char getLuminanceImageFragmentShaderSource[]
static
Initial value:
= "#version 300 es\n"
"precision highp float;\n"
"/* UNIFORMS */\n"
"uniform sampler2D texture_sampler;\n"
"/* INPUTS */\n"
"in vec2 texture_coordinates;\n"
"/* OUTPUTS */\n"
"out vec4 scene_color;\n"
"#define MIN_LUMINANCE (0.9)\n"
"void main()\n"
"{\n"
" vec4 sample_color = texture(texture_sampler, texture_coordinates);\n"
" float luminance = 0.2125 * sample_color.x +\n"
" 0.7154 * sample_color.y +\n"
" 0.0721 * sample_color.z;\n"
" if (luminance > MIN_LUMINANCE)\n"
" {\n"
" scene_color = sample_color;\n"
" }\n"
" else\n"
" {\n"
" scene_color = vec4(0.0);\n"
" }\n"
"}"

Definition at line 395 of file Native.cpp.

ProgramAndShadersIds getLuminanceImageProgramShaderObjects

Definition at line 595 of file Native.cpp.

int lastNumberOfIterations = 0

Definition at line 578 of file Native.cpp.

Vec3f lightPosition = {0.0f, 0.0f, 10.0f}

Definition at line 568 of file Native.cpp.

const Vec3f lookAtPoint = {0.0f, 0.0f, 0.0f}

Definition at line 569 of file Native.cpp.

int max_window_dimension = 0

Definition at line 570 of file Native.cpp.

int min_window_dimension = 0

Definition at line 571 of file Native.cpp.

const float nearPlane = 0.01f

Definition at line 572 of file Native.cpp.

int nOfCubeCoordinates = 0

Definition at line 584 of file Native.cpp.

int nOfCubeLocations = 0

Definition at line 585 of file Native.cpp.

int nOfCubeNormals = 0

Definition at line 586 of file Native.cpp.

const char renderSceneFragmentShaderSource[]
static

Definition at line 421 of file Native.cpp.

const char renderSceneVertexShaderSource[]
static

Definition at line 485 of file Native.cpp.

const char renderTextureVertexShaderSource[]
static
Initial value:
= "#version 300 es\n"
"precision mediump float;\n"
"/** GL_TRIANGLE_FAN-type quad vertex data. */\n"
"const vec4 vertex_positions[4] = vec4[4](vec4( 1.0, -1.0, 0.0, 1.0),\n"
" vec4(-1.0, -1.0, 0.0, 1.0),\n"
" vec4(-1.0, 1.0, 0.0, 1.0),\n"
" vec4( 1.0, 1.0, 0.0, 1.0) );\n"
"/** Texture UVs. */\n"
"const vec2 texture_uv[4] = vec2[4](vec2(1.0, 0.0),\n"
" vec2(0.0, 0.0),\n"
" vec2(0.0, 1.0),\n"
" vec2(1.0, 1.0) );\n"
"/* OUTPUTS */\n"
"/** Texture coordinates. */\n"
"out vec2 texture_coordinates;\n"
"void main()\n"
"{\n"
" /* Return vertex coordinates. */\n"
" gl_Position = vertex_positions[gl_VertexID];\n"
" /* Pass texture coordinated to fragment shader. */\n"
" texture_coordinates = texture_uv[gl_VertexID];\n"
"}\n"

Definition at line 537 of file Native.cpp.

SceneRenderingObjects sceneRenderingObjects

Definition at line 602 of file Native.cpp.

SceneRenderingProgramLocations sceneRenderingProgramLocations

Definition at line 596 of file Native.cpp.

ProgramAndShadersIds sceneRenderingProgramShaderObjects

Definition at line 597 of file Native.cpp.

StrongerBlurObjects strongerBlurObjects

Definition at line 603 of file Native.cpp.

const Vec3f upVector = {0.0f, 1.0f, 0.0f}

Definition at line 573 of file Native.cpp.

int windowHeight = 0

Definition at line 574 of file Native.cpp.

int windowWidth = 0

Definition at line 575 of file Native.cpp.