22 #include <GLES2/gl2.h>
23 #include <GLES2/gl2ext.h>
31 #include <android/log.h>
40 #include "Mathematics.h"
43 using namespace MaliSDK;
99 GL_CHECK(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
103 text->
addString(0, 0,
"Simple RotoZoom Example", 255, 255, 255, 255);
111 GL_CHECK(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureData));
114 GL_CHECK(glGenerateMipmap(GL_TEXTURE_2D));
115 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR));
116 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
117 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT));
118 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT));
128 GL_CHECK(glAttachShader(programID, vertexShaderID));
129 GL_CHECK(glAttachShader(programID, fragmentShaderID));
137 LOGE(
"Attribute not found at %s:%i\n", __FILE__, __LINE__);
146 LOGD(
"Warning: Uniform not found at %s:%i\n", __FILE__, __LINE__);
157 LOGD(
"Warning: Attribute not found at %s:%i\n", __FILE__, __LINE__);
168 LOGD(
"Warning: Uniform not found at %s:%i\n", __FILE__, __LINE__);
180 static float angleZTexture = 0.0f;
181 static float angleZOffset = 0.0f;
182 static float angleZoom = 0.0f;
183 static Vec4f radius = {0.0f, 1.0f, 0.0f, 1.0f};
204 GL_CHECK(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
221 textureMovement = textureMovement * rotateTextureZ;
222 textureMovement = textureMovement * translateTexture;
223 textureMovement = textureMovement *
zoom;
224 textureMovement = textureMovement *
scale;
230 GL_CHECK(glActiveTexture(GL_TEXTURE0));
244 if(angleZTexture >= 360) angleZTexture -= 360;
245 if(angleZTexture < 0) angleZTexture += 360;
247 if(angleZOffset >= 360) angleZOffset -= 360;
248 if(angleZOffset < 0) angleZOffset += 360;
250 if(angleZoom >= 360) angleZoom -= 360;
251 if(angleZoom < 0) angleZoom += 360;
268 (JNIEnv *env, jclass jcls)
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_rotozoom_RotoZoom_step(JNIEnv *env, jclass jcls)
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_rotozoom_RotoZoom_uninit(JNIEnv *, jclass)
static const float quadVertices[]
Functions for drawing text in OpenGL ES.
static Matrix identityMatrix
The identity matrix.
GLint GLsizei GLsizei height
GLenum GLuint GLintptr offset
Functions for manipulating matrices.
static Matrix createTranslation(float x, float y, float z)
Create and return a translation matrix.
static Matrix createScaling(float x, float y, float z)
Create and return a scaling matrix.
string fragmentShaderFilename
float * getAsArray(void)
Get the matrix elements as a column major order array.
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_rotozoom_RotoZoom_init(JNIEnv *env, jclass jcls, jint width, jint height)
const GLint textureHeight
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.
static Vec4f vertexTransform(Vec4f *vector, Matrix *matrix)
Transform a 4D vertex by a matrix.
unsigned char * textureData
static Matrix createRotationZ(float angle)
Create and return a rotation matrix around the z-axis matrix.
static void loadData(const char *filename, unsigned char **textureData)
Load texture data from a file into memory.
float degreesToRadians(float degrees)
Convert an angle in degrees to radians.
Matrix negativeTranslation
static const float quadTextureCoordinates[]
string vertexShaderFilename
bool setupGraphics(int width, int height)
static void processShader(GLuint *shader, const char *filename, GLint shaderType)
Create shader, load in source, compile, and dump debug as necessary.
void draw(void)
Draw the text to the screen.
typedef GLuint(GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count
A 4D floating point vector.
static const GLubyte quadIndices[]