This commit is contained in:
the_fiddler 2008-04-13 18:44:23 +00:00
parent 44729f595e
commit 510125a0fa

View file

@ -275,7 +275,7 @@ namespace OpenTK
/// proper OpenTK shutdown.</para> /// proper OpenTK shutdown.</para>
/// </remarks> /// </remarks>
public virtual void Exit() public virtual void Exit()
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
//glWindow.DestroyWindow(); //glWindow.DestroyWindow();
//while (glWindow.Exists) //while (glWindow.Exists)
@ -302,7 +302,7 @@ namespace OpenTK
/// </remarks> /// </remarks>
public virtual void ExitAsync() public virtual void ExitAsync()
{ {
//isExiting = true; //isExiting = true;
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
UpdateFrame += CallExitInternal; UpdateFrame += CallExitInternal;
} }
@ -343,10 +343,10 @@ namespace OpenTK
/// </summary> /// </summary>
public IGraphicsContext Context public IGraphicsContext Context
{ {
get get
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
return glContext; return glContext;
} }
} }
@ -372,12 +372,12 @@ namespace OpenTK
public string Title public string Title
{ {
get get
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
return glWindow.Title; return glWindow.Title;
} }
set set
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
glWindow.Title = value; glWindow.Title = value;
} }
@ -443,7 +443,7 @@ namespace OpenTK
/// (while the opengl context still exists), to allow resource cleanup. /// (while the opengl context still exists), to allow resource cleanup.
/// </summary> /// </summary>
public void DestroyWindow() public void DestroyWindow()
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
if (Exists) if (Exists)
glWindow.DestroyWindow(); glWindow.DestroyWindow();
@ -460,7 +460,7 @@ namespace OpenTK
/// </summary> /// </summary>
/// <see cref="public virtual void Run(double update_frequency, double render_frequency)"/> /// <see cref="public virtual void Run(double update_frequency, double render_frequency)"/>
public void Run() public void Run()
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
Run(0.0, 0.0); Run(0.0, 0.0);
} }
@ -471,7 +471,7 @@ namespace OpenTK
/// </summary> /// </summary>
/// <see cref="public virtual void Run(double updateFrequency, double renderFrequency)"/> /// <see cref="public virtual void Run(double updateFrequency, double renderFrequency)"/>
public void Run(double updateFrequency) public void Run(double updateFrequency)
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
Run(updateFrequency, 0.0); Run(updateFrequency, 0.0);
} }
@ -482,7 +482,7 @@ namespace OpenTK
/// <param name="updates_per_second">The frequency of UpdateFrame events.</param> /// <param name="updates_per_second">The frequency of UpdateFrame events.</param>
/// <param name="frames_per_second">The frequency of RenderFrame events.</param> /// <param name="frames_per_second">The frequency of RenderFrame events.</param>
public void Run(double updates_per_second, double frames_per_second) public void Run(double updates_per_second, double frames_per_second)
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
try try
{ {
@ -628,9 +628,9 @@ namespace OpenTK
if (Exists) if (Exists)
{ {
glContext.Dispose(); glContext.Dispose();
glContext = null; glContext = null;
glWindow.DestroyWindow(); glWindow.DestroyWindow();
} }
while (this.Exists) while (this.Exists)
this.ProcessEvents(); this.ProcessEvents();
@ -653,7 +653,7 @@ namespace OpenTK
/// </para> /// </para>
/// </remarks> /// </remarks>
public void ProcessEvents() public void ProcessEvents()
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
if (!isExiting) if (!isExiting)
glWindow.InputDriver.Poll(); glWindow.InputDriver.Poll();
@ -676,7 +676,7 @@ namespace OpenTK
/// </summary> /// </summary>
/// <param name="e"></param> /// <param name="e"></param>
private void OnRenderFrameInternal(RenderFrameEventArgs e) private void OnRenderFrameInternal(RenderFrameEventArgs e)
{ {
if (RenderFrame != null) if (RenderFrame != null)
RenderFrame(this, e); RenderFrame(this, e);
@ -692,7 +692,7 @@ namespace OpenTK
/// The base implementation (base.OnRenderFrame) is empty, there is no need to call it. /// The base implementation (base.OnRenderFrame) is empty, there is no need to call it.
/// </remarks> /// </remarks>
public virtual void OnRenderFrame(RenderFrameEventArgs e) public virtual void OnRenderFrame(RenderFrameEventArgs e)
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
} }
@ -731,7 +731,7 @@ namespace OpenTK
/// The base implementation (base.OnUpdateFrame) is empty, there is no need to call it. /// The base implementation (base.OnUpdateFrame) is empty, there is no need to call it.
/// </remarks> /// </remarks>
public virtual void OnUpdateFrame(UpdateFrameEventArgs e) public virtual void OnUpdateFrame(UpdateFrameEventArgs e)
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
} }
@ -782,7 +782,7 @@ namespace OpenTK
/// </summary> /// </summary>
/// <param name="e">Not used.</param> /// <param name="e">Not used.</param>
public virtual void OnLoad(EventArgs e) public virtual void OnLoad(EventArgs e)
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
} }
@ -815,7 +815,7 @@ namespace OpenTK
/// </summary> /// </summary>
/// <param name="e">Not used.</param> /// <param name="e">Not used.</param>
public virtual void OnUnload(EventArgs e) public virtual void OnUnload(EventArgs e)
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
} }
@ -844,7 +844,7 @@ namespace OpenTK
public KeyboardDevice Keyboard public KeyboardDevice Keyboard
{ {
get get
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
//if (input_driver.Keyboard.Count > 0) //if (input_driver.Keyboard.Count > 0)
// return input_driver.Keyboard[0]; // return input_driver.Keyboard[0];
@ -868,7 +868,7 @@ namespace OpenTK
public MouseDevice Mouse public MouseDevice Mouse
{ {
get get
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
//if (input_driver.Mouse.Count > 0) //if (input_driver.Mouse.Count > 0)
// return input_driver.Mouse[0]; // return input_driver.Mouse[0];
@ -892,12 +892,12 @@ namespace OpenTK
public VSyncMode VSync public VSyncMode VSync
{ {
get get
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
return vsync; return vsync;
} }
set set
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
if (value == VSyncMode.Off) if (value == VSyncMode.Off)
Context.VSync = false; Context.VSync = false;
@ -918,7 +918,7 @@ namespace OpenTK
/// </summary> /// </summary>
/// <remarks>Calling this function is equivalent to calling Context.SwapBuffers()</remarks> /// <remarks>Calling this function is equivalent to calling Context.SwapBuffers()</remarks>
public void SwapBuffers() public void SwapBuffers()
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
this.Context.SwapBuffers(); this.Context.SwapBuffers();
} }
@ -952,12 +952,12 @@ namespace OpenTK
public double TargetRenderPeriod public double TargetRenderPeriod
{ {
get get
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
return target_render_period; return target_render_period;
} }
set set
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
if (value <= 0.005) if (value <= 0.005)
{ {
@ -986,14 +986,14 @@ namespace OpenTK
public double TargetRenderFrequency public double TargetRenderFrequency
{ {
get get
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
if (TargetRenderPeriod == 0.0) if (TargetRenderPeriod == 0.0)
return 0.0; return 0.0;
return 1.0 / TargetRenderPeriod; return 1.0 / TargetRenderPeriod;
} }
set set
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
if (value < 1.0) if (value < 1.0)
{ {
@ -1021,12 +1021,12 @@ namespace OpenTK
public double TargetUpdatePeriod public double TargetUpdatePeriod
{ {
get get
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
return target_update_period; return target_update_period;
} }
set set
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
if (value <= 0.005) if (value <= 0.005)
{ {
@ -1054,14 +1054,14 @@ namespace OpenTK
public double TargetUpdateFrequency public double TargetUpdateFrequency
{ {
get get
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
if (TargetUpdatePeriod == 0.0) if (TargetUpdatePeriod == 0.0)
return 0.0; return 0.0;
return 1.0 / TargetUpdatePeriod; return 1.0 / TargetUpdatePeriod;
} }
set set
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
if (value < 1.0) if (value < 1.0)
{ {
@ -1085,7 +1085,7 @@ namespace OpenTK
public double RenderFrequency public double RenderFrequency
{ {
get get
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
if (render_period == 0.0) if (render_period == 0.0)
return 1.0; return 1.0;
@ -1103,7 +1103,7 @@ namespace OpenTK
public double RenderPeriod public double RenderPeriod
{ {
get get
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
return render_period; return render_period;
} }
@ -1119,7 +1119,7 @@ namespace OpenTK
public double UpdateFrequency public double UpdateFrequency
{ {
get get
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
if (update_period == 0.0) if (update_period == 0.0)
return 1.0; return 1.0;
@ -1137,7 +1137,7 @@ namespace OpenTK
public double UpdatePeriod public double UpdatePeriod
{ {
get get
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
return update_period; return update_period;
} }
@ -1183,7 +1183,7 @@ namespace OpenTK
{ {
get { if (disposed) throw new ObjectDisposedException("GameWindow"); return width; } get { if (disposed) throw new ObjectDisposedException("GameWindow"); return width; }
set set
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
if (value == this.Width) if (value == this.Width)
{ {
@ -1211,7 +1211,7 @@ namespace OpenTK
{ {
get { if (disposed) throw new ObjectDisposedException("GameWindow"); return height; } get { if (disposed) throw new ObjectDisposedException("GameWindow"); return height; }
set set
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
if (value == this.Height) if (value == this.Height)
{ {
@ -1267,7 +1267,7 @@ namespace OpenTK
/// </summary> /// </summary>
/// <param name="e">Contains information about the Resize event.</param> /// <param name="e">Contains information about the Resize event.</param>
protected virtual void OnResize(ResizeEventArgs e) protected virtual void OnResize(ResizeEventArgs e)
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
} }
@ -1344,8 +1344,8 @@ namespace OpenTK
/// Disposes of the GameWindow, releasing all resources consumed by it. /// Disposes of the GameWindow, releasing all resources consumed by it.
/// </summary> /// </summary>
public virtual void Dispose() public virtual void Dispose()
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); if (disposed) throw new ObjectDisposedException("GameWindow");
Dispose(true); Dispose(true);
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
} }
@ -1356,10 +1356,10 @@ namespace OpenTK
{ {
if (manual) if (manual)
{ {
if (glContext != null) if (glContext != null)
{ {
glContext.Dispose(); glContext.Dispose();
glContext = null; glContext = null;
} }
if (glWindow != null) if (glWindow != null)