40 #include <GLES2/gl2.h>
41 #include <GLES2/gl2ext.h>
47 #include <android/log.h>
61 using namespace MaliSDK;
113 GL_CHECK(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
126 GL_CHECK(glAttachShader(programID, vertexShaderID));
127 GL_CHECK(glAttachShader(programID, fragmentShaderID));
135 LOGE(
"Attribute not found at %s:%i\n", __FILE__, __LINE__);
144 LOGD(
"Warning: Attribute not found at %s:%i\n", __FILE__, __LINE__);
155 LOGD(
"Warning: Uniform not found at %s:%i\n", __FILE__, __LINE__);
166 LOGD(
"Warning: Uniform not found at %s:%i\n", __FILE__, __LINE__);
177 EGLint swapBehaviour;
178 if(eglQuerySurface(eglGetCurrentDisplay(), eglGetCurrentSurface(EGL_DRAW), EGL_SWAP_BEHAVIOR, &swapBehaviour) != EGL_TRUE)
180 LOGD(
"Warning: eglQuerySurface() failed at %s:%i\n", __FILE__, __LINE__);
183 LOGI(
"Default values:");
184 LOGI(
"EGL_SWAP_BEHAVIOR = 0x%.4x", (
int)swapBehaviour);
185 switch(swapBehaviour)
187 case (EGL_BUFFER_PRESERVED):
188 LOGI(
" = EGL_BUFFER_PRESERVED");
190 case (EGL_BUFFER_DESTROYED):
191 LOGI(
" = EGL_BUFFER_DESTROYED");
199 if(eglSurfaceAttrib(eglGetCurrentDisplay(), eglGetCurrentSurface(EGL_DRAW), EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED) != EGL_TRUE)
201 LOGD(
"Warning: eglSurfaceAttrib() failed at %s:%i\n", __FILE__, __LINE__);
209 static float angleX = 0.0f;
210 static float angleY = 0.0f;
211 static float angleZ = 0.0f;
213 static bool fullScreen =
false;
214 static bool preserve =
false;
219 fullScreen = !fullScreen;
225 LOGI(
"Scissor off\n");
227 GL_CHECK(glDisable(GL_SCISSOR_TEST))
228 preserve = !preserve;
232 LOGI(
"Preserve on\n");
233 if(eglSurfaceAttrib(eglGetCurrentDisplay(), eglGetCurrentSurface(EGL_DRAW), EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED) != EGL_TRUE)
235 LOGD(
"Warning: eglSurfaceAttrib() failed at %s:%i\n", __FILE__, __LINE__);
241 LOGI(
"Preserve off\n");
242 if(eglSurfaceAttrib(eglGetCurrentDisplay(), eglGetCurrentSurface(EGL_DRAW), EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED) != EGL_TRUE)
244 LOGD(
"Warning: eglSurfaceAttrib() failed at %s:%i\n", __FILE__, __LINE__);
251 LOGI(
"Scissor on\n");
252 GL_CHECK(glEnable(GL_SCISSOR_TEST));
265 GL_CHECK(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
276 if(angleX >= 360) angleX -= 360;
277 if(angleY >= 360) angleY -= 360;
278 if(angleZ >= 360) angleZ -= 360;
323 (JNIEnv *env, jclass jcls)
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_eglpreserve_EGLPreserve_init(JNIEnv *env, jclass jcls, jint width, jint height)
GLfloat cubeColors[numberOfValuesInCubeColorsArray]
Functions for drawing text in OpenGL ES.
GLint GLsizei GLsizei height
Functions for manipulating matrices.
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_eglpreserve_EGLPreserve_step(JNIEnv *env, jclass jcls)
static Matrix createTranslation(float x, float y, float z)
Create and return a translation matrix.
Provides a platform independent high resolution timer.
void clear(void)
Removes the current string from the class.
static Matrix matrixPerspective(float FOV, float ratio, float zNear, float zFar)
Create and return a perspective projection matrix.
float * getAsArray(void)
Get the matrix elements as a column major order array.
static const float cubeVertices[]
static const int textureCharacterHeight
The height (in pixels) of the characters in the text texture.
static const GLubyte cubeIndices[]
void reset()
Resets the timer to 0.0f.
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_eglpreserve_EGLPreserve_uninit(JNIEnv *, jclass)
static const int textureCharacterWidth
The width (in pixels) of the characters in the text texture.
void addString(int xPosition, int yPosition, const char *string, int red, int green, int blue, int alpha)
Add a std::string to be drawn to the screen.
bool setupGraphics(int width, int height)
unsigned int windowHeight
static Matrix createRotationY(float angle)
Create and return a rotation matrix around the y-axis matrix.
static Matrix createRotationZ(float angle)
Create and return a rotation matrix around the z-axis matrix.
string fragmentShaderFilename
string vertexShaderFilename
static void processShader(GLuint *shader, const char *filename, GLint shaderType)
Create shader, load in source, compile, and dump debug as necessary.
bool isTimePassed(float seconds=1.0f)
Tests if 'seconds' seconds have passed since reset() or this method was called.
void draw(void)
Draw the text to the screen.
typedef GLuint(GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count
static Matrix createRotationX(float angle)
Create and return a rotation matrix around the x-axis matrix.