OpenGL ES SDK for Android ARM Developer Center
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ThreadSync.cpp File Reference
#include <EGL/egl.h>
#include <GLES3/gl3.h>
#include <GLES3/gl3ext.h>
#include <string>
#include <jni.h>
#include <android/log.h>
#include "ThreadSync.h"
#include <pthread.h>
#include <unistd.h>
#include <stdlib.h>
#include "Text.h"
#include "Shader.h"
#include "Matrix.h"

Go to the source code of this file.

Functions

void touchStart (int x, int y)
 
void touchMove (int x, int y)
 
void touchEnd (int x, int y)
 
void animateTexture ()
 
void initTexture (void)
 
static voidworkingFunction (void *arg)
 
void createTextureThread (void)
 
bool setupGraphics (int width, int height)
 
void renderFrame (void)
 
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_threadsync_ThreadSync_init (JNIEnv *env, jclass jcls, jint width, jint height)
 
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_threadsync_ThreadSync_step (JNIEnv *env, jclass jcls)
 
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_threadsync_ThreadSync_uninit (JNIEnv *, jclass)
 
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_threadsync_ThreadSync_touchStart (JNIEnv *env, jclass jcls, jint x, jint y)
 
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_threadsync_ThreadSync_touchMove (JNIEnv *env, jclass jcls, jint x, jint y)
 
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_threadsync_ThreadSync_touchEnd (JNIEnv *env, jclass jcls, jint x, jint y)
 

Variables

static bool useFence = true
 A sample which illustrates the use of sync objects to synchronise the use of shared objects between multiple contexts in multiple threads. More...
 
string resourceDirectory = "/data/data/com.arm.malideveloper.openglessdk.threadsync/"
 
string vertexShaderFilename = "ThreadSync_cube.vert"
 
string fragmentShaderFilename = "ThreadSync_cube.frag"
 
GLuint vertexShaderID = 0
 
GLuint fragmentShaderID = 0
 
GLuint programID = 0
 
GLint iLocPosition = -1
 
GLint iLocTextureMix = -1
 
GLint iLocTexture = -1
 
GLint iLocFillColor = -1
 
GLint iLocTexCoord = -1
 
GLint iLocProjection = -1
 
GLint iLocModelview = -1
 
static float angleX = 0
 
static float angleY = 45
 
static float angleZ = 45
 
Matrix rotationX
 
Matrix rotationY
 
Matrix rotationZ
 
Matrix translation
 
Matrix modelView
 
Matrix projection
 
GLuint iCubeTex = 0
 
int windowWidth = -1
 
int windowHeight = -1
 
Texttext
 
static string baseString = "Thread Synchronisation Example. "
 
static string textString = ""
 
EGLContext mainContext = NULL
 
EGLContext mainDisplay = NULL
 
EGLSurface pBufferSurface = NULL
 
EGLContext pBufferContext = NULL
 
pthread_t secondThread
 
bool exitThread = false
 
GLsync secondThreadSyncObj = NULL
 
GLsync mainThreadSyncObj = NULL
 
GLuint64 timeout = GL_TIMEOUT_IGNORED
 
unsigned char * textureData = NULL
 
int swapStripes = -1
 
int texWidth = 512
 
int texHeight = 512
 
unsigned char bakedColours []
 
static bool touchStarted = false
 

Function Documentation

void animateTexture ( )

Definition at line 159 of file ThreadSync.cpp.

void createTextureThread ( void  )

Definition at line 363 of file ThreadSync.cpp.

void initTexture ( void  )

Definition at line 241 of file ThreadSync.cpp.

JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_threadsync_ThreadSync_init ( JNIEnv *  env,
jclass  jcls,
jint  width,
jint  height 
)

Definition at line 639 of file ThreadSync.cpp.

JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_threadsync_ThreadSync_step ( JNIEnv *  env,
jclass  jcls 
)

Definition at line 649 of file ThreadSync.cpp.

JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_threadsync_ThreadSync_touchEnd ( JNIEnv *  env,
jclass  jcls,
jint  x,
jint  y 
)

Definition at line 682 of file ThreadSync.cpp.

JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_threadsync_ThreadSync_touchMove ( JNIEnv *  env,
jclass  jcls,
jint  x,
jint  y 
)

Definition at line 676 of file ThreadSync.cpp.

JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_threadsync_ThreadSync_touchStart ( JNIEnv *  env,
jclass  jcls,
jint  x,
jint  y 
)

Definition at line 670 of file ThreadSync.cpp.

JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_threadsync_ThreadSync_uninit ( JNIEnv *  ,
jclass   
)

Definition at line 655 of file ThreadSync.cpp.

void renderFrame ( void  )

Definition at line 529 of file ThreadSync.cpp.

bool setupGraphics ( int  width,
int  height 
)

Definition at line 370 of file ThreadSync.cpp.

void touchEnd ( int  x,
int  y 
)

Definition at line 136 of file ThreadSync.cpp.

void touchMove ( int  x,
int  y 
)

Definition at line 131 of file ThreadSync.cpp.

void touchStart ( int  x,
int  y 
)

Definition at line 125 of file ThreadSync.cpp.

static void* workingFunction ( void arg)
static

Definition at line 272 of file ThreadSync.cpp.

Variable Documentation

float angleX = 0
static

Definition at line 72 of file ThreadSync.cpp.

float angleY = 45
static

Definition at line 73 of file ThreadSync.cpp.

float angleZ = 45
static

Definition at line 74 of file ThreadSync.cpp.

unsigned char bakedColours[]
Initial value:
=
{
255, 0, 0, 255,
0, 255, 0, 255,
255, 255, 0, 255,
0, 255, 255, 255,
}

Definition at line 114 of file ThreadSync.cpp.

string baseString = "Thread Synchronisation Example. "
static

Definition at line 90 of file ThreadSync.cpp.

bool exitThread = false

Definition at line 101 of file ThreadSync.cpp.

string fragmentShaderFilename = "ThreadSync_cube.frag"

Definition at line 57 of file ThreadSync.cpp.

GLuint fragmentShaderID = 0

Definition at line 61 of file ThreadSync.cpp.

GLuint iCubeTex = 0

Definition at line 83 of file ThreadSync.cpp.

GLint iLocFillColor = -1

Definition at line 66 of file ThreadSync.cpp.

GLint iLocModelview = -1

Definition at line 69 of file ThreadSync.cpp.

GLint iLocPosition = -1

Definition at line 63 of file ThreadSync.cpp.

GLint iLocProjection = -1

Definition at line 68 of file ThreadSync.cpp.

GLint iLocTexCoord = -1

Definition at line 67 of file ThreadSync.cpp.

GLint iLocTexture = -1

Definition at line 65 of file ThreadSync.cpp.

GLint iLocTextureMix = -1

Definition at line 64 of file ThreadSync.cpp.

EGLContext mainContext = NULL

Definition at line 94 of file ThreadSync.cpp.

EGLContext mainDisplay = NULL

Definition at line 95 of file ThreadSync.cpp.

GLsync mainThreadSyncObj = NULL

Definition at line 105 of file ThreadSync.cpp.

Matrix modelView

Definition at line 79 of file ThreadSync.cpp.

EGLContext pBufferContext = NULL

Definition at line 97 of file ThreadSync.cpp.

EGLSurface pBufferSurface = NULL

Definition at line 96 of file ThreadSync.cpp.

GLuint programID = 0

Definition at line 62 of file ThreadSync.cpp.

Matrix projection

Definition at line 80 of file ThreadSync.cpp.

string resourceDirectory = "/data/data/com.arm.malideveloper.openglessdk.threadsync/"

Definition at line 55 of file ThreadSync.cpp.

Matrix rotationX

Definition at line 75 of file ThreadSync.cpp.

Matrix rotationY

Definition at line 76 of file ThreadSync.cpp.

Matrix rotationZ

Definition at line 77 of file ThreadSync.cpp.

pthread_t secondThread

Definition at line 100 of file ThreadSync.cpp.

GLsync secondThreadSyncObj = NULL

Definition at line 104 of file ThreadSync.cpp.

int swapStripes = -1

Definition at line 110 of file ThreadSync.cpp.

int texHeight = 512

Definition at line 112 of file ThreadSync.cpp.

Text* text

Definition at line 89 of file ThreadSync.cpp.

string textString = ""
static

Definition at line 91 of file ThreadSync.cpp.

unsigned char* textureData = NULL

Definition at line 109 of file ThreadSync.cpp.

int texWidth = 512

Definition at line 111 of file ThreadSync.cpp.

GLuint64 timeout = GL_TIMEOUT_IGNORED

Definition at line 106 of file ThreadSync.cpp.

bool touchStarted = false
static

Definition at line 123 of file ThreadSync.cpp.

Matrix translation

Definition at line 78 of file ThreadSync.cpp.

bool useFence = true
static

A sample which illustrates the use of sync objects to synchronise the use of shared objects between multiple contexts in multiple threads.

A cube is rendered in the main application thread using a texture which is updated in a second thread. Each thread has its own rendering context and both contexts share their EGL objects. Sync objects are used to synchronise the access to shared data.

Definition at line 36 of file ThreadSync.cpp.

string vertexShaderFilename = "ThreadSync_cube.vert"

Definition at line 56 of file ThreadSync.cpp.

GLuint vertexShaderID = 0

Definition at line 60 of file ThreadSync.cpp.

int windowHeight = -1

Definition at line 86 of file ThreadSync.cpp.

int windowWidth = -1

Definition at line 85 of file ThreadSync.cpp.