void
VertexArrayDrawingRequest::draw(int start, int end)
{
  assert(!vertices.empty());
  assert(texcoords.empty() || int(texcoords.size()/2) == num_vertices());
  assert(colors.empty() || int(colors.size()/4) == num_vertices());

  OpenGLState state;

  glClear(GL_DEPTH_BUFFER_BIT);
  state.disable(GL_DEPTH_TEST);
  state.enable(GL_BLEND);
  state.set_blend_func(blend_sfactor, blend_dfactor);
  
  if (texture)
    {
      state.bind_texture(texture);
    }

  if (!colors.empty())
    {
      state.enable_client_state(GL_COLOR_ARRAY);
      glColorPointer(4, GL_UNSIGNED_BYTE, 0, &*colors.begin());
    }
  else
    {
      state.disable_client_state(GL_COLOR_ARRAY);
      state.color(Color(1.0f, 1.0f, 1.0f));
    }

  if (!texcoords.empty())
    {
      state.enable_client_state(GL_TEXTURE_COORD_ARRAY);
      glTexCoordPointer(2, GL_FLOAT, 0, &*texcoords.begin());
    }
  else
    {
      state.disable_client_state(GL_TEXTURE_COORD_ARRAY);
    }

  // FIXME: Might be worth to not use VertexArrays when we have a pretty small number of vertices
  state.disable_client_state(GL_NORMAL_ARRAY);
  state.enable_client_state(GL_VERTEX_ARRAY);

  glVertexPointer  (3, GL_FLOAT, 0, &*vertices.begin());

  state.activate();

  glPushMatrix();
  glMultMatrixf(modelview.matrix);

  glDrawArrays(mode, start, end);

  glPopMatrix();
}
  void render(unsigned int mask)
  {
#if 0
    Display::push_framebuffer(framebuffer);
    glClear(GL_COLOR_BUFFER_BIT);
    draw_particles();
    Display::pop_framebuffer();

    if (1) {
      OpenGLState state;

      glUseProgram(shader_program.get_handle());    
      shader_program.set_uniform1i("screen",      0);
      shader_program.set_uniform1i("particles",   1);
            
      state.bind_texture(tmp_texture, 0);
      state.bind_texture(framebuffer.get_texture(), 1);
      state.color(Color(1.0f, 1.0f, 1.0f, 1.0f));
      state.activate();

      glBegin(GL_QUADS);
      glTexCoord2f(0,0);
      glVertex2f(0,0);

      glTexCoord2f(800,0);
      glVertex2f(800,0);

      glTexCoord2f(800,600);
      glVertex2f(800, 600);

      glTexCoord2f(0, 600);
      glVertex2f(0,600);
      glEnd();

      glUseProgram(0);
    }
#endif
  }