How can I tell which platform my game is on?
BlitzMax Forums/BlitzMax Beginners Area/How can I tell which platform my game is on?
| ||
Is there a way to detect what platform my game is running on? Using graphics 800, 600, 0 doesn't work on my MacBook but graphics 800, 600, 32 does. Should I enumerate the modes then decide from that? |
| ||
Use the compiler directives ?macos, ?linux, ?win32. |
| ||
Setting 0 as the bitdepth should open your app in a window, as opposed to fullscreen. Which MacBook do you have, because that would work on my MacBook Pro and my older iBook. Also, it may also be useful to know that you can compile different sections of code depening on the processor family of the machine you're compiling on, especially if you want to make games for Intel and PPC based Macs. These directives are ?x86 for Intel/AMD and ?PPC for PowerPC. Don't forget to use a final ? to mark the end of any directive controlled section of code, thus. ?win32 ' code specific to Windows ?macos ' code sepcific to Mac (both Intel and PPC) ?linux ' code for Linux ? |
| ||
doesn't work on my MacBook That's because your graphics chip set only supports OpenGL in full screen - has nothing to do with MacOS. Should I enumerate the modes then decide from that? That, or leave the third parameter out entirely and let BlitzMAX decide for you. |
| ||
?win32 Graphics 800, 600 ?macos Graphics 800, 600, 32 ? works on my MacBook full screen and in a window on a PC. Graphics 800, 600 on its own doesn't do the right thing on my MacBook (nothing appears). |
| ||
I'm sorry. I didn't realize you where only developing for yourself. |
| ||
Macbook doesn't support windowed opengl?! |
| ||
Graphics 800, 600, 0 on a MacBook when you run it produces no window. The only thing you can do is hit the stop button. I checked with GraphicsModeExists and it returns true - but nothing actually appears. |
| ||
Graphics 800, 600, 0 on a MacBook when you run it produces no window. The only thing you can do is hit the stop button. I checked with GraphicsModeExists and it returns true - but nothing actually appears. |
| ||
Windowed mode works perfectly fine on my MacBook Pro. Also works with no problems on my older iBook. Is it a non-Pro MacBook you have? |
| ||
At the risk of sounding redundant, it depends on which kind of chip (and possibly driver) configuration you have in your computer. It has nothing to do with it being a Macbook. Some graphics chips only support hardware accelerated 3D graphics in full-screen mode. My old Acer Laptop doesn't do it either. |
| ||
Const Win:Int =0 Const Mac:int = 1 Const Lin:Int = 2 Global Platform:int ?win32 Platform= Win ?macos Platform=Mac ?linux Platform=Lin ? Select Platform Case Win Case Mac Case Lin Endselect |
| ||
H&K : Nice tip. Kinda obvious but not if you didn't think of it :-) |
| ||
The only problem with that method is that you end up with code for all three platforms within the same executable. |
| ||
I've got an Intel dual core MacBook with the integrated Intel graphics. |
| ||
@Grey, Just seemed strange to me that after 10 posts no one had actualy answered the question @Jazzie, Well I had assumed that the object was then to pass different parameters to the same code, so that you wouldnt actualy have different platform code. However, although Im not sure if you could ? selects cases, but if you could, then you can remove even those. |
| ||
Never heard of the GMA 950 not beeing able to use 3D windowed mode at 32bit and does not make sense why it should not be able to unless we would be talking of Vista. Perhaps some kind of effect enabled in your eye candy desktop on OSX which prevents it from using real 3D support? (intel chips might be no end chips *not low end* but at least GMA 900 and 950 are useable for the total bottom end tests) |
| ||
Well I had assumed that the object was then to pass different parameters to the same code, so that you wouldnt actualy have different platform code. ALL of the code between your Select..EndSelect section would get compiled into the executable, regardless of which platform it was being compiled on. So if you compiled on a Mac, the code for Windows and Linux would still be there, just never actually used. The compiler directives can be used absolutely anywhere. They just tell the compiler which section(s) of code to compile under a given circumstance, in this case, the platform. |
| ||
ALL of the code between your Select..EndSelect section would get compiled into the executable, regardless of which platform it was being compiled on. So if you compiled on a Mac, the code for Windows and Linux would still be there, just never actually used. Some people, here you are then.Const Win:Int =0 Const Mac:int = 1 Const Lin:Int = 2 Global Platform:int ?win32 Platform= Win ?macos Platform=Mac ?linux Platform=Lin ? Select Platform ?win32 Case Win ?macos Case Mac ?linux Case Lin ? EndselectI still think the point was simply to call the same functions but simply with different parameters depending on which platform you had identified. All he wanted was a way to know which parameters to pass to graphics, not to have a massive code section for each. And the actual question was "How can I tell which platform my game is on?", which was the Platform Global part of my code snippet, the select was just using it. What he wanted to be able to do was write the same code, that simply ran a little bit differently depending on the platform. My snippet seems to have lead you to think he will write diffent code for each platform, where as I was expecting somthing on the lines of Case win GoGame(1) Case Mac GoGame(2) etcObviously you or I would simply stick the different code in a ?? section, but the question, and then the implication of its use sudjested a different way whereby there is no "Three different codes for each platform", but rather one code that has knowlage of which platform its on. But ho um |