Game Development Community

Serious issue in T2D 1.7.6 on Mac

by Frantisek Smrcka · in Technical Issues · 01/06/2012 (3:44 pm) · 16 replies

Hi guys, I'm encountering a serious issue in Torque 2D 1.7.6.

Everytime I try to enter fullscreen mode either by using toggleFullScreen() or setScreenMode() I get this horrible error:

Quote:Fatal-ISV: (/Applications/Torque/Torque2D_Pro_1_7_6/engine/compilers/Xcode/../../source/platformMacCarb/macCarbOGLVideo.cc @ 556)

We could not create a valid AGL rendering context

I'm on Macbook Pro with Snow Leopard 10.6.8 and first I though it might have been caused by Xcode incompatibility as I had the newest version 4.2. So I uninstalled it and installed older and 100% compatible 3.2 version, yet the problem remained. So I tried coming back to Torque 2D 1.7.5 as I remembered switching to fullscreen with no problem and it worked perfectly. The same resolution and camera settings which by the way was in all cases 1280x720x32 and camera set to 160x90.

Anyone else on Mac with 1.7.6 version with the same issue? Anyone knows the solution?

#1
01/06/2012 (4:11 pm)
Do you have more than one monitor or are connecting through another subsystem like VNC?
#2
01/07/2012 (1:10 am)
Yep, I do have another monitor plugged to my Macbook's DVI port. The Big screen is the main screen where all the work is done. However, I have to remind that everything works just great when using 1.7.5...
#3
01/16/2012 (5:51 am)
Still no one has any solution to this issue? No one on Mac dealing with the same thing?
#4
01/16/2012 (8:18 am)
I have the same problem, stopping me from verifying if a problem that only occurred in fullscreen happens anymore. But that's not the worst problem I have, so I'm expecting a 1.7.7 :)
#5
01/18/2012 (6:11 am)
I've the same problem... with one or two monitors..
#6
01/24/2012 (1:10 am)
My app was rejected from App Store for this issue.

Any idea to apply a rapid patch?
#7
01/25/2012 (2:13 am)
Hmmm, that's exactly what I was afraid that could happen in my case as well.

I looked into macCarbOGLVideo.cc the other day as this was the one causing the error and compared it with the version released for 1.7.5 which worked just fine and found out that its slightly different, so I was considering either replacing the 1.7.6 version with the old one or simply going back to 1.7.5 TGB. But the problem is, that the changes in 1.7.6 version were made in order to make built apps run under OS X 10.7 Lion, where as I assume the apps built in 1.7.5 does not. And this leads into an inevitable conclusion that no matter what version you use (right now), you never get it to the App Store. In one case it's because the full screen issue, in another because of lack of support for the newest OS. We're stuck in between. The only reason why I remain patient about it is that my game is not finished yet so I can hope a fix will be released before it is, however, if I were you, I'd try to contact GG directly and try to push them a little bit.
#8
01/25/2012 (8:50 am)
Sorry I did not reply to this thread earlier. I saw the original post and I have been investigating a solution. Just posting to let you know I'm aware and will be taking action.
#9
01/26/2012 (8:44 am)
Cool, looking forward to it...
#10
02/07/2012 (1:19 pm)
Hi Micheal, thanks for looking into this issue, any updates on a fix?
#11
03/01/2012 (3:58 pm)
Alright all. I have the crash fixed. I now have v1.7.6 running in fullscreen on OS X Lion. I still need to fix a few issues, like having it select the main screen on a multi-monitor setup and grabbing the best resolution. I also want to read a few more docs on the code I am touching, as it makes me nervous that commenting out two lines of code made this work.

I would like people to test the code as I progress. Here is the first part of the fix:

1. Open engine/compilers/Xcode/Torque2D.xcodeproj
2. Expand the platformMacCarb group
3. Open macCarbOGLVideo.cc
4. Scroll down to line 137 in the following function:

AGLPixelFormat findValidPixelFormat(bool fullscreen, U32 bpp, U32 samples, bool recovery = true)
{
}

5. Comment out the following code:

if(fullscreen)
   attr[i++] = AGL_FULLSCREEN;

6. Change the following code:

fmt = aglChoosePixelFormat(NULL/*&platState.hDisplay*/, 1, attr);

To this:

fmt = aglChoosePixelFormat(NULL/*&platState.hDisplay*/, 0, attr);

7. Build the TGBGame project

8. Replace your game's TGBGame.app with what has been compiled in the tgb/gameData/T2DProject folder

9. Set your game to use fullscreen

10. RUN

If this allows your game to run in fullscreen mode without a crash, please let me know. If you encounter a crash, please provide a link to a crash log.

Again, there's some more work to do, but this should stop your crashing.
#12
03/02/2012 (11:38 am)
So I implemented this fix, it worked for me when I was starting in windowed mode and switching to full screen, that is good :).

Unfortunately , when I would start directly in full screen, it would still be windowed. On my widescreen monitor, starting like this in windowed mode would make my game scale incorrectly, because my window is 4:3 (1024 x 768), but the full screen graphics are 16:9 (1366 x 768). So my game would load the widescreen graphic for full screen and then it would get warped because it was in a regular size window.

Now the really bad part is that just when I was going to dig into the debugger and trace what was happening, to check what values were getting to the key function here, my video card on my mac started to flake out, so atm I cant run and get more info :(.
#13
05/08/2012 (8:36 pm)
Ok so just wanted to confirm finally that this fix works for me too. Got around to the Mac build again , finally, on a Lion Machine using Xcode 4.1, and using the GCC compiler setting (so our Oggs work).

The issue with starting in fullscreen was that the mac code has a setScreenMode call happen inside the createCanvas call, unlike the windows side. For me it just meant making sure I have these 2 of 3 variables set before calling createCanvas.

This, (bool )$pref::Video::fullScreen and one of these... (fullscreen) $pref::Video::resolution , (windowed) $pref::Video::windowedRes.

Anyway the fix works so thats great, thanks again. :)
#14
05/08/2012 (11:20 pm)
Have you tried with two monitors? It fullscreens on the wrong one for me (Mich knows).
#15
06/10/2012 (3:20 pm)
What this fix does is picks a pixelFormat for windowed mode and uses it for fullscreen. Although this will work in most cases, hitting correct PF is still pretty much a game of chance.

A less hacky but still quck hack would use DMGetGDeviceByDisplayID to get display handle and pass it to aglChoosePixelFormat, but this function is deprecated since Tiger (that's the way it was before that thing there was commented out, I think). It seems, Apple removed all the tricky stuff from their high-level AGL, and the only proper way is to rewrite the whole thing to use CGL.

This article looks promissing
gafferongames.com/2009/01/19/opengl-on-macosx/
but I won't get to work with my Mac in next few days, so good luck everyone.
#16
10/15/2012 (4:21 am)
The problem is due to some cards hardware acceleration are not supported.

you can comment the line

attr[i++] = AGL_ACCELERATED;

in file macCarbOGLVideo.cc