2009/04/25

Using DirectX from Haskell


I try to use DirectX from Haskell. I heard that there were a bindings made by Esa Ilari Vuokko. I got archive, but I can't found the homepage or repositry now, archive only. Anyway, I try to use that bindins.

Prepare


This library are for MinGW/MSYS, and need transformation DirectX library for MinGW:
cd $DXSDK
mkdir Mingw
cd Mingw
cp ../Lib/x86/*.lib .
rm DxErr*.lib
ls | xargs -n 1 reimp


Build


When I tried to compile Setup.hs, raised compile error. The library was made on GHC 6.4, and Its need to be change:
 main = defaultMainWithHooks defaultUserHooks{preConf=conf, postConf=ok}
where
- ok _ _ _ _ = return ExitSuccess
+ ok _ _ _ _ = return ()


Building base


When 'install', raise no 'LICENSE' file error. Copy it from root.

Building d3d


Need change d3d/DirectX9/D3D/Utility/Init.hs:
{- Comment out:
import Graphics.Win32 ( WindowClosure, HWND, mkClassName, loadIcon,
, loadCursor, createSolidBrush, rgb, registerClass
, showWindow, updateWindow, sendMessage, WPARAM
, LPARAM, LRESULT, WindowMessage, defWindowProc
, createWindow, getMessage, translateMessage
, dispatchMessage, allocaMessage )
import Graphics.Win32 ( iDI_APPLICATION, iDC_ARROW, cS_VREDRAW, cS_HREDRAW
, wS_OVERLAPPEDWINDOW, sW_SHOWNORMAL, wM_DESTROY
, wM_QUIT, wM_KEYDOWN, vK_ESCAPE )
-}
import Graphics.Win32


Building d3dx


No problems.

Make test application


Ok, the library was installed. I had tried making DirectX's Tutorial 2: Rendering Vertices:

I got it! I want to make more sample.

4 comments:

snk_kid said...

Hi, this is nice, where can we find the bindings!!! It would be cool if they where committed to hackage.

mokehehe said...

The bindings made by Esa Ilari Vuokko. I can't find it on the Internet now. The license is BSD, so I can put modifier version, but I don't know how to do...

Don Stewart said...

@mokehehe just ask for an account, http://hackage.haskell.org/packages/accounts.html

Or do you need help with cabal?

mokehehe said...

Thank you, Don. I will try to get account.