Differences in compiling on a PC or Mac.

BlitzMax Forums/BlitzMax Programming/Differences in compiling on a PC or Mac.

Xerra(Posted 2015) [#1]
I've recently been sharing a game I've been working on with a friend so we can brainstorm stuff and test things. He runs on a Mac system and I use a PC so until now he's been running a windows emulator to test it but he has BlitzMax so we decided it would be a good idea for him to compile the source code from his side on the Mac so he doesn't need to mess about like this.

I basically gave him the almost complete game including file structure for the assets so he can compile himself. Everything gets incbin'd into the main executable when it's compiled but he's unable to run it at present because of our lack of knowledge of each others platforms, it appears.

Mac's don't use DirectX so I'm going to have to switch the game to running with OpenGL as a first change and I'm looking to find out if there's anything else I need to do differently as well to ensure it compiles on both platforms?

As I say he will compile it on his Mac and I compile on Windows so we're not trying to do anything clever like me creating a Mac binary for him.

Anyone with Mac experience here able to advise me? I did some searching but couldn't find any specific guidelines on this.

Thanks.


Arska(Posted 2015) [#2]
If it goes like in Linux i have this in my project:
' ENABLE THESE WHEN BUILDING LINUX!
Rem
Framework BRL.Retro
Import BRL.Standardio
Import BRL.Font
Import BRL.GNet
Import BRL.Max2D
Import BRL.Audio
Import BRL.Threads
Import BRL.Math
Import BRL.Random
Import BRL.Glmax2d
Import BRL.Stream
Import BRL.System
Import BRL.Timer
Import BRL.httpstream
Import BRL.polledinput
Import BRL.keycodes
Import BRL.reflection
Import BRL.retro
Import BRL.Graphics
Import BRL.pngloader
Import BRL.wavloader
Import BRL.Blitz
Import BRL.OpenALAudio
End Rem


When i compile for Windows i have those commented out. In Linux is won't compile without those. I also had this problem with fonts when i made my Linux build:
http://www.blitzmax.com/Community/posts.php?topic=104064

But i don't know anything about how it goes Mac side, but i am assuming it's not so different from Linux.


Derron(Posted 2015) [#3]
For Linux and Mac you will use "OpenGL".

Just use "conditionals" for such things:

?Win32
SetGraphicsDriver D3D7Max2DDriver()
'or : SetGraphicsDriver D3D9Max2DDriver()
?not Win32
SetGraphicsDriver GLMax2DDriver()
?


On Linux you only need this big bunch of imports because of the framework-command you use.

framework: instead of using everything, you just include "BRL.Retro" plus the ones you import.

If you do this for win32 (or all) too, then they also need these imports.

Pay attention that you eg. "import brl.retro" albeit you already "framework" it.

PS: Windows-Users tend to use "\" in their paths ... use "/" on all platforms and you will have less trouble.

bye
Ron


Xerra(Posted 2015) [#4]
Thank you, Ron. I remember you reminding me about the filepath "/" "\" because I'd done it incorrectly before but couldn't find the original thread to remind myself which way round it was.

Code will be compiled on OSX 10, not Linux, so , judging by what you have written there I can use framework assistant on my code to give me the OpenGL and DirectX versions or just use the SetGraphics condition code you have there and the compiler will just pull in whatever modules i'm using commands from?

I know it won't be as optimized as weeding out stuff that's not in use but that could be done on the last build so I wouldn't need to change the code at all until then, no matter what machine it's being compiled on.

I hope that makes sense and I'm grateful for your advice.


Brucey(Posted 2015) [#5]
If it goes like in Linux i have this in my project

Good grief. Talk about over-kill...

If you are going to manually have all of those, you are just as well not bothering with using Framework at all, as the majority of those are redundant.


I generally start with Graphics, and add whatever else I'm using...
eg.
Framework BRL.GLMax2D ' for Max2D on GL

' loading images?
Import BRL.PNGLoader
Import BRL.JPGLoader

' sounds and music?
Import BRL.FreeAudioAudio ' sound driver
Import BRL.OggLoader

' file stuff?
Import BRL.FileSystem

' Random numbers?
Import BRL.Random



Derron(Posted 2015) [#6]
Framework assistant checks your code files and tries to see what elements you use - and therefor what modules to include in which file.

@opengl directx

?Win32
print "this is only printed on windows"
?not Win32
print "this is printed on everything but windows"
?Linux
print "This is only printed on linux"
?MacOs
print "this is printed on mac"
?
print "printed on all OS"


Now when setting a special graphics driver (which might not be needed - just in the case that you eg want to support more than one render engine on the OS - eg. dx + opengl on Windows, or bufferedGL + GL on linux) my sample code just did that depending on the OS of the compilating OS.

To make it more complete you would only import drivers you want:

Import BRL.GLMax2D
?Win32
Import BRL.D3D9Max2D
Import BRL.D3D7Max2D
?


... this code imports OpenGL for all OS and DX7/9 only for Windows builds.


bye
Ron


Xerra(Posted 2015) [#7]
Did some test runs on a clean install his side last night. Got it working without too much trouble.

Ironically it worked straight away if I stripped out all the framework and import calls which is fine for now but obviously can be streamlined later on.

Kind of makes me want to own a Mac as well as a PC now :)


Derron(Posted 2015) [#8]
Like said: without "framework" you include all modules "brl.mod" offers. This allows for faster prototyping but adds to overall binary filesize.

But you already recognized that adding it in "later on" will be easy enough (with "Framework Assistant" - by hand it can get really complex if you do not remember your code that well).


bye
Ron