@Override
	public void render(RenderContext renderContext) {

//		System.out.println(getCurrentMatrix().toString());

		glMatrixMode(GL_PROJECTION);
		glLoadMatrix(toFloatBuffer(renderContext.getCamera().getProjection(getViewport().getSize()).m));

		glMatrixMode(GL_MODELVIEW);
		glLoadMatrix(toFloatBuffer(renderContext.getCamera().getTransform().m));

		polys = 0;

		if (Display.wasResized()) {
			// wasResized = true
		} else {
			// wasResized = false
		}

		setColor(Color.WHITE);

		for (InstancedModel iModel : renderContext.getModelGroup().getIModels()) {

			ModelLoader model = iModel.model;
			List<InstanceAttributes> instanceAttributes = iModel.attributes;

			OpenGLModelData openGLModelData = OpenGLModelData.getOpenGLModelData(model);

			glBindVertexArray(openGLModelData.VAOID);
			glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, openGLModelData.VBOIID);

			if (openGLModelData.normals)
				glEnableClientState(GL_NORMAL_ARRAY);
			if (openGLModelData.colors)
				glEnableClientState(GL_COLOR_ARRAY);
			if (openGLModelData.textures) {
				glEnableClientState(GL_TEXTURE_COORD_ARRAY);
				glBindTexture(GL_TEXTURE_2D, OpenGLTextureData.getOpenGLTextureData(model.texture).id);
			}

			for (InstanceAttributes instanceAttribute : instanceAttributes) {

				glPushMatrix();

				//load the model translation matrix
				float[] m = instanceAttribute.getTransform().m;

				glMultMatrix(toFloatBuffer(m));

				// Draw the vertices
				glDrawElements(GL_TRIANGLES, model.indices.getSize() * model.indices.getStride(),
						GL_UNSIGNED_INT, 0);

				polys += model.indices.getSize();

				glPopMatrix();
			}

			// Put everything back to default (deselect)
			glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
			glBindVertexArray(0);

			glDisableClientState(GL_NORMAL_ARRAY);
			glDisableClientState(GL_COLOR_ARRAY);
			glDisableClientState(GL_TEXTURE_COORD_ARRAY);

			glBindTexture(GL_TEXTURE_2D, 0);
		}

		// System.out.println(polys + " polygons");

		GLErrorHelper.checkError();
	}