Rect.cs 779 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // $Id$
  2. using System;
  3. using DataStructures;
  4. using OpenGl;
  5. namespace SceneGraph
  6. {
  7. /// <summary>
  8. /// Scene Graph nodes which draws a 2 dimensional rectangle (without
  9. /// textures, just plain color, filled or not filled)
  10. /// </summary>
  11. public sealed class Rectangle : Node
  12. {
  13. public RectangleF Rect;
  14. public bool Fill;
  15. public Rectangle()
  16. {
  17. }
  18. public void Draw(Gdk.Rectangle cliprect)
  19. {
  20. gl.Disable(gl.TEXTURE_2D);
  21. gl.PolygonMode(gl.FRONT_AND_BACK, Fill ? gl.FILL : gl.LINE);
  22. gl.Begin(gl.QUADS);
  23. gl.Vertex2f(Rect.Left, Rect.Top);
  24. gl.Vertex2f(Rect.Right, Rect.Top);
  25. gl.Vertex2f(Rect.Right, Rect.Bottom);
  26. gl.Vertex2f(Rect.Left, Rect.Bottom);
  27. gl.End();
  28. gl.PolygonMode(gl.FRONT_AND_BACK, gl.FILL);
  29. gl.Enable(gl.TEXTURE_2D);
  30. }
  31. }
  32. }