GLArea.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * $Id$
  3. *
  4. * GtkGL# - OpenGL Graphics Library for the Gtk# Toolkit
  5. *
  6. * Copyright (c) 2002-2004 The Olympum Group, http://www.olympum.com/
  7. * All rights reserved.
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions are met:
  11. *
  12. * - Redistributions of source code must retain the above copyright notice, this
  13. * list of conditions and the following disclaimer.
  14. *
  15. * - Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. *
  19. * - Neither the name of The Olympum Group nor the names of its contributors
  20. * may be used to endorse or promote products derived from this software without
  21. * specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  24. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
  27. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  28. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  29. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  30. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  32. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  33. * DAMAGE.
  34. */
  35. namespace Gtk
  36. {
  37. using System;
  38. using System.Runtime.InteropServices;
  39. using Gdk;
  40. public class GLArea : DrawingArea
  41. {
  42. GLContext context;
  43. public GLArea (int[] attributeList)
  44. {
  45. DoubleBuffered = false;
  46. context = GLContext.CreateContext (attributeList, null, IntPtr.Zero);
  47. }
  48. public GLArea (int[] attributeList, GLArea share)
  49. {
  50. DoubleBuffered = false;
  51. context = GLContext.CreateContext (attributeList,
  52. share != null ? share.context : null, IntPtr.Zero);
  53. }
  54. public bool MakeCurrent ()
  55. {
  56. return context.MakeCurrent (this.GdkWindow.Handle);
  57. }
  58. public void SwapBuffers ()
  59. {
  60. context.SwapBuffers (this.GdkWindow.Handle);
  61. }
  62. }
  63. }