kanato's picture

Mac OS X progress

I have committed preliminary Mac OS support to the branches/macos folder in subversion. I am starting a new topic because the old topic has a bunch of discussion which isn't relevant now.

Things which aren't currently supported:
* Fullscreen
* WinForms integration, including GLControl

Things which are supported:
* Game window creation
* Keyboard and mouse events
* Enumeration of supported display modes

OpenTK Example results on my machine are listed below. My machine is a Mac Mini, with OS X 10.4.11 installed. Graphics card is a built-in Intel GMA 950.

GLSL 1: First shader: Works, but gives message about requiring OpenGL 2.0
GLSL 2: Julia set: Gives message about requiring OpenGL 2.0, then black screen with FPS counter
OpenAL: Playback: Works
OpenGL 5: Vertex arrays: Null reference exception
OpenGL: GLU Tesselation: KeyNotFoundException is thrown
OpenGL: Simple FBO: Works (I am unsure if the resulting image is correct though)
Test: Audio Context Test: No error message.
Test: GameWindow states: Fullscreen min/max not implemented.
Test: Input Logger: Works okay if you click on the "hidden input window" at first. If you click on anything else, it stops working.
Test: Math speed test: KeyNotFoundException is thrown
Test: Resolution changes: Not supported yet.
Tutorial 1: Simple Window: Works
Tutorial 2: Immediate mode: Works
Tutorial 3: Display Lists: Works
Tutorial 3: Fonts: Works
Tutorial 4: Text: Runs, but text layout is messed up, except for FPS counter.
Tutorial 5: Texture mapping: Works
Tutorial 8: VBO's: Works after message about needing OpenGL 1.5.

WinForms 1: Runs, but no colors appear.
WinForms 2: Runs, but no response to input.
WinForms 3: Works
WinForms 4: Runs, but nothing appears in controls.

The KeyNotFoundException appears to be a bug in the CarbonGLNative window, so I will need to examine that more closely. Kamujin, if you can run the examples and let me know if you get the same results that will be helpful.

I've also done some refactoring in the library in how platform specific classes are instantiated.


Comment viewing options

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

Awesome! Good to hear it works on Leopard too. I am surprised at the crash in WinForms 3. The WinForms 4 test might look right if you resize the window. At least it does on mine, so there is something of an initial refresh problem.

The next major thing to do is full screen support, after that it is just finding and fixing bugs.

kanato's picture

Okay, I have attached a new test version of the Examples.app. JTAlton, Kamujin if you guys can test this it will be helpful. This one includes full screen support which needs to be tested.

There are a few known issues:

  • OpenGL 5: Vertex Arrays - fails.
  • Test Resolution Changes - This gives a black screen after the resolution change, because no context is set to the display. Hit enter to get past it.
  • Input Logger - The Hidden window is not actually hidden.

On my machine, winforms 3 (extensions) after running other examples it crashes. If it's the first example, there is no problem. I'm curious to know if this occurs on other machines as well.

Also, if that works, there is a less trivial test: http://www.agatelib.org/download/bbx.tar.bzip2 . Music doesn't work, because OpenAL doesn't support decoding ogg files.

examples.tar_.gz1.33 MB
JTalton's picture

Sweet. I'll give it a try when I get a chance. The wife hordes the MacBook Pro.

JTalton's picture

Error.png56.11 KB
debug.log23.65 KB
kanato's picture

Okay, I'm pretty sure that's the same error as before. It's complaining because of the presence of the fullscreen flag, and it doesn't like the device handle I've passed to it for some reason. I will try to post a fix for it soon.

kanato's picture

Okay, can you try this one out? Try the GameWindow states test. There are two ways to go full screen, one is by pressing shift+1 and the other by pressing 3. The second one changes resolution, and the first one keeps the desktop resolution. Can you let me know if these work?

Examples.tgz1.33 MB
JTalton's picture

GameWindow state changes work. Looks good! Also tested the Julia Set which works good. Fonts are not rendering.

kanato's picture

Ok, I have completed merging the macos branch in with the trunk, but it is not committed yet. Before I actually do the commit, there were a couple of changes I made to GameWindow that I would like comments on. I have attached a patch with the chages to GameWindow and GLControl. If you apply this patch, it won't compile because other stuff that it depends on is not included in the patch. Mainly the things that were changed were switching to full screen in the GameWindow constructor, I changed how the Resize event interacts betwee GameWindow and INativeGLWindow and added a Close event which is used if the window is closed. The resize changes make the behavior a bit more consistent, and the Close event is useful for code which does not use GameWindow.Run. The resize changes are also related to the fact that on Mac OS X on is required to call aglUpdateContext when the size of the render target is changed, so this is the main source of the changes in the GLControl code.

So far everything seems to work great, except for the text example. That one gets about 7 frames per second, and all the text is scrunched up to the left side. The Fonts example works fine, except it appears that the bold and italic flags are ignored. The WinForms font rendering sample works fine too.

macos_gamewindow.patch5.31 KB
the Fiddler's picture

The patch look fine.

Can you please run a final "svn update" before committing? I made some changes to the MouseDevice earlier - they shouldn't cause any conflicts, but just to be safe.

Edit: the text example is broken on Mono because their GDI+ implementation does not support word wrapping. The more I work on it, the more obvious it becomes that text in .Net is broken beyond repair. At this point, the only sensible solution for text layout is to use Mono.Pango on Linux / MacOS and native GDI on Windows.

kanato's picture

Ok, the merge is committed, so the OpenTK trunk now has support for Mac OS X.