Jump to content
  • Advertisement
  • 03/16/04 06:15 PM
    Sign in to follow this  

    Getting DirectX 8.1 to Work with Dev-C++

    Graphics and GPU Programming

    Myopic Rhino

    Getting DirectX 8.1 to Work with Dev-C++
    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++

    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

      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.

      Report Article
    Sign in to follow this  

    User Feedback

    There are no comments to display.

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!