00001 #region License
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #endregion
00027
00028 using System;
00029 using System.Collections.Generic;
00030 using System.Text;
00031 using System.Diagnostics;
00032 using OpenTK.Graphics;
00033
00034 namespace OpenTK.Platform.Egl
00035 {
00036
00037 class EglWindowInfo : IWindowInfo
00038 {
00039 #region Fields
00040
00041 IntPtr handle;
00042 IntPtr display;
00043 IntPtr surface;
00044 bool disposed;
00045
00046 #endregion
00047
00048 #region Constructiors
00049
00050 public EglWindowInfo(IntPtr handle, IntPtr display)
00051 {
00052 Handle = handle;
00053 Display = display;
00054 }
00055
00056 public EglWindowInfo(IntPtr handle, IntPtr display, IntPtr surface)
00057 {
00058 Handle = handle;
00059 Display = display;
00060 Surface = surface;
00061 }
00062
00063 #endregion
00064
00065 #region Public Members
00066
00067 public IntPtr Handle { get { return handle; } private set { handle = value; } }
00068
00069 public IntPtr Display { get { return display; } private set { display = value; } }
00070
00071 public IntPtr Surface { get { return surface; } private set { surface = value; } }
00072
00073 public void CreateWindowSurface(IntPtr config)
00074 {
00075 Surface = Egl.CreateWindowSurface(Display, config, Handle, null);
00076 int error = Egl.GetError();
00077 if (error != Egl.SUCCESS)
00078 throw new GraphicsContextException(String.Format("[Error] Failed to create EGL window surface, error {0}.", error));
00079 }
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 public void DestroySurface()
00092 {
00093 if (Surface != IntPtr.Zero)
00094 if (!Egl.DestroySurface(Display, Surface))
00095 Debug.Print("[Warning] Failed to destroy {0}:{1}.", Surface.GetType().Name, Surface);
00096 }
00097
00098 #endregion
00099
00100 #region IDisposable Members
00101
00102 public void Dispose()
00103 {
00104 Dispose(true);
00105 GC.SuppressFinalize(this);
00106 }
00107
00108 void Dispose(bool manual)
00109 {
00110 if (!disposed)
00111 {
00112 if (manual)
00113 {
00114 DestroySurface();
00115 disposed = true;
00116 }
00117 else
00118 {
00119 Debug.Print("[Warning] Failed to destroy {0}:{1}.", this.GetType().Name, Handle);
00120 }
00121 }
00122 }
00123
00124 ~EglWindowInfo()
00125 {
00126 Dispose(false);
00127 }
00128
00129 #endregion
00130 }
00131 }