JNIEXPORT jfloatArray JNICALL JNIFUNCTION(arwGetProjectionMatrix(JNIEnv *env, jobject obj)) 
{
	float proj[16];
    
	if (arwGetProjectionMatrix(proj)) return glArrayToJava(env, proj, 16);	
	return NULL;
}
JNIEXPORT void JNICALL JNIFUNCTION_DEMO(demoDrawFrame(JNIEnv* env, jobject obj)) {
	
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

    // Set the projection matrix to that provided by ARToolKit.
	float proj[16];
	arwGetProjectionMatrix(proj);
	glMatrixMode(GL_PROJECTION);
	glLoadMatrixf(proj);
	glMatrixMode(GL_MODELVIEW);
	
	glStateCacheEnableDepthTest();
	glStateCacheEnableLighting();	
	glEnable(GL_LIGHT0);
	
	for (int i = 0; i < NUM_MODELS; i++) {		
		models[i].visible = arwQueryMarkerTransformation(models[i].patternID, models[i].transformationMatrix);		
			
		if (models[i].visible) {					
			glLoadMatrixf(models[i].transformationMatrix);		
			
			glLightfv(GL_LIGHT0, GL_AMBIENT, lightAmbient);
			glLightfv(GL_LIGHT0, GL_DIFFUSE, lightDiffuse);
			glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
			
			glmDrawArrays(models[i].obj, 0);
		}

	}
	
}