Well, I already have at least some experience in cross-platform development. But that was done in C and for console applications only (very boring interface stuff).
Anyway, the problem is the following, On Windows I have to do this to get a screen (for drawing sprites):
Code: Select all
If Not (OpenWindow(0, 0, 0, 640, 480, "PureBasic", #PB_Window_SystemMenu | #PB_Window_ScreenCentered))
MessageRequester("Error", "Cannot initialize Window!", #PB_MessageRequester_Ok)
End
EndIf
If Not (OpenWindowedScreen(WindowID(0), 0, 0, 640, 480, 0, 0, 0))
MessageRequester("Information", "Cannot initialize Screen!", 0)
End
EndIf
While under Linux, SDL already provides a window, so I can simply do:
Code: Select all
If Not (OpenWindowedScreen(0, 0, 0, 640, 480, 0, 0, 0))
MessageRequester("Information", "Cannot initialize Screen!", 0)
End
EndIf
If I do the Linux way on Windows, I get a runtime error. If I do the Windows way on Linux, I get the SDL screen *plus* an additional App Window (you may want try it out). So I simply want to know "yeah, this is Windows" or "this is Linux" in order to have one piece of code (not the binary!) that compiles and runs on both platforms (skip the OS X part for now). In C one would use precompiler directives (#define / #ifdef / #endif etc.) for that.
So I have to check at compile time for the platform the executable is being build for. The first solution (compile time) works perfectly, while the other (runtime through OSVersion()) doesn't (error message on Linux is: there is no screen - debugging shows that neither code branch is used).
So, after testing, I found out that this does do the trick:
Code: Select all
If (#PB_Compiler_OS = #PB_OS_Windows)
If Not (OpenWindow(0, 0, 0, 640, 480, "PureBasic", #PB_Window_SystemMenu | #PB_Window_ScreenCentered))
MessageRequester("Error", "Cannot initialize Window!", #PB_MessageRequester_Ok)
End
EndIf
If Not (OpenWindowedScreen(WindowID(0), 0, 0, 640, 480, 0, 0, 0))
MessageRequester("Information", "Cannot initialize Screen!", 0)
End
EndIf
EndIf
If (#PB_Compiler_OS = #PB_OS_Linux)
If Not (OpenWindowedScreen(0, 0, 0, 640, 480, 0, 0, 0))
MessageRequester("Information", "Cannot initialize Screen!", 0)
End
EndIf
EndIf
Once again: thank you for being so kind to help me with this issue,