PDA

View Full Version : Phoenix, Asphyre or Andorra on Mac OS



wagenheimer
25-07-2009, 01:31 AM
Somebody here get some success on running Phoenix, Asphyre or Andorra on Mac Os?

- Andorra 2D, it compiles, but when I did run it shows nothing.
- Phoenix, it almost compiles, I did get Linker error.
- Asphyre, still need some conversion to become Linux/Mac Os compatible.

Anybody here have some success with some of this engines in Mac Os?

igel457
27-07-2009, 09:38 AM
Andorra 2D should work if you use the GLFW or SDL windowframework (the LCL TOpenGLContext, which is used by default does not work on MacOS, if I'm well informed).

Information about how to use other "windowframeworks" can be found in the "SimpleNoVCL" demo. Simply include "AdSDL" or "AdGLFW" instead of "AdStdWindow".

For me it would be very nice to know whether Andorra 2D runs on MacOS as I don't own a Mac (and don't plan to obtain one...).

Stoney
29-07-2009, 09:26 PM
Aspyhre won't work on a Mac, because as far as I know, Aspyre just uses DirectX and DirectX is Windows-only.



Andorra 2D should work if you use the GLFW or SDL windowframework (the LCL TOpenGLContext, which is used by default does not work on MacOS, if I'm well informed).

Information about how to use other "windowframeworks" can be found in the "SimpleNoVCL" demo. Simply include "AdSDL" or "AdGLFW" instead of "AdStdWindow".

For me it would be very nice to know whether Andorra 2D runs on MacOS as I don't own a Mac (and don't plan to obtain one...).


GLFW won't work by default. You need to modify following lines in the glfw.pas (Line 356f.). Originally, it should look like this:


const
{$IFDEF WIN32}
DLLNAME = 'glfw.dll';
{$ELSE}
DLLNAME = 'libglfw.so';
{$ENDIF}

Now it need to look like this:


const
{$IFDEF WIN32}
DLLNAME = 'glfw.dll';
{$ELSE}
{$IFDEF DARWIN}
DLLNAME = 'libglfw.dylib';
{$ELSE}
DLLNAME = 'libglfw.so';
{$ENDIF}
{$ENDIF}

Now you need to get libglfw.dylib. There are two possibilites to do that: Install Fink and download libglfw.dylib and then configure to link against /sw/lib (if that's the directory where you put Fink) or download the source package from the GLFW homepage and compile it yourself. (You need to link against the library, of course.)
When deploying your application, don't forget to leave the path to your library relative or others can't use your application if they don't have Fink installed.
(The better way would be to build a GLFW.framework, I guess, it should work like described above, but I couldn't test it yet.)

As for Andorra2D, I tried a few things, but I couldn't get it to work. Yet. I will try harder once my exams are over. :)

Phoenix2D should work with the fix described in this post, but I wouldn't recommand to use GLFW on a Mac, because it uses the old Carbon interface, which is an old artefact from Mac OS 9 - times and is still supported in Snow Leopard, but who knows, what will happen with Carbon in Mac OS 10.7?
Furthermore, the GLFW Object Pascal port hasn't been updated since 2005 if I recall correctly.

The safest bet is to use SDL (and/or OpenGL) which uses Cocoa (introduced with Mac OS X and a lot more future-proof than Carbon). This is the combination I'm using at the moment and built a little framework around it, you can check some of the games on my blog and recently my framework has been used for a semi-commercial product.
I'm not quite sure if my framework would fit your needs since I designed it espacially for prototyping and rapid game development.


Update: I tried to port Phoenix in the last hours. Unfortunately without any success and tried the two latest beta versions. There are following problems:
- dglOpenGL.pas needs to be modified like described here: http://delphigl.com/forum/viewtopic.php?t=6872&highlight=mac (last post)
- The FreeImage Delphi Wrapper only supports Windows and is not designed to be platform-independant, there are too many dependencies on Windows.pas
- Also there is no equivalent for getTickCount, so phxTimer won't work

Andreaz
30-07-2009, 09:41 AM
Phoenix2D should work with the fix described in this post, but I wouldn't recommand to use GLFW on a Mac, because it uses the old Carbon interface, which is an old artefact from Mac OS 9 - times and is still supported in Snow Leopard, but who knows, what will happen with Carbon in Mac OS 10.7?
Furthermore, the GLFW Object Pascal port hasn't been updated since 2005 if I recall correctly.

The safest bet is to use SDL (and/or OpenGL) which uses Cocoa (introduced with Mac OS X and a lot more future-proof than Carbon). This is the combination I'm using at the moment and built a little framework around it, you can check some of the games on my blog and recently my framework has been used for a semi-commercial product.
I'm not quite sure if my framework would fit your needs since I designed it espacially for prototyping and rapid game development.


I have added a SDL renderer to Phoenix in the latest version (the demo 13_Device.SDL), if you feel like it test it out ;)
http://phoenixlib.net/files/Phoenix%202009-07-30.7z

It uses GraphicEx for the image loading so no need for Freeimage.dll either.

pstudio
31-07-2009, 03:42 PM
Hi Andreaz,
I tried out the latest Phoenix and it is looking great.

However I'm having some trouble using it with Turbo Delphi on Windows. If I try and run and debug the Template example I get an access violation. But if I just build it and run it through Windows it works fine. Have you experienced any like that? The previous versions of Phoenix didn't have this problem.

EDIT:

It turns out the access violation happens when the OGL renderer calls glfwOpenWindow() which seems pretty strange to me.

I think I'll move this to it's own topic since it is a bit offtopic.

Stoney
01-08-2009, 08:11 PM
I clearly underestimated the amount of time it would take to port one of these engines to Mac OS X.
But it's not all bad news, I updated the GLFW header from API version 2.5 to 2.6 and it's now cross-platform, works with Delphi and FreePascal on Windows, Linux and most important Mac OS X. Furthermore, I modified the dglOpenGL header to work correctly with GLFW on Linux and Mac OS X.
I also converted the Mipmaps example from C to Object Pascal.
Take a look at my blog post (http://freeze-dev.de/blog/?p=310) or download the updated glfw.pas here (http://freeze-dev.de/blog/?download=Lib.GLFW.Pascal).

wagenheimer
07-08-2009, 10:59 PM
Hi Stoney!

Have you any success in making the Phoenix run in Mac OS??? I'm still with some big problems...

There are a solution for the GetTickCount Problem.

http://forum.lazarus.freepascal.org/index.php?topic=6099.0

Stoney
11-08-2009, 10:47 AM
I haven't had much success yet.
I've used Andreaz Phoenix version from 09-07-30. The problem with GetTickCount has been solved.

I tried to get the DeviceSDL sample to work.
But there are still some other problems:
- GraphicEx doesn't really work on Mac OS X:
-- The included JPG unit doesn't work
-- Asm calls can't be used on Mac OS X (e.g. GraphicColor.pas)
-- The Convert16_8/Convert16_8Alpha for example won't work. Errors:


/Users/.../GraphicColor.pas(649,33) Error: Illegal qualifier
/Users/.../GraphicColor.pas(649,33) Hint: may be pointer dereference is missing
/Users/.../GraphicColor.pas(649,33) Error: Illegal expression
/Users/.../GraphicColor.pas(649,33) Fatal: Syntax error, ";" expected but "identifier R" found

-- Compression doesn't work

So, I tried to get an empty window to work. But still, I got a linker error:


Undefined symbols:
"_iconv_close", referenced from: _CWSTRING_FINITHREAD in cwstring.o _CWSTRING_FINITHREAD in cwstring.o
"WSRegisterMenuItem", referenced from: _WSMENUS_REGISTERMENUITEM in wsmenus.o
"WSRegisterHintWindow", referenced from: _WSFORMS_REGISTERHINTWINDOW in wsforms.o
"WSRegisterPopupMenu", referenced from: _WSMENUS_REGISTERPOPUPMENU in wsmenus.o
"WSRegisterWinControl", referenced from: _WSCONTROLS_REGISTERWINCONTROL in wscontrols.o
"WSRegisterCustomForm", referenced from: _WSFORMS_REGISTERCUSTOMFORM in wsforms.o
"WSRegisterMainMenu", referenced from: _WSMENUS_REGISTERMAINMENU in wsmenus.o
"WSRegisterControl", referenced from: _WSCONTROLS_REGISTERCONTROL in wscontrols.o
"WSRegisterCustomImageList", referenced from: _WSIMGLIST_REGISTERCUSTOMIMAGELIST in wsimglist.o
"WSRegisterCustomControl", referenced from: _WSCONTROLS_REGISTERCUSTOMCONTROL in wscontrols.o
"_iconv_open", referenced from: _CWSTRING_INITTHREAD in cwstring.o _CWSTRING_INITTHREAD in cwstring.o
"WSRegisterGraphicControl", referenced from: _WSCONTROLS_REGISTERGRAPHICCONTROL in wscontrols.o
"WSRegisterCustomFrame", referenced from: _WSFORMS_REGISTERCUSTOMFRAME in wsforms.o
"WSRegisterScrollBox", referenced from: _WSFORMS_REGISTERSCROLLBOX in wsforms.o
"_iconv", referenced from: _CWSTRING_WIDE2ANSIMOVE$PWIDECHAR$ANSISTRING$LONGI NT in cwstring.o _CWSTRING_WIDE2ANSIMOVE$PWIDECHAR$ANSISTRING$LONGI NT in cwstring.o _CWSTRING_ANSI2WIDEMOVE$PCHAR$WIDESTRING$LONGINT in cwstring.o _CWSTRING_ANSI2WIDEMOVE$PCHAR$WIDESTRING$LONGINT in cwstring.o
"WSRegisterMenu", referenced from: _WSMENUS_REGISTERMENU in wsmenus.o
"WSRegisterScrollingWinControl", referenced from: _WSFORMS_REGISTERSCROLLINGWINCONTROL in wsforms.o
"WSRegisterDragImageList", referenced from: _WSCONTROLS_REGISTERDRAGIMAGELIST in wscontrols.o
ld: symbol(s) not found
Error: Error while linking

So you need to add the unit Interfaces in the DeviceSDL.dpr, but still some errors left:


Undefined symbols:
"_iconv_close", referenced from: _CWSTRING_FINITHREAD in cwstring.o _CWSTRING_FINITHREAD in cwstring.o
"_iconv_open", referenced from: _CWSTRING_INITTHREAD in cwstring.o _CWSTRING_INITTHREAD in cwstring.o
"_iconv", referenced from: _CWSTRING_WIDE2ANSIMOVE$PWIDECHAR$ANSISTRING$LONGI NT in cwstring.o _CWSTRING_WIDE2ANSIMOVE$PWIDECHAR$ANSISTRING$LONGI NT in cwstring.o _CWSTRING_ANSI2WIDEMOVE$PCHAR$WIDESTRING$LONGINT in cwstring.o _CWSTRING_ANSI2WIDEMOVE$PCHAR$WIDESTRING$LONGINT in cwstring.o
ld: symbol(s) not found
Error: Error while linking

And that's were I'm stuck right now. The curious part is, libiconv is installed on my machine and I linked to it.

Maybe it's a bug because I used a daily snapshot of Lazarus, but for some reason I can't properly uninstall Lazarus on Mac OS X and if I just replace my daily snapshot with the old 0.9.26 Lazarus, Lazarus won't start.

Traveler
11-08-2009, 11:30 AM
Hi Stoney, I've modified your reply so that the pascal code becomes more clear.

Andreaz
12-08-2009, 07:34 AM
Could it be something like this bug that we have bumped into?

http://bugs.freepascal.org/view.php?id=11565

wagenheimer
21-08-2009, 11:07 PM
Anybody have any news progress on this?

Stoney
11-09-2009, 09:51 PM
Allright, I got an empty window to work with Phoenix using the SDLDevice example.
Step-by-step:
1. Download and install Fink from http://www.finkproject.org/
2. Install the sdl package through Fink (Open a terminal and type "fink install sdl" (without ") and enter your password.)
3. Download and extract the Phoenix file Andreaz posted in this thread.
4. Apply the dglOpenGL.pas fixes from http://delphigl.com/forum/viewtopic.php?t=6872&highlight=mac or download the latest GLFW.pas from either this thread or my blog and replace the dglOpenGL.pas unit.
5. Rename phxOpenGL.SDL.pas to phxOpenGL_SDL.pas (in /inc). Open the unit and change "unit phxOpenGL.SDL" to "unit phxOpenGL_SDL".
6. Open the DeviceSDL.dpr with Lazaras (it is located in /demos/13_DeviceSDL). I used the latest daily Lazarus and FreePascal snapshots.
7. Add the following lines to the DeviceSDL.dpr (best between progam and uses):

{$IFDEF FPC}
{$IFDEF DARWIN}
{$linklib gcc}
{$linklib SDLmain}
{$ENDIF}
{$ENDIF}

8. Remove any references to phxGraphicEx or phxFreeImage (both in the dpr-File and in Main.pas)
9. Remove (or just add // in front of the line) any reference to Image and Font.
10. Open "Project | Compiler settings" and click on "Linker" on the left. Click on the checkbox in settings and add the following line:


-L/usr/lib -L/usr/X11R6/lib -L/sw/lib -lSDL

11. Click on Run and the project compiles and you can see an empty window. Yeah. :)

Additional notes:
- You can link against the SDL framework which is better way to go, because deploying the application is much easier that way, but for some reason when linked against the framework the application produces AV when it's being closed.
- The generated executable is about 20 MB big. Using strip and upx shrinks the executable to about 1,2 MB.

Using FreeImage doesn't work because there are too many dependencies to Windows. So I removed the reference to the windows unit and implemented PRGBQuad, PBITMAPINFOHEADER and PBITMAPINFO as suggested by FreeImage.h
When try to compile with this changes, following errors occur:

phxFreeImage.pas:405:junk `@4$stub' after expression
phxFreeImage.pas:741:junk `@4$stub' after expression
phxFreeImage.pas:746:junk `@4$stub' after expression
phxFreeImage.pas:751:junk `@4$stub' after expression
phxFreeImage.pas:756:junk `@4$stub' after expression
phxFreeImage.pas:762:junk `@4$stub' after expression
phxFreeImage.pas:766:junk `@4$stub' after expression
phxFreeImage.pas:803:junk `@4$stub' after expression
phxFreeImage.pas:900:junk `@4$stub' after expression
phxFreeImage.pas:989:junk `@4$stub' after expression
phxFreeImage.pas:1111:junk `@24$stub' after expression
phxFreeImage.pas:1118:junk `@4$stub' after expression
phxFreeImage.pas:1124:junk `@4$stub' after expression
phxFreeImage.pas:1194:junk `@4$stub' after expression
phxFreeImage.pas:1212:junk `@24$stub' after expression
phxFreeImage.pas:1219:junk `@4$stub' after expression
phxFreeImage.pas:1225:junk `@4$stub' after expression
phxFreeImage.pas:1290:junk `@4$stub' after expression
phxFreeImage.pas:1308:junk `@24$stub' after expression
phxFreeImage.pas:1315:junk `@4$stub' after expression
phxFreeImage.pas:1321:junk `@4$stub' after expression
phxFreeImage.pas:1376:junk `@4$stub' after expression
phxFreeImage.pas:1449:junk `@12$stub' after expression
phxFreeImage.pas:1461:junk `@4$stub' after expression
phxFreeImage.pas:1471:junk `@4$stub' after expression
phxFreeImage.pas:1510:junk `@16$stub' after expression
phxFreeImage.pas:1524:junk `@4$stub' after expression
phxFreeImage.pas:1609:junk `@4$stub' after expression
phxFreeImage.pas:1635:junk `@4$stub' after expression
phxFreeImage.pas:1677:junk `@20$stub' after expression
phxFreeImage.pas:1681:junk `@4$stub' after expression
phxFreeImage.pas:1752:junk `@4$stub' after expression
phxFreeImage.pas:1756:junk `@4$stub' after expression
phxFreeImage.pas:2022:junk `@16$stub' after expression
phxFreeImage.pas:2035:junk `@4$stub' after expression
phxFreeImage.pas:2103:junk `@20$stub' after expression
phxFreeImage.pas:2107:junk `@4$stub' after expression
phxFreeImage.pas:2384:junk `@16$stub' after expression
phxFreeImage.pas:2397:junk `@4$stub' after expression
phxFreeImage.pas:2465:junk `@20$stub' after expression
phxFreeImage.pas:2469:junk `@4$stub' after expression
phxFreeImage.pas:2746:junk `@16$stub' after expression
phxFreeImage.pas:2759:junk `@4$stub' after expression
phxFreeImage.pas:2827:junk `@20$stub' after expression
phxFreeImage.pas:2831:junk `@4$stub' after expression
phxFreeImage.pas:3108:junk `@16$stub' after expression
phxFreeImage.pas:3121:junk `@4$stub' after expression
phxFreeImage.pas:3189:junk `@20$stub' after expression
phxFreeImage.pas:3193:junk `@4$stub' after expression
phxFreeImage.pas:4211:invalid character '_' in mnemonic
phxFreeImage.pas:4212:Rest of line ignored. 1st junk character valued 64 (@).
phxFreeImage.pas:4251:invalid character '_' in mnemonic
phxFreeImage.pas:4252:Rest of line ignored. 1st junk character valued 64 (@).
phxFreeImage.pas:4261:invalid character '_' in mnemonic
phxFreeImage.pas:4262:Rest of line ignored. 1st junk character valued 64 (@).
phxFreeImage.pas:4271:invalid character '_' in mnemonic
phxFreeImage.pas:4272:Rest of line ignored. 1st junk character valued 64 (@).
phxFreeImage.pas:4281:invalid character '_' in mnemonic
phxFreeImage.pas:4282:Rest of line ignored. 1st junk character valued 64 (@).
phxFreeImage.pas:4291:invalid character '_' in mnemonic
phxFreeImage.pas:4292:Rest of line ignored. 1st junk character valued 64 (@).
phxFreeImage.pas:4301:invalid character '_' in mnemonic
phxFreeImage.pas:4302:Rest of line ignored. 1st junk character valued 64 (@).
phxFreeImage.pas:4321:invalid character '_' in mnemonic
phxFreeImage.pas:4322:Rest of line ignored. 1st junk character valued 64 (@).
phxFreeImage.pas:4341:invalid character '_' in mnemonic
phxFreeImage.pas:4342:Rest of line ignored. 1st junk character valued 64 (@).
phxFreeImage.pas:4351:invalid character '_' in mnemonic
phxFreeImage.pas:4352:Rest of line ignored. 1st junk character valued 64 (@).
phxFreeImage.pas:4361:invalid character '_' in mnemonic
phxFreeImage.pas:4362:Rest of line ignored. 1st junk character valued 64 (@).
phxFreeImage.pas:4371:invalid character '_' in mnemonic
phxFreeImage.pas:4372:Rest of line ignored. 1st junk character valued 64 (@).
phxFreeImage.pas:4421:invalid character '_' in mnemonic
phxFreeImage.pas:4422:Rest of line ignored. 1st junk character valued 64 (@).
phxFreeImage.pas:4441:invalid character '_' in mnemonic
phxFreeImage.pas:4442:Rest of line ignored. 1st junk character valued 64 (@).
phxFreeImage.pas:4451:invalid character '_' in mnemonic
phxFreeImage.pas:4452:Rest of line ignored. 1st junk character valued 64 (@).
phxFreeImage.pas:4471:invalid character '_' in mnemonic
phxFreeImage.pas:4472:Rest of line ignored. 1st junk character valued 64 (@).
../../inc/phxFreeImage.pas(14,48) Error: Error while assembling exitcode 1
../../inc/phxFreeImage.pas(14,48) Fatal: There were 2 errors compiling module, stopping


I found a reference to phxSDL_image, but I couldn't find that unit in any Phoenix release. Is there a way to include SDL_image instead of FreeImage or GraphicEx?

Stoney
12-09-2009, 11:27 PM
Using the latest snapshot Phoenix is finally working on a Mac.
Here is the screenshot proof:
http://www.freeze-dev.de/images/phoenixonmac.jpg

There are still some fixes I need to apply, but it wouldn't take more than a few days.

wagenheimer
12-09-2009, 11:31 PM
What wonderful news!!! Keep on the good work!

Stoney
15-09-2009, 10:05 PM
Based on the latest Phoenix snapshot I've put together a little Mac OS demo. Download here (http://www.freeze-dev.de/files/PhoenixMacDemo.zip) (ca. 9 MB)

There is one bug which still annoys me: When I link against the frameworks, as soon as I close the application I get an access violation. Might it be connected to the fact that I use the Lazarus daily snapshots.

wagenheimer
16-09-2009, 03:05 AM
I tried everything but I still always get two kinds of erros:

- When I did try to compile with makefile : ld: library not found for -lgcc An error occurred while linking Error: Error while linking
- When i did compile in Lazarus IDE, it compiles, but It raises "Project Raised Exception Class:External : SIGTRAP.

I have the lastest SDL and GCC installed... I have MacOS SDK and IPHONE SDK installed.

Anybody else had success in compiling?

Stoney
17-09-2009, 02:40 AM
The SIGTRAP error is probably because the application is not linking against the Cocoa framework. See: http://www.gamedev.net/community/forums/topic.asp?topic_id=224420

I changed the necessary files and: Download here (http://www.freeze-dev.de/files/PhoenixMacDemoPatch.zip) (65 kB)
Just replace the files. After that, try again to compile. I really hope this does the trick.

wagenheimer
17-09-2009, 03:28 AM
It is working! It is working! =). You are my hero! Thank you very much!... It only compiles with ./build.sh, but it is working! =)

But, is there some problem with .jpg? My program crash when I try to load .jpg images!

And some .png are with changed colors!

Stoney
17-09-2009, 10:47 AM
Sorry, my bad.
I forgot to mention that you need move the images to the right position if you compile in Lazarus.

That's what the following lines in the main.pas are for:

// Path to data
const
{$IFDEF DARWIN}
// Keep the original path to /Contents/Resources in the .app - file
PATH = '../Resources/';
{$ELSE}
PATH = 'DemoRes\';
{$ENDIF}



The Mac OS applications are basically just a folder. Right-click on the application and click on "Show content" to show the contents of the application.
/Contents/Frameworks is where the frameworks should be stored if frameworks are needed
/Contents/MacOS is where the executable is
/Contents/Resources is where resources like icons, images, sounds should be stored

When you compile with Lazarus, you can see that Lazarus creates such an application.
You need to copy the Arial16.phxfnt and the tx09.png to /Contents/Resources of the application.
The compiled application should now find all files.

czar
17-09-2009, 07:47 PM
Wow this look pretty exciting. I am going to have to give it a go on my macbook this weekend.

wagenheimer
17-09-2009, 09:01 PM
Andreaz solved the problems with phxSDL_Image, and now Jpg and Png are working corectly!

Also he is adding lot of new impressive features to Phoenix! =)