Skip to main content
GameDev.net gamedev.net
🔒 Locked

Going back to Dx7 with the dx9sdk

Started by Wicked Ewok Sep 17, 2005 at 2:05 PM 9 replies 3.7k views
Original Post
Wicked Ewok
Wicked Ewok
Hi I was wondering if it is possible to go back to Dx7 with the Dx9 SDK. I tried defining the DX Version before including the headers but d3d9xmath.h spews out 1000s of errors. I'm not sure what else I should do besides defining the DX Versions. Any help is appreciated. Thanks! -Marv
-=~''^''~=-.,Wicked,.-=~''^''~=-
CTar
CTar
Do you mean you want to use DX7, but include d3d9xmath.h or d3d9x.h? I'm not familiar with DirectX 7, but you should instead include d3d7xmath.h or d3d7x.h or whatever the file is called in DX7.
Wicked Ewok
Wicked Ewok
Hi Ctar, I don't seem to have d3dx7.h. The new SDKs provide just the 9 versions. I still include d3d9.h because it has version checks inside if I predefine the version number. But looking at d3dx9.h, it doesn't seem to have version checks. I'm confused:(

Best,
-Marv
-=~''^''~=-.,Wicked,.-=~''^''~=-
MustEatYemen
MustEatYemen
Your semi out of luck. How that is all setup is that the runtimes have the hooks for all the previous DirectX code (so if you have DirectX 9 installed you can still run Direct X 6 code, not sure how far back they've maintained backwards compatibilty anymore as they've made some random changes)

Anyways, since Microsoft no longer distrubtes the SDK's for previous versions of DirectX (they never did, and it really didn't matter until they got around to removing DirectDraw and moved DirectShow to god knows where).

Your kinda stuck trying to locate a earlier version of the SDK, which won't be easy. Unless you really really want to use DirectDraw, you might as well move up to Direct X 9. There is ways to get DirectX 9 to work under Visual C++ 6.0, just don't remember the link off the top of my head.
-Scott
Wicked Ewok
Wicked Ewok
Hi MustEatYemen, that sounds very discouraging. I'm trying to go back to DirectX7 or 8 because XP ships with Dx8, but not Dx9. I figured since I wasn't using anything special for my game I didn't have to use 9. I think at the least, if I don't use the D3DX libraries I would be fine, but it would make for a lot more work. The good thing is that d3d9.h seems to define the correct interface and hooks for the version you specify. When you say there are ways to get DirectX9 working under visual C++ 6.0, do you actually mean DirectX8 or 7? Thanks, I'll try to locate a copy of directx 7 in the meantime.

Best,
Marv
-=~''^''~=-.,Wicked,.-=~''^''~=-
S1CA
S1CA
The DirectX 9 SDK contains only the newest D3DX header and library files; it's the same with the SDK sample code, framework and tools (the download size would increase year on year if they didn't strip out the legacy stuff).

For the core components of DirectX (i.e. not the extensions/helpers), the DX9 SDK contains the current library files and the previous library files (e.g. D3D8, DInput7, etc).

The SDK does however contain the header files for all previous core components (the version number extension to the filenames was introduced in DirectX 8.0 - D3DX in DX7 was simply called d3dx.h).


The DirectX runtimes will support *all* previous interfaces (kinda the point of using COM).



As for developing Direct3D 7 code:

- if you don't need D3DX, you can use the D3D7 header files in the DirectX 9 SDK and use LoadLibrary and GetProcAddress (or make your own importlibs for the DLLs) to get at the necessary DLL exports. The DirectX 9 version of dxguid.lib still has the GUIDs/IIDs for previous interface versions.

- obtain the DirectX 7 SDK and copy the contents of the include and lib folders into the include and lib folders of your DirectX 9 SDK installation. Obtaining the full DX7 SDK would be preferable since you'll have the sample source code and documentation to refer to. ISTR somebody posted a link to someones online repository of DirectX SDKs (not an official one).
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
S1CA
S1CA
Quote:
Original post by Wicked Ewok
Hi MustEatYemen, that sounds very discouraging. I'm trying to go back to DirectX7 or 8 because XP ships with Dx8, but not Dx9. I figured since I wasn't using anything special for my game I didn't have to use 9. I think at the least, if I don't use the D3DX libraries I would be fine, but it would make for a lot more work. The good thing is that d3d9.h seems to define the correct interface and hooks for the version you specify. When you say there are ways to get DirectX9 working under visual C++ 6.0, do you actually mean DirectX8 or 7? Thanks, I'll try to locate a copy of directx 7 in the meantime.

Best,
Marv


I'd definately recommend DirectX 8 over DirectX 7. With Direct3D7, you also need to know DirectDraw and have to do a lot more setup and maintenence work to display anything.

Each version of the SDK released does tend to contain optimizations, bug fixes and security fixes compared to previous releases. Those fixes and optimizations are rarely retrospective because old products outside of Microsoft's control may be relying on those bugs being there (e.g. a D3D7 bug under Win2k caused performance problems with dynamic vertex buffers - many DX7 games written back then assume the bug is present and change behaviour accordingly).

Because of the improvements & fixes, even to basic features that have been present since DX1, using the newer SDK can still be beneficial, even if you don't use any of the new features. The main decision should really be "what D3D DDI level will my customers have in their graphics hardware drivers", if it's DX7, use D3D9; if it's DX6, D3D8 should be fine, if it's DX5, then you've a case for using D3D7. The other decision is compiler support - if you're still using MSVC 6 (Visual Studio 1997), then you may need to use an older SDK or upgrade your compiler.
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
MustEatYemen
MustEatYemen
Quote:
Original post by Wicked Ewok
Hi MustEatYemen, that sounds very discouraging. I'm trying to go back to DirectX7 or 8 because XP ships with Dx8, but not Dx9. I figured since I wasn't using anything special for my game I didn't have to use 9.


You can either bundle your game with the latest distrubtable copy of DirectX. Notice that many games ask you if you wish to install DirectX 9.0c when you install them.
or
Tell people who use your game to go to http://www.microsoft.com/windows/directx/default.aspx
and download a copy.

Most people running Windows XP will have DirectX 9.0c installed, iirc it was part of at least SP2, if not SP1.
-Scott
Wicked Ewok
Wicked Ewok
Hi S1CA and MustEatYemen, thanks for the info. The reason that I can't use DirectX9 right now is because I'm trying to appeal to casual gamers. Most of them haven't upgraded service packs, and typically have only the DirectX8 runtime. On top of that, I'm trying to keep my game download under 10MB, sodistributing the Dx9 runtime just won't be possible unfortunately. Still hunting for an old SDK version. And thanks for the advice S1CA, I'll use Dx8 instead of 7. Still no
luck finding either though.

Best,
Marv
-=~''^''~=-.,Wicked,.-=~''^''~=-
Wicked Ewok
Wicked Ewok
Searching a little more using the actual exe file instead of "DirectX 7 SDK" or "DirectX 8 SDK" I was able to find a few sites such as:

http://ftp.ncnu.edu.tw/Windows/Collection/MultiMedia/DirectX8.0%20SDK/DX8/Dx8sdk.exe

which has the dx8 sdk. Thanks again guys.

Best,
Marv
-=~''^''~=-.,Wicked,.-=~''^''~=-
daviangel
daviangel
As has already been said as long as you don't use any helper dx libraries even old dx 5 programs like the one below compile with latest directx sdk and visual c++ compiler:
#define NAME "Surface"#define TITLE "DirectDraw Surfaces"#define WIN32_LEAN_AND_MEAN#include <windows.h>#include <windowsx.h>#include <ddraw.h>LPDIRECTDRAW            lpDD;           // DirectDraw objectLPDIRECTDRAWSURFACE     lpDDSPrimary;   // DirectDraw primary surfaceBOOL LoadImage( LPDIRECTDRAWSURFACE lpDDS, LPSTR szImage ){    HBITMAP         hbm;    HDC             hdcImage = NULL;    HDC             hdcSurf  = NULL;    BOOL            bReturn  = FALSE;    DDSURFACEDESC   ddsd;    ZeroMemory( &ddsd, sizeof( ddsd ) );    ddsd.dwSize = sizeof( ddsd );    if ( FAILED( lpDDS->GetSurfaceDesc( &ddsd ) ) )	{        goto Exit;    }    // If the pixel format isn't some flavor of RGB, 	// we can't handle it.    if ( ( ddsd.ddpfPixelFormat.dwFlags != DDPF_RGB ) ||         ( ddsd.ddpfPixelFormat.dwRGBBitCount < 16 ) )    {        OutputDebugString( "Nonpalettized RGB mode required.\n" );        goto Exit;            }    // Try loading the image.    hbm = ( HBITMAP )LoadImage( NULL, szImage,             IMAGE_BITMAP, ddsd.dwWidth,             ddsd.dwHeight, LR_LOADFROMFILE | LR_CREATEDIBSECTION);    if ( hbm == NULL ) 	{        OutputDebugString("Couldn't find the resource.\n" );        goto Exit;    }    // Create a DC and select the image into it.    hdcImage = CreateCompatibleDC( NULL );    SelectObject( hdcImage, hbm );       // Get a DC for the surface.    if ( FAILED( lpDDS->GetDC( &hdcSurf ) ) )	{        OutputDebugString( "Couldn't get a DC.\n");        goto Exit;    }        // The BitBlt will perform format conversion as necessary.    if ( BitBlt( hdcSurf, 0, 0, ddsd.dwWidth, ddsd.dwHeight,                  hdcImage, 0, 0, SRCCOPY ) == FALSE ) 	{        OutputDebugString( "Blt failed.\n" );        goto Exit;    }    // Success.    bReturn = TRUE;    Exit:    // Clean up everything.    if ( hdcSurf )        lpDDS->ReleaseDC( hdcSurf );    if ( hdcImage )        DeleteDC( hdcImage );    if ( hbm )        DeleteObject( hbm );    return bReturn;}static void ReleaseObjects( void ){    if ( lpDD != NULL )    {        if ( lpDDSPrimary != NULL )        {            lpDDSPrimary->Release();            lpDDSPrimary = NULL;        }        lpDD->Release();        lpDD = NULL;    }}BOOL Fail( HWND hwnd,  char *szMsg ){    ReleaseObjects();	OutputDebugString( szMsg );    DestroyWindow( hwnd );    return FALSE;}long FAR PASCAL WindowProc( HWND hWnd, UINT message,                             WPARAM wParam, LPARAM lParam ){    switch ( message )    {		case WM_SETCURSOR:			SetCursor(NULL);	// Turn off the mouse cursor			return TRUE; 		case WM_KEYDOWN:			switch ( wParam )			{				case VK_ESCAPE:					PostMessage ( hWnd, WM_CLOSE, 0, 0 );					break;			}			break;		case WM_DESTROY:			ReleaseObjects();			PostQuitMessage( 0 );			break;		}    return DefWindowProc( hWnd, message, wParam, lParam );}static BOOL doInit( HINSTANCE hInstance, int nCmdShow ){    HWND                hwnd;    WNDCLASS            wc;    DDSURFACEDESC       ddsd;     // Set up and register window class    wc.style = CS_HREDRAW | CS_VREDRAW;    wc.lpfnWndProc = WindowProc;    wc.cbClsExtra = 0;    wc.cbWndExtra = 0;    wc.hInstance = hInstance;    wc.hIcon = LoadIcon( hInstance, IDI_APPLICATION );    wc.hCursor = LoadCursor( NULL, IDC_ARROW );    wc.hbrBackground = NULL;    wc.lpszMenuName = NAME;    wc.lpszClassName = NAME;    RegisterClass( &wc );        // Create a fullscreen window    hwnd = CreateWindowEx(        WS_EX_TOPMOST,        NAME,        TITLE,        WS_POPUP,        0, 0,        GetSystemMetrics( SM_CXSCREEN ),        GetSystemMetrics( SM_CYSCREEN ),        NULL,        NULL,        hInstance,        NULL );    if ( !hwnd )    {        return FALSE;    }    ShowWindow( hwnd, nCmdShow );    UpdateWindow( hwnd );    // Create the DirectDraw object -- we just need an IDirectDraw    // interface so we won't bother to query an IDirectDraw2    if ( FAILED( DirectDrawCreate( NULL, &lpDD, NULL ) ) )	{		return Fail( hwnd, "Couldn't create DirectDraw object.\n" );	}	// Get exclusive mode    if FAILED( lpDD->SetCooperativeLevel( hwnd,                        DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN ) )	{		return Fail( hwnd, "Couldn't set cooperative level.\n" );	}    // Set the display mode. An RGB mode is required for this sample	if ( FAILED( lpDD->SetDisplayMode( 640, 480, 32 ) ) )	{		return Fail( hwnd, "Couldn't set display mode.\n" );	}	// Create the primary surface    ddsd.dwSize = sizeof( ddsd );    ddsd.dwFlags = DDSD_CAPS;    ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;    	if ( FAILED( lpDD->CreateSurface( &ddsd, &lpDDSPrimary, NULL ) ) )	{		return Fail( hwnd, "Couldn't create primary surface.\n" );	}    if ( !LoadImage( lpDDSPrimary, "lake.bmp" ) ) 	{        return Fail( hwnd, "Couldn't load the image.\n" );    }	return TRUE;}int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,                    LPSTR lpCmdLine, int nCmdShow ){    MSG         msg;    lpCmdLine = lpCmdLine;    hPrevInstance = hPrevInstance;    if ( !doInit( hInstance, nCmdShow ) )    {        return FALSE;    }    while ( GetMessage( &msg, NULL, 0, 0 ) )    {        TranslateMessage( &msg );        DispatchMessage( &msg );    }    return msg.wParam;}


All I had to link with was ddraw.lib. Sometimes you have to include dxguid.lib though. Note I wouldn't be caught using goto's so this isn't my code but is included in microsoft's "Inside DirectX" book from years ago.
Also the book include DX SDK 5.2 on the cd and you can easily find older versions of dx sdk included on just about any game programming book. Any Lamothe book comes to mind...
[size="2"]Don't talk about writing games, don't write design docs, don't spend your time on web boards. Sit in your house write 20 games when you complete them you will either want to do it the rest of your life or not * Andre Lamothe

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.