48 #include <android/log.h>
64 using namespace MaliSDK;
67 const string resourceDirectory =
"/data/data/com.arm.malideveloper.openglessdk.instancedTessellation/files/";
98 const float torusRadius = 1.0f;
100 const float circleRadius = 0.4f;
113 ASSERT(
solidTorus != NULL,
"Could not instantiate InstancedSolidTorus class.");
146 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_instancedTessellation_NativeLibrary_step(JNIEnv *, jobject)
float projectionMatrix[16]
void setProjectionMatrix(MaliSDK::Matrix *projectionMatrix)
Pass the correctly defined projection matrix to the program related to the torus model.
const string resourceDirectory
GLint GLsizei GLsizei height
Functions for manipulating matrices.
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_instancedTessellation_NativeLibrary_init(JNIEnv *, jobject, jint width, jint height)
void matrixPerspective(float *matrix, float fieldOfView, float aspectRatio, float zNear, float zFar)
Create a perspective projection matrix and store the results in the first parameter.
Class derived from the Torus abstract class. It manages drawing of a rotating wireframed unicolor tor...
void uninit()
Delete created objects and free allocated memory.
static void setResourceDirectory(std::string requiredResourceDirectory)
Set the resource directory for all tori.
Class derived form Torus abstract class. It manages drawing of a rotating solid torus, built from separate patches. Each patch is modelled as a Bezier surface approximating surface of a perfect torus. To satisfy the C1 continuity between neighbour patches, the number of circles creating the torus and also the number of points in each circle is restricted to 12. It allows us to divide both circles of torus ("big" and "small") into 4 quadrants and approximate each of it using bicubic Bezier curves. Control mesh vertices has to be distored, so the derivatives on the patch edges are equal and resulting image is round. That is why we cannot use the regular way to determine control points. The patches are in fact very dense square-shaped meshes, used as input attributes by vertex shader. The shader changes their shape on the basis of the distorted control mesh and places them next to each other, forming a round torus. The class, apart from inherited components, manages:
Abstract class that draws torus on the screen. It stores generic data describing the drawn torus: ...
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_instancedTessellation_NativeLibrary_uninit(JNIEnv *, jobject)
virtual void draw(float *rotationVector)=0
Draw the torus model.
GLsizei GLsizei GLfloat distance