This was all well and good except it would help to have a game engine.
I choose Allegro for it being c based so much more easier to interface to D. (Bindings already exist).
My primary platform is Windows 7 64bit.
This was primarily because dmd (D's compiler) uses Microsofts toolchain for linking. This is rather nice thing for COFF support as it's linker (optilink) only support OMF and thats for 32bit only.
So this is all well and good but back to Allegro.
To use it you need a Microsoft compiled/linked version with the import libraries.
I am choosing to stick to dynamically linked for the time being but it shouldn't be too hard to reconfigure Visual studio to produce static libs for use.
Setup notes
A couple of the dependencies require and is recommended by MingW but this isn't the best thing in my case.
So it was a bit of work to get it play nicely with Visual Studio expsecially since some were only designed for 2005 version in mind (no 64bit).
Three tools are required to be used.
- NASM
- CMake
- Visual C++ (Visual Studio 2010).
For this you can use the paid versions or the express it doesn't really matter.
It may work for 2012 or 2008. I have not tested on either.
Make sure CMake and NASM is on your path.
Small note about NASM; to build FLAC you need to copy nasm.exe as nasmw.exe (this is historic legacy issue).
You don't need Visual Studio on your path. However when I run cmake-gui I always do it from the Visual Studio x64 Win64 Command Prompt. (This can be found under Microsoft Visual Studio 2010/Visual Studio Tools in the start menu).
Note about how I use CMake. I always create a directory called e.g. bin under the directory then call cmake-gui .. from within it. This makes so if you delete the bin directory you only remove the build configuration for your system nothing more. Binaries built is placed in another directory.
Here is a list of dependencies and where to get them.
I used the latest version of all libraries upon this writing.
(I didn't thoroughly test it against Allegro but it compiled so should be fine).
Before I say how to compile them (which goes against more common expectations).
The resulting binaries and include files need to go into this file structure:
- Allegro_source
- deps
- dumb
- include
- *.h
- lib
- dll
- flac
- include
- flac
- *.h
- lib
- dll
- freetype
- include
- ft2build.h
- freetype
- config
- *.h
- *.h
- lib
- dll
- vorbis
- include
- vorbis
- *.h
- lib
- dll
- ogg
- include
- ogg
- *.h
- lib
- dll
- openal
- include
- *.h
- lib
- dll
- physfs
- include
- *.h
- lib
- dll
- zlib
- include
- *.h
- lib
- dll
The lib directory will contains all static library files. Please note not all .lib files are static libraries, in fact there will also be import libraries for use like that.
You don't need to compile the dll's _but_ it would probably a good idea to.
The reason I have detailed this structure so much is because you will quite easily get errors like can't find include dir's or a library binary. This just helps prevent the former. If it occurs and its placed correctly then its a delete of the bin folder.
Build notes
On Allegro's community wiki there is a tutorial on how to compile on Windows 7 but I found this not complete; at least not for my situation.
This is more an additive upon it.
For a lot of the dependencies there is already build solutions ready to go for Visual Studio 2010.
If they do not, you can quite easily use one of the other older ones and convert it.
For CMake they are produced for you.
FLAC is a problem.
It uses inline assembly now the Visual C++ compiler in 64bit mode does not have this functionality.
But thanks to ScummVM we have a patch for this issue on the particular files.
I manually did the patching because it is rather simple in this case.
Essentially the part this is referring to (starting at line 152) now looks like this:
#if defined (_MSC_VER)/* OPT: an MSVC built-in would be better */static _inline FLAC__uint32 local_swap32_(FLAC__uint32 x){x = ((x<<8 amp="" x="" xff00ff00="">>8)&0x00FF00FF);8>return (x>>16) | (x<<16 blockquote="">Or well something like that ignoring formatting.}#ifdef _WIN64static void local_swap32_block_(FLAC__uint32 *start, FLAC__uint32 len){while (len--) {*start = local_swap32_(*start);++start;}}#elsestatic void local_swap32_block_(FLAC__uint32 *start, FLAC__uint32 len){__asm {mov edx, startmov ecx, lentest ecx, ecxloop1:jz done1mov eax, [edx]bswap eaxmov [edx], eaxadd edx, 4dec ecxjmp short loop1done1:}}#endif#endif16>
You also need to find and replace all instances of "FLAC__CPU_IA32", "FLAC__HAS_NASM" and "FLAC__USE_3DNOW" without quotes, with "FLAC__NO_ASM" remember to build with FLAC__HAS_NASM enabled (look on tool bar).I hope this helps someone in the future.This took me two days to work it out all out.Have fun!
No comments:
Post a Comment