TutorialPartI extends Activity; OpenGLRenderer implements Renderer;

package se.jayway.opengl.tutorial;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import android.opengl.GLU;
import android.opengl.GLSurfaceView.Renderer;

public class OpenGLRenderer implements Renderer {
/*
	public void onDrawFrame(GL10 arg0) {
		// TODO Auto-generated method stub

	}

	public void onSurfaceChanged(GL10 arg0, int arg1, int arg2) {
		// TODO Auto-generated method stub

	}

	public void onSurfaceCreated(GL10 arg0, EGLConfig arg1) {
		// TODO Auto-generated method stub

	}
*/
	/*
	* (non-Javadoc)
	*
	* @see
	* android.opengl.GLSurfaceView.Renderer#onSurfaceCreated(javax.
	* microedition.khronos.opengles.GL10, javax.microedition.khronos.
	* egl.EGLConfig)
	*/
	public void onSurfaceCreated(GL10 gl, EGLConfig config) {
	// Set the background color to black ( rgba ).
	gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // OpenGL docs.
	// Enable Smooth Shading, default not really needed.
	gl.glShadeModel(GL10.GL_SMOOTH);// OpenGL docs.
	// Depth buffer setup.
	gl.glClearDepthf(1.0f);// OpenGL docs.
	// Enables depth testing.
	gl.glEnable(GL10.GL_DEPTH_TEST);// OpenGL docs.
	// The type of depth testing to do.
	gl.glDepthFunc(GL10.GL_LEQUAL);// OpenGL docs.
	// Really nice perspective calculations.
	gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, // OpenGL docs.
	GL10.GL_NICEST);
	}
	/*
	* (non-Javadoc)
	*
	* @see
	* android.opengl.GLSurfaceView.Renderer#onDrawFrame(javax.
	* microedition.khronos.opengles.GL10)
	*/
	public void onDrawFrame(GL10 gl) {
	// Clears the screen and depth buffer.
	gl.glClear(GL10.GL_COLOR_BUFFER_BIT | // OpenGL docs.
	GL10.GL_DEPTH_BUFFER_BIT);
	}
	/*
	* (non-Javadoc)
	*
	* @see
	* android.opengl.GLSurfaceView.Renderer#onSurfaceChanged(javax.
	* microedition.khronos.opengles.GL10, int, int)
	*/
	public void onSurfaceChanged(GL10 gl, int width, int height) {
	// Sets the current view port to the new size.
	gl.glViewport(0, 0, width, height);// OpenGL docs.
	// Select the projection matrix
	gl.glMatrixMode(GL10.GL_PROJECTION);// OpenGL docs.
	// Reset the projection matrix
	gl.glLoadIdentity();// OpenGL docs.
	// Calculate the aspect ratio of the window
	GLU.gluPerspective(gl, 45.0f,
	(float) width / (float) height,
	0.1f, 100.0f);
	// Select the modelview matrix
	gl.glMatrixMode(GL10.GL_MODELVIEW);// OpenGL docs.
	// Reset the modelview matrix
	gl.glLoadIdentity();// OpenGL docs.
	}
	
}
package se.jayway.opengl.tutorial;


import android.opengl.GLSurfaceView;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.Window;
import android.view.WindowManager;

public class TutorialPartI extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       
        /*
        this.requestWindowFeature(Window.FEATURE_NO_TITLE); // (NEW)
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN); // (NEW)
        //*/
        ///
        //*
        GLSurfaceView view = new GLSurfaceView(this);
        view.setRenderer(new OpenGLRenderer());
        setContentView(view);
        //*/
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        //getMenuInflater().inflate(R.menu.activity_tutorial_part_i, menu);
        return true;
    }    

}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值