OpenGL ES SDK for Android
ARM Developer Center
|
The application shows the projected lights effect. There is a spot light effect adjusted to display the texture instead of the normal light colour. There is also a shadow map technique used to make the scene more realistic by applying some shadows. More...
#include <jni.h>
#include <android/log.h>
#include <GLES3/gl3.h>
#include "Common.h"
#include "CubeModel.h"
#include "Mathematics.h"
#include "Matrix.h"
#include "PlaneModel.h"
#include "ProjectedLights.h"
#include "Shader.h"
#include "Texture.h"
#include "Timer.h"
#include <cstring>
Go to the source code of this file.
Functions | |
static void | drawCubeAndPlane (bool isCameraPointOfView) |
Draw cube and plane model. More... | |
static void | generateAndPrepareColorTextureObject () |
Generate a colour texture object and fill it with data. More... | |
static void | generateAndPrepareDepthTextureObject () |
Generate a depth texture object, set its properties and bind it to the generated framebuffer object. More... | |
static void | getRenderSceneProgramLocations (GLuint programObjectId, RenderSceneProgramLocations *locationsStoragePtr) |
Retrieve locations for attributes and uniforms used in a program object responsible for rendering a scene. More... | |
static void | initializeProgramObject (ProgramAndShaderObjectIds *objectIdsPtr, const char *fragmentShaderFileName, const char *vertexShaderFileName) |
Create and compile shader objects. If successful, they are attached to the program object, which is then linked. More... | |
static void | initializeViewMatrices () |
Initilize data that will be used to translate vertices into eye- and NDC-space. More... | |
static void | renderFrame () |
Function called to render the new frame into the back buffer. More... | |
static void | setupGeometryData () |
Prepare the geometry data that will be used while rendering the scene. More... | |
static void | setupGraphics (int width, int height) |
Prepare the OpenGLES environment to start the animation. More... | |
static void | uninit () |
Delete created objects and free allocated memory. More... | |
static void | updateSpotLightDirection () |
Calculate the updated direction of the spot light and update the corresponding OpenGLES object settings so that the new spot light direction will be used. More... | |
JNIEXPORT void JNICALL | Java_com_arm_malideveloper_openglessdk_projectedLights_NativeLibrary_init (JNIEnv *env, jobject obj, jint width, jint height) |
JNIEXPORT void JNICALL | Java_com_arm_malideveloper_openglessdk_projectedLights_NativeLibrary_step (JNIEnv *env, jobject obj) |
JNIEXPORT void JNICALL | Java_com_arm_malideveloper_openglessdk_projectedLights_NativeLibrary_uninit (JNIEnv *env, jobject obj) |
The application shows the projected lights effect. There is a spot light effect adjusted to display the texture instead of the normal light colour. There is also a shadow map technique used to make the scene more realistic by applying some shadows.
The projected lights effect is implemented in two basic steps described as follows:
Definition in file Native.cpp.
|
static |
Draw cube and plane model.
isCameraPointOfView | True, if a scene from camera point of view is supposed to be rendered. False in case of rendering a scene from spot light perspective. |
Definition at line 163 of file Native.cpp.
|
static |
Generate a colour texture object and fill it with data.
Definition at line 279 of file Native.cpp.
|
static |
Generate a depth texture object, set its properties and bind it to the generated framebuffer object.
Definition at line 343 of file Native.cpp.
|
static |
Retrieve locations for attributes and uniforms used in a program object responsible for rendering a scene.
programObjectId | ID of a program object for which locations are queried. |
locationsStoragePtr | Pointer to structure object where retrieved locations will be stored. Cannot be NULL. |
Definition at line 400 of file Native.cpp.
|
static |
Create and compile shader objects. If successful, they are attached to the program object, which is then linked.
objectIdsPtr | Deref where generated program and shader objects IDs will be stored. Cannot be NULL. |
fragmentShaderFileName | Name of fragment shader file. Cannot be NULL. |
vertexShaderFileName | Name of vertex shader file. Cannot be NULL. |
Definition at line 455 of file Native.cpp.
|
static |
Initilize data that will be used to translate vertices into eye- and NDC-space.
Definition at line 487 of file Native.cpp.
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_projectedLights_NativeLibrary_init | ( | JNIEnv * | env, |
jobject | obj, | ||
jint | width, | ||
jint | height | ||
) |
Definition at line 993 of file Native.cpp.
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_projectedLights_NativeLibrary_step | ( | JNIEnv * | env, |
jobject | obj | ||
) |
Definition at line 1006 of file Native.cpp.
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_projectedLights_NativeLibrary_uninit | ( | JNIEnv * | env, |
jobject | obj | ||
) |
Definition at line 999 of file Native.cpp.
Function called to render the new frame into the back buffer.
Definition at line 566 of file Native.cpp.
|
static |
Prepare the geometry data that will be used while rendering the scene.
Store data in the buffer objects so that it can be used during draw calls.
Definition at line 646 of file Native.cpp.
Prepare the OpenGLES environment to start the animation.
width | Window width. |
height | Window height. |
Definition at line 702 of file Native.cpp.
|
static |
Delete created objects and free allocated memory.
Definition at line 872 of file Native.cpp.
|
static |
Calculate the updated direction of the spot light and update the corresponding OpenGLES object settings so that the new spot light direction will be used.
Definition at line 935 of file Native.cpp.
CameraViewProperties cameraViewProperties |
Definition at line 147 of file Native.cpp.
GeometryProperties cubeGeometryProperties |
Definition at line 148 of file Native.cpp.
DirectionalLightProperties directionalLightProperties |
Definition at line 149 of file Native.cpp.
SpotLightViewProperites lightViewProperties |
Definition at line 150 of file Native.cpp.
GeometryProperties planeGeometryProperties |
Definition at line 151 of file Native.cpp.
RenderSceneObjects renderSceneObjects |
Definition at line 152 of file Native.cpp.
ProgramAndShaderObjectIds renderSceneProgramAndShadersIds |
Definition at line 153 of file Native.cpp.
RenderSceneProgramLocations renderSceneProgramLocations |
Definition at line 154 of file Native.cpp.
GLsizei shadowMapHeight |
Definition at line 155 of file Native.cpp.
GLsizei shadowMapWidth |
Definition at line 156 of file Native.cpp.
SpotLightProperties spotLightProperties |
Definition at line 157 of file Native.cpp.
Timer timer |
Definition at line 158 of file Native.cpp.
GLsizei windowHeight |
Definition at line 159 of file Native.cpp.
GLsizei windowWidth |
Definition at line 160 of file Native.cpp.