the Fiddler's picture

Investigate possible WinForms-based GameWindow implementation.

Project:The Open Toolkit library
Version:0.9.x-dev
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:closed
Description

A Windows.Forms implementation of GameWindow will significantly reduce the amount of code we have to maintain in OpenTK.Platform. It will also make new new features easier to implement and the code will be better tested.

I have spent some time implementing GameWindow2 using Windows.Forms, GLControl and Kamujin's InterleavedScheduler. The resulting code is, indeed, much simpler and supports several features missing from the current implementation:

  • Support for custom main loops.
  • Support for window icons.
  • Support for setting the window position.
  • Saner event interface (closer to the BCL conventions).

On the other hand, the new code is missing keyboard and mouse support, cannot run at unlimited update / render frequencies and is not compatible with GameWindow.

I'd love to hear your feedback:

  1. Does it run on your system? (which OS?) You should see a black 640x480 window with a fps counter on the top-left corner. I am especially interested in Mac OS X.
  2. Is your fps stable and close to 60?
  3. How is the CPU and memory usage compared to the old implementation?
  4. Try setting different pixel formats in the GameWindow2 constructor - does it still work?

Binaries and source code are attached. I won't be having much free time the next few weeks, so please feel free to make modifications and corrections (consider it released under the OpenTK license).

Edit: New version which suppresses WinForms Mouse & Keyboard messages and changes FrameEventArgs.Time from TimeSpan to double.

Edit 2: New version that allows you to choose between the old and new GameWindow implementation for comparison.

Edit 3: New version that forces VSync to off.

Edit 4: Please ignore the attachment below, it is outdated. Use the file located here.

AttachmentSize
GameWindow2.7z391.81 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

#41

Status:in progress» closed

The gw-next2 branch contains custom INativeWindow implementations that do not rely on Windows.Forms.

objarni's picture

#42

So if not WinForms dependent, what does it depend on?

the Fiddler's picture

#43

Completely native.

OpenTK 0.9.7 ships with native X11 and MacOS implementations and a WinForms-based Win32 implementation (which is not as bad as it seems). The gw-next2 branch contains a native Win32 implementation and a much more extensive API on all platforms. I'll post more details on a new issue, but it should be stable for testing now.

objarni's picture

#44

Cool. Any plans on new binary release ? Beta?

the Fiddler's picture

#45

At the soonest, the new code will go into OpenTK 0.9.9.