Author Topic: Multiplatform and Resolution Support.  (Read 4075 times)

Offline mrplant

  • Mr. Polyvector
  • ***
  • Posts: 232
    • View Profile
Hi.

I have a game I am writing  that has platform conditional code. It has been a real learning example but I finally have it working from one source code and one set of graphics.
I use Ampos's generous rescaling code mainly, slightly customised to my needs. Thanks Ampos!

My game runs and has been tested on PC, Mac, iPhone 3, iPhone 4s, iPad 1, iPad 2, iPad 3rd Generation and iPod.

I designed the game initially at 1024x768 (4:3 aspect ratio resolution) for all my graphics and screen placement code and use Ampos's routines to rescale to chosen resolution.
Ok.

So.. on the PC platform - I set project settings to be 3999x3998 manually and the code autoscales by reading the DESKTOP size and setscreen'ing to that resolution. Works great.
I have a 27" iMac here and run GLBasic on Parallels fullscreen mode - the desktop size is 2560x1440 on this computer and the game works out the scale factor internally and fills the screen to the games 4:3 aspect ratio.
Works as expected. Graphics are very crisp as I have an 8 bit style and don't use Smoothscale modes on the whole.

On iOS - I designed the game for my main platform at the time - the iPad 1 and iPad 2 at 1024x768.  Again I set the project settings to 3999x3998 and the code reads the SCREENSIZE this time (using conditional code) and resizes.
When compiling on Xcode, I set project type to universal.
This means it runs on iPad at 1024x768. It run on new iPad 3rd gen model at 2048x1536 (upscaling by a factor of 2.0). Due to the 8 bit nature of my graphics it looks great on the new iPad2 (I use smoothshading off to get the effect I need).
It autosizes on the fly on iPhone to 960x480, again running in a 4:3 aspect ratio scaled area. Great! iPhone 3 - same it runs at 480x240 with no issues. IPod Same.

The one problem is the Mac platform. Here is why. You can't use the SETSCREEN command I have found, as it causes crashes and bad things to happen so I have to rely on project settings here.

If I set project settings to 1024x768 on the Mac - the game runs fine as it sets my macs monitor to 1024x768 graphics mode automatically on startup. Looks a bit blurry though as the native monitor resolution is 2560x1440. It runs on my Macbook at 1024x768 again fine. (The Macbook native res is 1280x800).

Now then.. If I manually set the project settings for Mac to 2560x1440 - it runs on my Mac at native resolution now at 2560x1440 and the graphics look as crisp as they do on Parallels under windows mentioned earlier.
The problem is.. If I run this binary on my Macbook - the native screen size is 1280x800. What happens is the binary crashes at launch - not good.
If I compile another version with project settings at 1024x768 it runs fine of course.
*I see Macbook Air screen resolutions all support 1024x768 4:3 modes, but are native 1366x768 for 11.6" models and 1440x900 for 13" models.

The point of all this is .. I have a proposal to make.. that to my mind would improve the way things can be handled on the Mac platform.
Here it is..

On Mac - you have to rely on Project settings - thats fine.
I can set 1024x768 or manually enter in 2560x1440 but both these things cause the problem above when Mac screen hardware is different sizes (ie. crashes on startup).

What if.. On the Mac if you could enter 3999x3998 manually as project settings. This would then be a flag to the GLBasic Mac runtime startup code that it should see what the native Mac screen resolution is and (without resizing) it should use those values for the current screen size - if the users program requests to know the SCREENSIZE, it should return those native screen resolution numbers. That way AMPOS's code could resize as normal.

That would mean that if I set project settings manually  to 3999x3998, the game would run at 2560x1440 on my 27"  iMac and at 1280x800 on my Macbook as those are the native screen sizes. This would just need one binary and it would not crash at startup on my Macbook (instead of what it does at present).

This change would require runtime startup support from GLBasic of course - to my mind it makes sense at it is a special case (3999x3998 manually) but would allow more flexibility on the Mac platform..

What do you think Gernot?

I have no idea if these changes are easy/impossible/make sense but as I say, to me in theory they do.

You could either hard set the resolution to use in Mac project settings to say 1024x768 or allow manual special case size of 3999x3998.

Thanks.

MrTAToad

  • Guest
Re: Multiplatform and Resolution Support.
« Reply #1 on: 2012-Mar-21 »
I'm sure SETSCREEN used to work on the iMac - unless the new OS does nasty things to the SDL Video mode function...

Offline mrplant

  • Mr. Polyvector
  • ***
  • Posts: 232
    • View Profile
Re: Multiplatform and Resolution Support.
« Reply #2 on: 2012-Mar-21 »
Looks like it might MrTAToad.

If I set Mac project settings to 3999x3998 and start up the game, this is the crash log I get with Lion 10.7.3
Project settings to 2560x1440 work fine as expected.


Process:         MacOSX [995]
Path:            /Users/USER/Desktop/*/RockCrush.app/Contents/MacOS/MacOSX
Identifier:      com.techworldservices.rockcrush
Version:         3.042.0 (3.042.0)
Code Type:       X86 (Native)
Parent Process:  launchd [288]

Date/Time:       2012-03-21 15:43:56.327 +0000
OS Version:      Mac OS X 10.7.3 (11D50b)
Report Version:  9

Interval Since Last Report:          199141 sec
Crashes Since Last Report:           16
Per-App Interval Since Last Report:  111 sec
Per-App Crashes Since Last Report:   1
Anonymous UUID:                      BC55D36C-24D7-4327-A4FD-9FF718419FE2

Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000000

VM Regions Near 0:
--> __PAGEZERO             0000000000000000-0000000000001000 [    4K] ---/--- SM=NUL  /Users/USER/Desktop/*/RockCrush.app/Contents/MacOS/MacOSX
    __TEXT                 0000000000001000-00000000000ec000 [  940K] r-x/rwx SM=COW  /Users/USER/Desktop/*/RockCrush.app/Contents/MacOS/MacOSX

Application Specific Information:
objc[995]: garbage collection is OFF

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libGL.dylib                      0x90ac88c8 glClearColor + 12
1   com.techworldservices.rockcrush   0x0005c1ac OpenGLRainbows::ClearScreen(unsigned long) + 106
2   com.techworldservices.rockcrush   0x0001b55f __GLBASIC__::CLEARSCREEN(int) + 55
3   com.techworldservices.rockcrush   0x000178a5 __GLBASIC__::__MainGameSub_() + 53
4   com.techworldservices.rockcrush   0x0002f5a4 SDL_main + 814
5   com.techworldservices.rockcrush   0x0001a281 -[SDLMain applicationDidFinishLaunching:] + 88 (SDLMain.m:302)
6   com.apple.Foundation             0x921c2e25 __-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_1 + 49
7   com.apple.CoreFoundation         0x9bd46cb3 ___CFXNotificationPost_block_invoke_1 + 275
8   com.apple.CoreFoundation         0x9bd11a38 _CFXNotificationPost + 2776
9   com.apple.Foundation             0x921ae012 -[NSNotificationCenter postNotificationName:object:userInfo:] + 92
10  com.apple.AppKit                 0x9669175d -[NSApplication _postDidFinishNotification] + 259
11  com.apple.AppKit                 0x96691453 -[NSApplication _sendFinishLaunchingNotification] + 84
12  com.apple.AppKit                 0x9668ff74 -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:] + 277
13  com.apple.AppKit                 0x9668fc8a -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 377
14  com.apple.CoreFoundation         0x9bd5f298 -[NSObject performSelector:withObject:withObject:] + 72
15  com.apple.Foundation             0x921e80f6 __-[NSAppleEventManager setEventHandler:andSelector:forEventClass:andEventID:]_block_invoke_1 + 121
16  com.apple.Foundation             0x921e6ea9 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 476
17  com.apple.Foundation             0x921e6c7d _NSAppleEventManagerGenericHandler + 234
18  com.apple.AE                     0x9ac91045 aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned long, unsigned char*) + 202
19  com.apple.AE                     0x9ac7ab67 _ZL25dispatchEventAndSendReplyPK6AEDescPS_ + 43
20  com.apple.AE                     0x9ac7aa54 aeProcessAppleEvent + 253
21  com.apple.HIToolbox              0x9c0d05d6 AEProcessAppleEvent + 103
22  com.apple.AppKit                 0x9668cd0b _DPSNextEvent + 1301
23  com.apple.AppKit                 0x9668c306 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 113
24  com.apple.AppKit                 0x96688675 -[NSApplication run] + 911
25  com.techworldservices.rockcrush   0x0001a0a9 CustomApplicationMain + 428 (SDLMain.m:231)
26  com.techworldservices.rockcrush   0x0001a524 main + 280 (SDLMain.m:382)
27  com.techworldservices.rockcrush   0x0000248e _start + 228 (crt.c:272)
28  com.techworldservices.rockcrush   0x000023a9 start + 41

Thread 1:: Dispatch queue: com.apple.libdispatch-manager
0   libsystem_c.dylib                0x9b4c9527 __error + 19
1   libsystem_c.dylib                0x9b427c9e cthread_set_errno_self + 20
2   libsystem_kernel.dylib           0x9847048b cerror + 43
3   libdispatch.dylib                0x9be9b6a7 _dispatch_mgr_thread + 53

Thread 2:
0   libsystem_kernel.dylib           0x9846f02e __workq_kernreturn + 10
1   libsystem_c.dylib                0x9b473ccf _pthread_wqthread + 773
2   libsystem_c.dylib                0x9b4756fe start_wqthread + 30

Thread 3:
0   libsystem_kernel.dylib           0x9846f02e __workq_kernreturn + 10
1   libsystem_c.dylib                0x9b473ccf _pthread_wqthread + 773
2   libsystem_c.dylib                0x9b4756fe start_wqthread + 30

Thread 4:
0   libsystem_kernel.dylib           0x9846f02e __workq_kernreturn + 10
1   libsystem_c.dylib                0x9b473ccf _pthread_wqthread + 773
2   libsystem_c.dylib                0x9b4756fe start_wqthread + 30

Thread 5:
0   libsystem_kernel.dylib           0x9846f02e __workq_kernreturn + 10
1   libsystem_c.dylib                0x9b473ccf _pthread_wqthread + 773
2   libsystem_c.dylib                0x9b4756fe start_wqthread + 30

Thread 6:
0   libsystem_kernel.dylib           0x9846f02e __workq_kernreturn + 10
1   libsystem_c.dylib                0x9b473ccf _pthread_wqthread + 773
2   libsystem_c.dylib                0x9b4756fe start_wqthread + 30

Thread 0 crashed with X86 Thread State (32-bit):
  eax: 0x00000000  ebx: 0x0005c14e  ecx: 0x00000000  edx: 0x00ffffff
  edi: 0x00000000  esi: 0x000c3428  ebp: 0xbfffeac8  esp: 0xbfffeab0
   ss: 0x00000023  efl: 0x00010282  eip: 0x90ac88c8   cs: 0x0000001b
   ds: 0x00000023   es: 0x00000023   fs: 0x00000000   gs: 0x0000000f
  cr2: 0x00000000
Logical CPU: 1

Binary Images:
    0x1000 -    0xebff5 +com.techworldservices.rockcrush (3.042.0 - 3.042.0) <AE6A9FD6-51AA-202C-7151-7E5AE502B5F9> /Users/USER/Desktop/*/RockCrush.app/Contents/MacOS/MacOSX
 0x39c0000 -  0x39cefff  com.apple.iokit.IOHIDLib (1.7.1 - 1.7.1) <1748DFD3-0DC9-37E3-913E-C72BA193C8B0> /System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib
0x


------------------


etc..


If I set project settings to 3999x3998 and then do this in program:

XRes=2560
YRes= 1440
SETSCREEN XRes,YRes,1

I get this crash:


Process:         MacOSX [995]
Path:            /Users/USER/Desktop/*/RockCrush.app/Contents/MacOS/MacOSX
Identifier:      com.techworldservices.rockcrush
Version:         3.042.0 (3.042.0)
Code Type:       X86 (Native)
Parent Process:  launchd [288]

Date/Time:       2012-03-21 15:43:56.327 +0000
OS Version:      Mac OS X 10.7.3 (11D50b)
Report Version:  9

Interval Since Last Report:          199141 sec
Crashes Since Last Report:           16
Per-App Interval Since Last Report:  111 sec
Per-App Crashes Since Last Report:   1
Anonymous UUID:                      BC55D36C-24D7-4327-A4FD-9FF718419FE2

Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000000

VM Regions Near 0:
--> __PAGEZERO             0000000000000000-0000000000001000 [    4K] ---/--- SM=NUL  /Users/USER/Desktop/*/RockCrush.app/Contents/MacOS/MacOSX
    __TEXT                 0000000000001000-00000000000ec000 [  940K] r-x/rwx SM=COW  /Users/USER/Desktop/*/RockCrush.app/Contents/MacOS/MacOSX

Application Specific Information:
objc[995]: garbage collection is OFF

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libGL.dylib                      0x90ac88c8 glClearColor + 12
1   com.techworldservices.rockcrush   0x0005c1ac OpenGLRainbows::ClearScreen(unsigned long) + 106
2   com.techworldservices.rockcrush   0x0001b55f __GLBASIC__::CLEARSCREEN(int) + 55
3   com.techworldservices.rockcrush   0x000178a5 __GLBASIC__::__MainGameSub_() + 53
4   com.techworldservices.rockcrush   0x0002f5a4 SDL_main + 814
5   com.techworldservices.rockcrush   0x0001a281 -[SDLMain applicationDidFinishLaunching:] + 88 (SDLMain.m:302)
6   com.apple.Foundation             0x921c2e25 __-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_1 + 49
7   com.apple.CoreFoundation         0x9bd46cb3 ___CFXNotificationPost_block_invoke_1 + 275
8   com.apple.CoreFoundation         0x9bd11a38 _CFXNotificationPost + 2776
9   com.apple.Foundation             0x921ae012 -[NSNotificationCenter postNotificationName:object:userInfo:] + 92
10  com.apple.AppKit                 0x9669175d -[NSApplication _postDidFinishNotification] + 259
11  com.apple.AppKit                 0x96691453 -[NSApplication _sendFinishLaunchingNotification] + 84
12  com.apple.AppKit                 0x9668ff74 -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:] + 277
13  com.apple.AppKit                 0x9668fc8a -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 377
14  com.apple.CoreFoundation         0x9bd5f298 -[NSObject performSelector:withObject:withObject:] + 72
15  com.apple.Foundation             0x921e80f6 __-[NSAppleEventManager setEventHandler:andSelector:forEventClass:andEventID:]_block_invoke_1 + 121
16  com.apple.Foundation             0x921e6ea9 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 476
17  com.apple.Foundation             0x921e6c7d _NSAppleEventManagerGenericHandler + 234
18  com.apple.AE                     0x9ac91045 aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned long, unsigned char*) + 202
19  com.apple.AE                     0x9ac7ab67 _ZL25dispatchEventAndSendReplyPK6AEDescPS_ + 43
20  com.apple.AE                     0x9ac7aa54 aeProcessAppleEvent + 253
21  com.apple.HIToolbox              0x9c0d05d6 AEProcessAppleEvent + 103
22  com.apple.AppKit                 0x9668cd0b _DPSNextEvent + 1301
23  com.apple.AppKit                 0x9668c306 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 113
24  com.apple.AppKit                 0x96688675 -[NSApplication run] + 911
25  com.techworldservices.rockcrush   0x0001a0a9 CustomApplicationMain + 428 (SDLMain.m:231)
26  com.techworldservices.rockcrush   0x0001a524 main + 280 (SDLMain.m:382)
27  com.techworldservices.rockcrush   0x0000248e _start + 228 (crt.c:272)
28  com.techworldservices.rockcrush   0x000023a9 start + 41
« Last Edit: 2012-Mar-21 by mrplant »

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10697
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Multiplatform and Resolution Support.
« Reply #3 on: 2012-Mar-21 »
maybe the gfx card can't display such a large texture?
Why would you start with 3999x3998? Just use 320x240 and then GETDESKTOPSIZE and then SETSCREEN. It's (so far) only the mobile devices that can't resize the screen, because the iOS handles this terribly complicated.

Offline mrplant

  • Mr. Polyvector
  • ***
  • Posts: 232
    • View Profile
Re: Multiplatform and Resolution Support.
« Reply #4 on: 2012-Mar-21 »
Ill try that.

The only reason I was using such obviously oversized values of 3999x3998 is purely because someone else mentioned it in the other resizing threads.
In fact it was originally 9999x9998 - quite a few people were talking about it.

anyway, I will give the low values a try instead! Seems sensible.
« Last Edit: 2012-Mar-21 by mrplant »

Offline mrplant

  • Mr. Polyvector
  • ***
  • Posts: 232
    • View Profile
Re: Multiplatform and Resolution Support.
« Reply #5 on: 2012-Mar-21 »
I tried setting Mac project settings to 320x240 and let code GETDESKTOPSIZE then SETSCREEN mode to those values at runtime.

However , all I get is a solid white window with no graphics or text - sound continues to work and game seems to be there hidden somewhere but screen output is blank for some reason. Maybe an SDL issue on Lion?

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3611
    • View Profile
    • Space Fractal
Re: Multiplatform and Resolution Support.
« Reply #6 on: 2012-Mar-21 »
On my mac I also have problems using SETSCREEN, which dosent set fullscreen at all, but a fullscreen windowed instead. So I dedicated I just checking the desktop resoulution minus some pixels around, so its not got of the bottom or in the right. This was the best workaround I could get.

In Windows I use SETSCREEN without problem, but I don't like the little windows which glbasic open in the start, and I would perfer it hided my startup. I also not want to setup a standard resoulution, but should open in its desktop resoulution instead.

Howover its a very good thread.

PS. its look like glbasic allready support the new ipad 2 new screen, that sound very great :-D.
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline mrplant

  • Mr. Polyvector
  • ***
  • Posts: 232
    • View Profile
Re: Multiplatform and Resolution Support.
« Reply #7 on: 2012-Mar-21 »
I take it you meant iPad 3rd gen above spacefractal - I have a little routine built into my game to report on current in use size of screen along with XScale YScale XOffset YOffset etc. so it was nice to see it report 2048x1536 on iPad 3 with X Scale of 2 and Y Scale of 2  :good:
For anyone wondering, the new screen on that device is awesome and the resolution is insane but GLBasic apps work fine! The good news is 1024x768 apps still look great on it - certainly not any worse than on iPad 1 or 2.

I used 320x240 (fullscreen) in win32 project settings and sent a test version to my tester and his laptop actually supported that res. lol so game ran at 320x240 instead of his native 1280x800. So I made it 320x240 non fullscreen this time in settings and it worked as expected - changed to 1280x800 fullscreen later.

However, like you mention it brings up an ugly small window at startup but I suppose I can live with that.

On Mac, I am just forcing 1024x768 fullscreen now just to get it working on most screens as I cannot get past this 2560x1440 issue at moment.
« Last Edit: 2012-Mar-21 by mrplant »

Offline mrplant

  • Mr. Polyvector
  • ***
  • Posts: 232
    • View Profile
Re: Multiplatform and Resolution Support.
« Reply #8 on: 2012-Mar-21 »
Spacefractal wrote:

>On my mac I also have problems using SETSCREEN, which dosent set fullscreen at all, but a fullscreen windowed instead.

Same here - just i tend to get blank graphics onscreen after that.

MrTAToad

  • Guest
Re: Multiplatform and Resolution Support.
« Reply #9 on: 2012-Mar-22 »
Full screen on a Mac hasn't been possible unfortunately - Gernot did say why ages ago, but I can't remember what it was.

After a SETSCREEN, you must re-load all graphics, otherwise you do get white blocks.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10697
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Multiplatform and Resolution Support.
« Reply #10 on: 2012-Mar-22 »
I think you could go from fullscreen to windowed with setscreen on the Mac. See my Tooyan game.