Exemplo n.º 1
0
int main(int argc, char *argv[]) {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA | GLUT_DEPTH);
    glutInitWindowSize(800,800);
    glutInitWindowPosition(10,10);
    glutCreateWindow("Super Ellipsoid");

    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
    glutSpecialFunc(specialKeyboard);
    glutMouseFunc(mouse);
    glutMotionFunc(mouseMotion);
    glutIdleFunc(idle);

    glutCreateMenu(displayMenu);
    glutAddMenuEntry("Increase m",1);
    glutAddMenuEntry("Decrease m",2);
    glutAddMenuEntry("Increase n",3);
    glutAddMenuEntry("Decrease n",4);
    glutAddMenuEntry("Exit",5);
    glutAttachMenu(GLUT_RIGHT_BUTTON);

    installShaders();
    setCamera();

    matrixIdentity(Projection);
    matrixPerspective(Projection,
                      40, 1.0, (GLfloat) 1, 750);

    initValues();
    glClearColor(0.0,0.0,0.0,1.0);

    glutMainLoop();
    return 0;
}
Exemplo n.º 2
0
  int main(int argc, char *argv[]) {
    glutInit(&argc, argv);

    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
    glutInitWindowSize(800,800);
    glutInitWindowPosition(70,70);
    glutCreateWindow("ST HELENS TERRAIN");

    initValues();

    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
    glutMouseFunc(mouse);
    glutMotionFunc(mouseMotion);
    glutIdleFunc(idle);
  
    installShaders();
    setCamera();

//    nearPlane = radius - 1.3,farPlane = radius + 1.3;
    matrixIdentity(Projection);
    nearPlane = 1.3;
    farPlane = 4.0;
    matrixPerspective(Projection,
                      30, 1.0, (GLfloat) nearPlane, farPlane);


    glUniform1f(nearPlaneUniform, nearPlane);
    glUniform1f(farPlaneUniform, farPlane);


    glClearColor(0.1,0.1,0.1,0.0);

    glutMainLoop();

    //freeing the memory
    free(indicesArray);
    free(normalsArray);
    free(verticesArray);

    return 0;
  }
Exemplo n.º 3
0
bool setupGraphics(int width, int height)
{
    LOGI("Hello From the Native Side!! - setup Graphics - start");
    simpleCubeProgram = createProgram(glVertexShader, glFragmentShader);
    if (simpleCubeProgram == 0)
    {
        LOGE ("Could not create program");
        return false;
    }
    vertexLocation = glGetAttribLocation(simpleCubeProgram, "vertexPosition");
    vertexColourLocation = glGetAttribLocation(simpleCubeProgram, "vertexColour");
    projectionLocation = glGetUniformLocation(simpleCubeProgram, "projection");
    modelViewLocation = glGetUniformLocation(simpleCubeProgram, "modelView");
    /* Setup the perspective */
    matrixPerspective(projectionMatrix, 45, (float)width / (float)height, 0.1f, 100);
    glEnable(GL_DEPTH_TEST);
    glViewport(0, 0, width, height);
    LOGI("Hello From the Native Side!! - setup Graphics");
    return true;
}
Exemplo n.º 4
0
JNIEXPORT void JNICALL Java_dugu9sword_esplayer_VideoTextureSurfaceRenderer_nativeDrawTexture(
		JNIEnv* env, jobject obj) {

	glClearColor(1.0f, 1.0f, 1.0f, 0.5f);
	glEnable(GL_DEPTH_TEST);
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

	glViewport(0, 0, width, height);

	glUseProgram(program);
	int textureParamHandle = glGetUniformLocation(program, "texture");
	int textureCoordinateHandle = glGetAttribLocation(program,
			"vTexCoordinate");
	int positionHandle = glGetAttribLocation(program, "vPosition");
	int textureTranformHandle = glGetUniformLocation(program,
			"textureTransform");
	int modelViewMatrixHandle = glGetUniformLocation(program,
				"modelViewMatrix");
	int projectionMatrixHandle = glGetUniformLocation(program,
				"projectionMatrix");

	float projectionMatrix[16];
	float modelViewMatrix[16];
	matrixPerspective(projectionMatrix, 45, (float)width / (float)height, 0.1f, 100);
	matrixIdentityFunction(modelViewMatrix);
    matrixRotateX(modelViewMatrix, ++angle);
    matrixRotateY(modelViewMatrix, ++angle);
	matrixTranslate(modelViewMatrix,0.0f,0.0f,-5.0f);

    glUniformMatrix4fv(projectionMatrixHandle, 1, GL_FALSE,projectionMatrix);
    glUniformMatrix4fv(modelViewMatrixHandle, 1, GL_FALSE, modelViewMatrix);


	glEnableVertexAttribArray(positionHandle);
	glVertexAttribPointer(positionHandle, 3, GL_FLOAT, false, 0, vertices);

	glBindTexture(GL_TEXTURE0, textures[0]);
	glActiveTexture(GL_TEXTURE0);

	glUniform1i(textureParamHandle, 0);
	glEnableVertexAttribArray(textureCoordinateHandle);
	glVertexAttribPointer(textureCoordinateHandle, 3, GL_FLOAT, false, 0,
			textureCoords);

	jclass clazz = env->GetObjectClass(obj);
	jfieldID f_videoTextureTransform = env->GetFieldID(clazz,
			"videoTextureTransform", "[F");
	jfloatArray jfa_videoTextureTransform = (jfloatArray) env->GetObjectField(
			obj, f_videoTextureTransform);
	jfloat* v_videoTextureTransform = env->GetFloatArrayElements(
			jfa_videoTextureTransform, 0);
	glUniformMatrix4fv(textureTranformHandle, 1, false,
			v_videoTextureTransform);
	env->ReleaseFloatArrayElements(jfa_videoTextureTransform,
			v_videoTextureTransform, JNI_ABORT);

//	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
	glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, indicies);
	glDisableVertexAttribArray(positionHandle);
	glDisableVertexAttribArray(textureCoordinateHandle);
}