Code example for GL11

Methods: glColor4f, glDrawArrays, glVertexPointer

0
	public static final void drawTriangleStrip(FloatBuffer vb, float[] color,
			int beginVertex, int endVertex) {
		if (vb == null)
			return; 
		setColor(color);
		gl.glVertexPointer(2, GL10.GL_FLOAT, 0, vb);
		gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, beginVertex, endVertex
				- beginVertex);
	} 
 
	public static final void drawTriangleFan(FloatBuffer vb, float[] color) {
		setColor(color);
		gl.glVertexPointer(2, GL10.GL_FLOAT, 0, vb);
		gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 0, vb.capacity() / 2);
	} 
 
	public static final void drawLines(FloatBuffer vb, float[] color,
			float width, int type, int stride) {
		setColor(color);
		gl.glLineWidth(width);
		gl.glVertexPointer(2, GL10.GL_FLOAT, stride, vb);
		gl.glDrawArrays(type, 0, vb.capacity() / (2 + stride / 8));
	} 
 
	public static final void drawLines(FloatBuffer vb, float[] color,
			float width, int type) {
		drawLines(vb, color, width, type, 0);
	} 
 
	public static final void drawCircle(float pointSize, float[] color, float x,
			float y) {
		push(); 
		translate(x, y);
		float scale = pointSize / CIRCLE_RADIUS;
		scale(scale, scale);
		drawTriangleFan(circleVb, color);
		pop(); 
	} 
 
	protected final float distanceFromCenterSquared(float x, float y) {
		return (x - width / 2) * (x - width / 2) + (y - height / 2)
				* (y - height / 2);
	} 
 
	public final void setBackgroundColor(float[] color) {
		backgroundColor = color;
		initBackgroundColor(); 
	} 
 
	public static final void setColor(float[] color) {
		gl.glColor4f(color[0], color[1], color[2], color[3]);
	} 
 
	protected void initBackgroundColor() { 
		gl.glClearColor(backgroundColor[0], backgroundColor[1],
				backgroundColor[2], backgroundColor[3]);