All pastes #900849 Raw Edit

Unnamed

public java v1 · immutable
·published 2008-02-12 06:09 UTC
rendered paste body
public class Renderer implements GLEventListener{	private GLU glu = new GLU();	private LinkedList<Entity> entities = new LinkedList<Entity>();	public Renderer()	{		entities.add(new FloorEntity());		//entities.add(new BlockEntity());	}		public void display(GLAutoDrawable gLDrawable)	{		final GL gl = gLDrawable.getGL();		gl.glLoadIdentity();		glu.gluLookAt(1.0, 1.0, 50.0, //eye position					  0.0, 0.0, 0.0,  //look at					  0.0, 1.0, 0.0); //y-axis is up		gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);				for (Entity e : entities)		{			e.render(gl);		}	}	public void init(GLAutoDrawable gLDrawable)	{		GL gl = gLDrawable.getGL();		gl.glShadeModel(GL.GL_SMOOTH);		gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);				float[] specular = new float[] {1.0f, 1.0f, 1.0f, 1.0f};		gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, specular, 0);				float[] position = new float[] {2.0f, 2.0f, -2.0f, 1.0f};		gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, position, 1);				gl.glEnable(GL.GL_LIGHTING);		gl.glEnable(GL.GL_LIGHT0);	}	public void reshape(GLAutoDrawable gLDrawable, int x, int y, int width, int height)	{		final GL gl = gLDrawable.getGL();		if (height <= 0) { height = 1; } // avoid a divide by zero error!		final float h = (float) width / (float) height;		gl.glViewport(0, 0, width, height);				gl.glMatrixMode(GL.GL_PROJECTION);		gl.glLoadIdentity();		glu.gluPerspective(45.0, h, 1.0, 100.0);				gl.glMatrixMode(GL.GL_MODELVIEW);		gl.glLoadIdentity();		glu.gluLookAt(1.0, 1.0, 50.0,  //eye position				  0.0, 0.0, 0.0,  //look at				  0.0, 1.0, 0.0); //y-axis is up	}}