Merged GameWindow timing fixes and release documentation from branches/1.0.

This commit is contained in:
the_fiddler 2009-11-17 14:54:30 +00:00
parent 144e6b6947
commit d00cc6bd86
3 changed files with 196 additions and 97 deletions

View file

@ -1,9 +1,120 @@
---------------------------------
OpenTK 1.0 beta-1 -> 1.0 beta-2
---------------------------------
2009-11-17 the_fiddler
* Removed unused code.
* Fixed OnUpdateFrame timing calculation (the previous
implementation could overshoot the target by up to 50%).
Refactored Update-/RenderFrame dispatching into a separate
method.
* Updated release notes for 1.0 beta-2 release.
* Bumped version numbers for 1.0 beta-2 release.
* Added VertexAttribPointer(..., int) and DrawElements(..., int)
overloads.
* Fixed NormalPointer and FogCoordPointer parameters. Added missing
TexCoordPointer(..., int) overload. Added DrawElements(..., int)
overload. Renamed the last parameter from pointer to offset, to
clarify its intent. (Fixes isse [#1386]: "Add overloads for
TexCoordPointer and NormalPointer".)
* Completely disabled CL10, ES10 and ES11 wrappers. They won't be
in the 1.0 release, we can reduce download size a bit.
* Type, Parameter, ParameterCollection and Function classes now
implement IComparable directly (rather than casting to strings
and comparing those). Modified comparison order to place pointer
overloads after reference or array overloads. Fixes issue
[#1098]: "[Bind] Work around VS bug by ensuring pointer
parameters are generated last".
2009-11-16 the_fiddler
* Added strongly-typed tokens for GetActiveUniformBlock, which was
introduced in OpenGL 3.1. Fixes issue [#1216]: "[GL]
GetActiveUniformBlock* methods take ArbUniformBufferObject
parameters".
* Added new OpenGL 3.1 tokens for ARB_texture_rectangle,
ARB_shader_objects and EXT_gpu_shader4. Fixes issue [#1355]:
"TextureRectangle tokens for ActiveUniformType".
* VertexAttribIPointer should take the integer subset
(VertexAttribIPointerType) of VertexAttribPointerType. Fixes
issue [#1166]: "VertexAttribIPointer pointer type parameter".
* Removed invalid BGRA token from VertexAttribPointerType.
* Made unix kernel detection less strict. The program is now
allowed to run even the specific kernel name is unknown. Partly
fixes issue [#1382]: "OpenTK and other Unix OS".
* Added new OpenGL 3.x tokens to GenerateMipmap. Fixes issue
[#1162]: "GL.GenerateMipmap argument".
* Vector3(d).Cross: do not modify 'result' more than once to ensure
that Cross(ref a, ref b, out a) works correctly. Optimized
vector-quaternion transform. Fixes issue [#1373]: "[Math]
optimize Vector transform by Quaternion".
* Changed vector-quaternion transformations to use standard q * v *
q^-1 convention. Fixes issue [#1372]: "[Math] Vector
transformation by Quaternion follows non-standard quaternion math
convention".
* Added support for fractional mouse wheel values. Fixes issue
[#1279]: "Mouse wheel does not seem to work".
* Renamed "Entry" to "Unmanaged Name" to clarify its purpose.
* Make context current on loading thread and be more defensive when
retrieving unmanaged entry points. Resolves issue [#1378]:
"OpenGL Extensions test fails".
* Launch samples on a different thread than the launcher. Samples
may install their own message loops and some operating systems do
not behave correctly with multiple message loops on a single
thread.
* Preserve the sign of the mouse position. Fixes issue [#1376]:
"mouse position".
* Fixed InvalidCastException in keyboard logging delegates.
2009-11-15 kanato
* MacOS: Fix crash in CheckEnterLeaveEvents if using WinForms too.
* MacOS: Correct resizing behavior and correctly implement Bounds,
ClientRectangle, and ClientSize getters and setters.
* MacOS: Add proper icon support for the dock.
* MacOS: Implement Focused property and FocusChanged event.
* MacOS: Implement mouse enter / leave events.
2009-11-14 kanato
* MacOS: Clean up AglContext destruction code. Implement
INativeWindow.Close method.
* MacOS: Several minor fixes: * Implement MouseWheel event *
Implement KeyPress event * Fix generation of MouseMove events *
Fix right mouse button up event
* MacOS: Fix bug where application started from the command line
would not be in the foreground and not respond to keyboard
events.
2009-11-12 the_fiddler
* Do not hook ProcessExit event if an X server is not available.
Should fix issue [#1364]: 1.0 beta-1 throws
TypeInitializationException in OpenTK.Platform.X11.API when
running on windows. Cleaned up stale comments and code.
2009-11-11 the_fiddler
* * Vector4.cs: * Vector3.cs: * Vector2.cs: * Vector4d.cs: *
Vector3d.cs: * Vector2d.cs: Removed code using C# 3.0 features.
* * BlittableValueType.cs: Clarify how BlittableValueType<T>.Stride
works on non-blittable types.
* * Source/OpenTK/BlittableValueType.cs: Removed struct constraint.
Sometimes consumers of this class may not be able to use struct
generic constraints - the class is now usable in this case. *
Source/Examples/OpenTK/Test/BlittableValueTypes.cs: Test
BlittableValueType class using several different types.
------------------------------ ------------------------------
OpenTK 0.9.9-3 -> 1.0 beta-1 OpenTK 0.9.9-3 -> 1.0 beta-1
------------------------------ ------------------------------
2009-11-10 the_fiddler 2009-11-10 the_fiddler
* Added missing license information.
* Updated documentation for release.
* Disabled CL10, ES10 and ES11 bindings which were not finalized in * Disabled CL10, ES10 and ES11 bindings which were not finalized in
time for OpenTK 1.0. time for OpenTK 1.0.
* Updated documentation for release. * Updated documentation for release.

View file

@ -1,69 +1,72 @@
The Open Toolkit 1.0 beta 1 The Open Toolkit 1.0 beta 2
[Overview] [Overview]
This is the first beta release of OpenTK 1.0. Important changes include: This is the second beta release of OpenTK 1.0. This release a laarge number of issues identified in the first beta. Additionally, it:
* Type-safe OpenGL|ES 2.0 bindings. * improves support for Mac OS × (multiple monitors, dock integration, input focus and more).
* A large number of new examples on picking, shaders, dds textures, constructive solid geometry and multithreading. * allows OpenTK to run on *BSD, Solaris and other Unix variants.
* Improved Mac OS X support. * fixes a timing issue that caused UpdateFrame events to be raised up to 50% faster than necessary.
* Improved multi-monitor support. * adds a number of missing tokens for OpenGL 3.1 and 3.2.
* Improved multithreading support. * fixes mouse movement on windows and adds support for fractional wheel values (available in high-precision mice).
* A large number of bug- and stability fixes. * fixes and optimizes quaternion-vector transforms.
* Improved documentation. * further improves multithreading support on Linux.
* Improvements and bugfixes to the build system. * works around a Visual Studio bug, which caused a number of OpenGL wrappers to disappear from intellisense.
* Temporary removal of OpenGL|ES 1.0, 1.1 and OpenCL bindings.
Please visit http://www.opentk.com to report issues or request features. Visit http://www.opentk.com for the latest news and information on the Open Toolkit.
[Resolved issues] [Resolved issues]
[#550] [#805]
[#552] [#1098]
[#622] [#1162]
[#1013] [#1166]
[#1014] [#1216]
[#1015] [#1279]
[#1028] [#1324]
[#1071] [#1354]
[#1142] [#1355]
[#1265] [#1364]
[#1268] [#1367]
[#1274] [#1372]
[#1291] [#1373]
[#1294] [#1376]
[#1300] [#1378]
[#1303] [#1382]
[#1304] [#1386]
[#1307]
[#1313] Please report any issues you encounter at http://www.opentk.com/node/add/project-issue/opentk
[#1318]
[#1333]
[#1334]
[#1338]
[#1339]
[#1341]
[#1350]
[Known issues] [Known issues]
* The Mac OS X port needs testing. If you encounter a bug, please report it at http://www.opentk.com/node/add/project-issue/opentk.
* OpenGL 3.1 and 3.2 fucntions may be missing specific tokens. Please report any such issues at http://www.opentk.com/node/add/project-issue/opentk
* Mono 2.2 and 2.4.0 fail to compile OpenTK due to a compiler bug (https://bugzilla.novell.com/show_bug.cgi?id=488960). Please compile with Mono 2.0, 2.4.2+ or use the supplied binaries instead. * Mono 2.2 and 2.4.0 fail to compile OpenTK due to a compiler bug (https://bugzilla.novell.com/show_bug.cgi?id=488960). Please compile with Mono 2.0, 2.4.2+ or use the supplied binaries instead.
* The example browser is incomplete.
* The Mac OS X port needs work. If you are interested in helping out, please make a post at http://www.opentk.com/forum/3. * The example browser is a work-in-progress.
* MonoDevelop fails to sign assemblies (bugs https://bugzilla.novell.com/show_bug.cgi?id=484752 and https://bugzilla.novell.com/show_bug.cgi?id=537063). * MonoDevelop fails to sign assemblies (bugs https://bugzilla.novell.com/show_bug.cgi?id=484752 and https://bugzilla.novell.com/show_bug.cgi?id=537063).
* OpenGL 3.2 methods may be missing specific tokens. Please report any such issues at http://www.opentk.com/node/add/project-issue/opentk
[API changes] [API changes]
Please note that binary compatibility is not preserved between beta releases. Please note that binary compatibility is not preserved between beta releases.
If you are upgrading from OpenTK 0.9.9-0 or earlier you can simplify the upgrade process by adding a reference to OpenTK.Compatibility.dll and OpenTK.GLControl.dll (if necessary). OpenTK.Compatibility contains code and APIs that have been deprecated and removed from the core library, as well as code for interoperation with the Tao framework. If you are upgrading from OpenTK 0.9.9-0 or earlier you can simplify the upgrade process by adding a reference to OpenTK.Compatibility.dll and OpenTK.GLControl.dll (if necessary). OpenTK.Compatibility contains code and APIs that have been deprecated and removed from the core library and supports applications written against the Tao framework (Tao.OpenGl, Tao.OpenAl and Tao.Platform.Windows.SimpleOpenGlControl).
[1.0 beta-2]
1. NormalPointer(..., int) and FogCoordPointer(..., int) overloads no longer specify a 'size' argument.
Solution: this is the correct signature, the 'size' argument found in previous OpenTK versions was invalid. This bug is unlikely to appear in practice.
[1.0 beta-1] [1.0 beta-1]

View file

@ -73,8 +73,6 @@ namespace OpenTK
{ {
#region --- Fields --- #region --- Fields ---
//DisplayMode mode; // TODO: Removable?
object exit_lock = new object(); object exit_lock = new object();
IGraphicsContext glContext; IGraphicsContext glContext;
@ -84,11 +82,13 @@ namespace OpenTK
double update_period, render_period; double update_period, render_period;
double target_update_period, target_render_period; double target_update_period, target_render_period;
// TODO: Implement these: // TODO: Implement these:
double update_time, render_time;//, event_time; double update_time, render_time;
//bool allow_sleep = true; // If true, GameWindow will call Timer.Sleep() if there is enough time.
VSyncMode vsync; VSyncMode vsync;
//InputDriver input_driver; Stopwatch update_watch = new Stopwatch(), render_watch = new Stopwatch();
double next_render = 0.0, next_update = 0.0;
FrameEventArgs update_args = new FrameEventArgs();
FrameEventArgs render_args = new FrameEventArgs();
#endregion #endregion
@ -369,42 +369,26 @@ namespace OpenTK
TargetUpdateFrequency = updates_per_second; TargetUpdateFrequency = updates_per_second;
TargetRenderFrequency = frames_per_second; TargetRenderFrequency = frames_per_second;
Stopwatch update_watch = new Stopwatch(), render_watch = new Stopwatch();
double next_render = 0.0, next_update = 0.0;
FrameEventArgs update_args = new FrameEventArgs();
FrameEventArgs render_args = new FrameEventArgs();
update_watch.Reset();
render_watch.Reset();
Visible = true; // Make sure the GameWindow is visible. Visible = true; // Make sure the GameWindow is visible.
OnLoadInternal(EventArgs.Empty); OnLoadInternal(EventArgs.Empty);
// On some platforms, ProcessEvents() does not return while the user is resizing or moving // On some platforms, ProcessEvents() does not return while the user is resizing or moving
// the window. We can avoid this issue by raising UpdateFrame and RenderFrame events // the window. We can avoid this issue by raising UpdateFrame and RenderFrame events
// whenever we encounter a size or move event. // whenever we encounter a size or move event.
EventHandler<EventArgs> DispatchUpdateAndRenderFrame = delegate(object sender, EventArgs e)
{
RaiseUpdateFrame(update_watch, ref next_update, update_args);
RaiseRenderFrame(render_watch, ref next_render, render_args);
};
Move += DispatchUpdateAndRenderFrame; Move += DispatchUpdateAndRenderFrame;
Resize += DispatchUpdateAndRenderFrame; Resize += DispatchUpdateAndRenderFrame;
Debug.Print("Entering main loop."); Debug.Print("Entering main loop.");
update_watch.Start();
render_watch.Start();
while (!IsExiting && Exists) while (!IsExiting && Exists)
{ {
ProcessEvents(); ProcessEvents();
DispatchUpdateAndRenderFrame(this, EventArgs.Empty); DispatchUpdateAndRenderFrame(this, EventArgs.Empty);
} }
} }
finally finally
{ {
Debug.Print("Restoring priority.");
Thread.CurrentThread.Priority = ThreadPriority.Normal;
OnUnloadInternal(EventArgs.Empty); OnUnloadInternal(EventArgs.Empty);
if (Exists) if (Exists)
@ -415,68 +399,69 @@ namespace OpenTK
} }
} }
private void RaiseUpdateFrame(Stopwatch update_watch, ref double next_update, FrameEventArgs update_args) void DispatchUpdateAndRenderFrame(object sender, EventArgs e)
{
RaiseUpdateFrame(update_watch, ref next_update, update_args);
RaiseRenderFrame(render_watch, ref next_render, render_args);
}
void RaiseUpdateFrame(Stopwatch update_watch, ref double next_update, FrameEventArgs update_args)
{ {
int num_updates = 0; int num_updates = 0;
double total_update_time = 0;
// Cap the maximum time drift to 1 second (e.g. when the process is suspended). // Cap the maximum time drift to 1 second (e.g. when the process is suspended).
double time = update_watch.Elapsed.TotalSeconds; double time = update_watch.Elapsed.TotalSeconds;
if (time <= 0)
return;
if (time > 1.0) if (time > 1.0)
time = 1.0; time = 1.0;
// Raise UpdateFrame events until we catch up with our target update rate. // Raise UpdateFrame events until we catch up with our target update rate.
while (next_update - time <= 0.0) while (next_update - time <= 0 && time > 0)
{ {
next_update -= time;
update_args.Time = time;
OnUpdateFrameInternal(update_args);
time = update_time = update_watch.Elapsed.TotalSeconds - time;
// Stopwatches are not accurate over long time periods.
// We accumulate the total elapsed time into the time variable
// while reseting the Stopwatch frequently.
update_watch.Reset();
update_watch.Start();
// Don't schedule a new update more than 1 second in the future. // Don't schedule a new update more than 1 second in the future.
// Sometimes the hardware cannot keep up with updates // Sometimes the hardware cannot keep up with updates
// (e.g. when the update rate is too high, or the UpdateFrame processing // (e.g. when the update rate is too high, or the UpdateFrame processing
// is too costly). This cap ensures we can catch up in a reasonable time // is too costly). This cap ensures we can catch up in a reasonable time
// once the load becomes lighter. // once the load becomes lighter.
next_update = next_update - time + TargetUpdatePeriod; next_update += TargetUpdatePeriod;
if (next_update < -1.0) next_update = Math.Max(next_update, -1.0);
next_update = -1.0;
// Allow up to 10 consecutive UpdateFrame events. total_update_time += update_time;
// This prevents the application from "hanging" when the hardware cannot
// keep up with the requested update rate. // Allow up to 10 consecutive UpdateFrame events to prevent the
if (++num_updates >= 10) // application from "hanging" when the hardware cannot keep up
// with the requested update rate.
if (++num_updates >= 10 || TargetUpdateFrequency == 0.0)
break; break;
if (time > 0)
{
update_args.Time = time;
OnUpdateFrameInternal(update_args);
update_time = update_watch.Elapsed.TotalSeconds;
}
time = update_watch.Elapsed.TotalSeconds;
// Stopwatches are not accurate over long time periods.
// We accumlate the total elapsed time into the time variable
// while reseting the Stopwatch frequently.
update_watch.Reset();
update_watch.Start();
if (TargetUpdateFrequency == 0.0)
break;
next_update -= time;
} }
// Calculate statistics // Calculate statistics
if (num_updates > 0) if (num_updates > 0)
{ {
update_period = time / (double)num_updates; update_period = total_update_time / (double)num_updates;
} }
} }
private void RaiseRenderFrame(Stopwatch render_watch, ref double next_render, FrameEventArgs render_args) void RaiseRenderFrame(Stopwatch render_watch, ref double next_render, FrameEventArgs render_args)
{ {
// Cap the maximum time drift to 1 second (e.g. when the process is suspended). // Cap the maximum time drift to 1 second (e.g. when the process is suspended).
double time = render_watch.Elapsed.TotalSeconds; double time = render_watch.Elapsed.TotalSeconds;
if (time > 1.0) if (time > 1.0)
time = 1.0; time = 1.0;
if (time <= 0)
return;
double time_left = next_render - time; double time_left = next_render - time;
// Todo: remove this? // Todo: remove this?