Wednesday, August 12, 2009

Mingw + DirectX

I am currently a student at University of Illinois, Chicago doing masters in Computer Science with focus on graphics programming. I decided to learn directx and what could be a better way to do that other than programming it?. I have microsoft Visual c++ installed on my system. But I am a big fan of g++. Hence I decided to do a small project with directx graphics and mingw compiler.

Trouble starts here. There is very little information on the internet about combining directX and mingw. Most of the users seem to use DevCPP or visual c++. Anyways without losing hope, I searched and found this useful website by link. Having this page as foundation I started the installation process. I thought to myself "what if there is little or no information about this topic on the net? I will experiment and write a blog about it" and here it goes.

I already have mingw's latest version. To learn more about Mingw with Opengl please visit my "Mingw + glsl" blog. I also have mingw utilities to use the reimp tool. Now reimp tool is used to convert *.lib files to Mingw compatible *.a files.

Next I downloaded directx sdk for windows Vista ( And yeah I have Vista) . Installed directx to C:\Program Files\Microsoft DirectX SDK (March 2009). Now to make directx libraries compatible with Mingw, I used reimp tool to convert all the *.lib files of C:\Program Files\Microsoft DirectX SDK (March 2009)\Lib\x64 to *.a files. I moved those reimp'ed files from to C:\MinGW\lib\directx. Created a new folder directx under lib for directx libraries.

Then I moved header files (*.h) files from C:\Program Files\Microsoft DirectX SDK (March 2009)\Include to C:\MinGW\include\directx. Directx folder will not be there under include, so created one.

Now in the program, include the header file as #include and while running compile command include the library as -ld3d9 for e.g:
g++ demo.cpp -ld3d9

I ran my first directX "hello world" sorta program from http://www.directxtutorial.com/ and it compiled and ran successfully. looking forward to learn more about DirectX

hope this piece of information helps you with g++ and DirecX combination.