Getting DirectX 8.1 to Work with Dev-C++
by Sherman Chin


ADVERTISEMENT

Getting DirectX 8.1 to Work with Dev-C++ 4.9.8.1
by Sherman Chin

I have noticed that many people would like to know how to use DirectX with Dev-C++ because the beta version of Dev-C++ does not seem to work with DirectX very well until you do some tweaking and the official Dev-C++ site itself does not provide much help. So, I will write about how to get the free Dev-C++ compiler to work with DirectX 8.1 and thus, provide the user with a major tool that is needed to code state-of-the-art games . Now, even my game engine (www.Sherman3D.net/download/files/VFVer1.zip) is fully compilable in Dev-C++ 4.9.8.1.

Want to know how? Then follow these easy steps (they might look simple now but it took a lot of trial and error):

  1. Install Dev-C++

  2. Use the "Check for Updates/Packages" option in the Tools menu.

  3. Download the Direct9 package (which also includes DirectX 8.1)

  4. Select the "Project Options" item from the Project menu. Click on the Parameters tab.

  5. In the "Linker" section, click on "Add Library or Object" and add the necessary library files for DirectX. Here is what my list looks like:
    -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32
    ../../../Dev-Cpp/lib/libdsound.a
    ../../../Dev-Cpp/lib/libdxguid.a
    ../../../Dev-Cpp/lib/libd3d8.a
    ../../../Dev-Cpp/lib/libd3dx8d.a
    ../../../Dev-Cpp/lib/libd3dxof.a
    ../../../Dev-Cpp/lib/libdplayx.a
    ../../../Dev-Cpp/lib/libwinmm.a
    ../../../Dev-Cpp/lib/libdxapi.a
    ../../../Dev-Cpp/lib/libwsock32.a
    ../../../Dev-Cpp/lib/libdinput8.a
    ../../../Dev-Cpp/lib/dinput.lib
    ../../../Dev-Cpp/lib/strmiids.lib
    

    As you can see, I am using Direct3D, DirectSound, DirectPlay, DirectInput and DirectShow. There are a few other necessary Windows libraries as well. I also added dinput.lib from the Microsoft DirectX 8.1 SDK (download it from Microsoft's site) because the one included with Dev-C++ (libdinput.a) seems to be missing some required data formats. The strmiids.lib, a DirectShow library for playing cutscenes, is not present in Dev-C++ so I added it from the DirectX 8.1 SDK as well.

  6. You are bound to run into compile time errors as the *.a DirectX library files that come with Dev-C++ have some typo errors in them. They are usually quite easy to fix though. Here is an example:
    Error message: something or other already defined in example.h
    Reason: #ifdef _EXAMPLE_
    Correction: #ifdef _EXAMPLE_H
    

    I can't really remember the exact typos as I corrected all of them without keeping the original files.

    In dxfile.h, delete the last line.
    In dmdls.h, change #ifndef MAKE_FOURCC to #ifndef MAKEFOURCC
    In dmdls.h, change WLOOP[1] to Wloop[1];
    In strmif.h, change #ifndef _WINGDI_ to #ifndef _WINGDI_H

  7. The biggest problem for me was getting DirectShow to work. First of all, comment out all the VMR stuff in strmif.h. I seem to get a GUID conflict if I don't. So just comment out lines 20551-20556, 28733-28759, 28759 till 28945. It is going to be a tedious process as there are many /**/ in between and you need to do a // for each line lest you miss out one of those #endif's like I originally did >_<.

  8. Another DirectShow problem is that you need to include atlbase.h to for automatic conversions from char to wchar but Dev-C++ doesn't come with atlbase.h. I did the filename conversion manually using a Win32 function. Replace wcscpy(wFileName, lpszMedia); (the function that is used by the DirectShow examples in the SDK) with
       MultiByteToWideChar(CP_ACP    ,     // code page
                           MB_PRECOMPOSED, // character-type options
                           lpszMedia,      // address of string to map
                           -1,             // number of characters in string
                           wFileName,      // address of wide-character buffer
                           MAX_PATH        // size of buffer);
    
  9. Dev-C++ doesn't seem to support the allocation of memory space with the "new" command using a variable for the size of memory to allocate. So, if you have something like this:

    m_Polygons = new sPolygon[m_NumPolygons]();

    Replace it with:

    (void*)m_Polygons = malloc(m_NumPolygons*sizeof(sPolygon));

  10. Dev-C++ uses the debug libraries of DirectX so please put d3dx8d.dll (which can be found in the DLL subdirectory of Dev-C++) in your program's directory when you distribute it.

  11. If you are using Windows resource files (*.rc), make sure to include "windows.h" in the resource file itself and remove any reference to "afxres.h". Open the resource header file, "resource.h" and write a definition for IDC_STATIC in the list.

There might be some other minor complications when using Dev-C++ with DirectX 8.1 so please post your questions at http://forum.Sherman3D.com and I will try to help the best I can.

Discuss this article in the forums


Date this article was posted to GameDev.net: 3/16/2004
(Note that this date does not necessarily correspond to the date the article was written)

See Also:
General

© 1999-2011 Gamedev.net. All rights reserved. Terms of Use Privacy Policy
Comments? Questions? Feedback? Click here!