As the title says MonoGame is using MonoMac’s MonoMacGameView to drive their cross platform XNA gaming development platform.


MonoGame

As per their project description from the MonoGame website at http://monogame.codeplex.com/ :

MonoGame is a free OpenGL implementation of the XNA Framework for MonoTouch, MonoDroid, Mac OS X & now Windows. Our goal is to allow XNA developers on Windows & Windows Phone 7 to port of their games to the iPhone / iPod / Android / Mac OS X (visa versa), with minimal hassle. 

MonoMacGameView

To implement the MacOS X side they used the MonoMacGameView which is MonoMac’s implementation of a NSView to allow you to animate and render OpenGL content.  The MonoMacGameView exposes several events that can be subscribed to or overridden to add custom animation logic.

Events that are exposed follow the OpenTK GameWindow events to allow easier integration with existing code:

  • OnLoad: Occurs after creating the OpenGL context, but before entering the main loop. Override to load resources.
  • OnUnload: Occurs after exiting the main loop, but before deleting the OpenGL context. Override to unload resources.
  • OnResize: Occurs whenever GameWindow is resized. You should update the OpenGL Viewport and Projection Matrix here.
  • OnUpdateFrame: Occurs at the specified frame render rate. Override to add your game logic.
  • OnRenderFrame: Occurs at the specified frame render rate. Override to add your rendering code.

Call the Run() method to start the application’s main loop.  Run(double) takes a parameter that specifies the rendering update rate.

By default the Run() method or specifying 0.0 for update rate Run(0.0) method uses the CVDisplayLink which synchronizes buffer swaps with the vertical refresh rate (usually 60Hz or ~60 frames per second) and allows the machine to determine the best rate.

If you pass a value to the Run(double) method other than 0 then the updates are refreshed by a NSTimer update so you can control what the animation refresh rate or frames per second will be.

Sample Code

To see actual samples running you can access the github content at https://github.com/CartBlanche/MonoGame.  Once you have the repository you can open the MonoGame.Framework.MacOS.sln file to see the samples.

If you are interested in helping out let Dominique know or post a message on the codeplex discussion board here http://monogame.codeplex.com/discussions.