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

beginner DX question

Started by Aerts Jan 25, 2006 at 1:20 AM 2 replies 550+ views
Original Post
Aerts
Aerts
I have MS VC++ 6.0, the DX 9.0c SDK and the DX 9.0c summer 2004 SDK update. I installed the DX 9.0c SDK and I got a few new AppWizard entries in my MSVC New Project page (like DirectX project etc.). Someone told me I don't need the original (old) SDK, only the update because it's standalone. To verify I did this: -uninstall the DX 9.0c SDK -uninstall MSVC++ 6 (to erase the New Project options) -reinstall MSVC++ 6 -install the DX 9.0c summer 2004 SDK update (WITHOUT the old SDK) Result: I have everything except the new AppWizard options (btw being a beginner, they mean a lot to me). Please tell me: what do I have to do, step by step, with these 3 softwares?
owiley
owiley
ok I don't know if I understand you but I will try to answer.


First you only need one, reason is the way microsoft developed Directx. It uses com model which is very nice. Ok to the important stuff how to set up your program:
1) Start up VC++,
2) At file menu choose New (Project-tab)
3) at the dialog choose win32 app (not win32 console)
It might be helpful to choose a blank workspace and add files manually
4) Add new source file by clicking on file New (choose the files tab)
here you might want to find tut and follow along for adding code
use the following (Im not sure if its totally right but its in the right direction)
#include <d3d9.h>LPDIRECT3D9 g_pD3D = NULL;LPDIRECT3DDEVICE9 g_pD3DDevice = NULL;HRESULT InitialiseD3D(HWND hWnd){    //First of all, create the main D3D object. If it is created successfully we     //should get a pointer to an IDirect3D8 interface.    g_pD3D = Direct3DCreate9(D3D_SDK_VERSION);    if(g_pD3D == NULL)    {        return E_FAIL;    }    //Get the current display mode    D3DDISPLAYMODE d3ddm;    if(FAILED(g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm)))    {        return E_FAIL;    }    //Create a structure to hold the settings for our device    D3DPRESENT_PARAMETERS d3dpp;     ZeroMemory(&d3dpp, sizeof(d3dpp));    //Fill the structure.     //We want our program to be windowed, and set the back buffer to a format    //that matches our current display mode    d3dpp.Windowed = TRUE;    d3dpp.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC;    d3dpp.BackBufferFormat = d3ddm.Format;    //Create a Direct3D device.    if(FAILED(g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,                                    D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pD3DDevice)))    {        return E_FAIL;    }        return S_OK;}void Render(){    if(g_pD3DDevice == NULL)    {        return;    }    //Clear the backbuffer to a green color    g_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 255, 0), 1.0f, 0);        //Begin the scene    g_pD3DDevice->BeginScene();        //Rendering of our game objects will go here        //End the scene    g_pD3DDevice->EndScene();        //Filp the back and front buffers so that whatever has been rendered on the back buffer    //will now be visible on screen (front buffer).    g_pD3DDevice->Present(NULL, NULL, NULL, NULL);}void CleanUp(){    if(g_pD3DDevice != NULL)    {        g_pD3DDevice->Release();        g_pD3DDevice = NULL;    }    if(g_pD3D != NULL)    {        g_pD3D->Release();        g_pD3D = NULL;    }}void GameLoop(){    //Enter the game loop    MSG msg;     BOOL fMessage;    PeekMessage(&msg, NULL, 0U, 0U, PM_NOREMOVE);        while(msg.message != WM_QUIT)    {        fMessage = PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE);        if(fMessage)        {            //Process message            TranslateMessage(&msg);            DispatchMessage(&msg);        }        else        {            //No message to process, so render the current scene            Render();        }    }}//The windows message handlerLRESULT WINAPI WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){    switch(msg)    {        case WM_DESTROY:            PostQuitMessage(0);            return 0;        break;        case WM_KEYUP:             switch (wParam)            {                 case VK_ESCAPE:                    //User has pressed the escape key, so quit                    DestroyWindow(hWnd);                    return 0;                break;            }         break;    }    return DefWindowProc(hWnd, msg, wParam, lParam);}//Application entry pointINT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, INT){    //Register the window class    WNDCLASSEX wc = {sizeof(WNDCLASSEX), CS_CLASSDC, WinProc, 0L, 0L,                      GetModuleHandle(NULL), NULL, NULL, NULL, NULL,                     "DX Project 1", NULL};    RegisterClassEx(&wc);    //Create the application's window    HWND hWnd = CreateWindow("DX Project 1", "www.andypike.com: Tutorial 1",                               WS_OVERLAPPEDWINDOW, 50, 50, 500, 500,                              GetDesktopWindow(), NULL, wc.hInstance, NULL);    //Initialize Direct3D    if(SUCCEEDED(InitialiseD3D(hWnd)))    {         //Show our window        ShowWindow(hWnd, SW_SHOWDEFAULT);        UpdateWindow(hWnd);        //Start game running: Enter the game loop        GameLoop();    }        CleanUp();    UnregisterClass("DX Project 1", wc.hInstance);        return 0;}
Bring more Pain
Calin
Calin
To compile DirectX code, DX9 SDK summer 2004 update should be sufficient.
As for VS 6.0, Microsoft dropped it's support for this version some time ago. Not sure what this means in practice though (never tried to code DX applications with VS 6.0).
If I where you I would download Visul Studio 2005 Express. It's free and you get a modern compiler/IDE.
After having installed these tools you should try and compile your first DX program. To do this you will need some basic DirectX program code ( I suggest downloading a tutorial and try compiling the code that comes with it.)
Don't expect things running straight from the first try. All kind of errors might (and will) pop up in this procces. Most of them will be easy to fix. The main thing is to always have the DirectX documentation at hand.
There is a lot of useful information in the Forum FAQ, it would be a good idea to take a glance.
Also you can find more details on setting up your DirectX/VS enviroment in this thread

[Edited by - Calin on January 25, 2006 2:11:52 AM]
My project`s facebook page is “DreamLand Page”
jollyjeffers
jollyjeffers
The AppWizard part of the SDK was dropped a long time ago. They were replaced by the "Install Project" feature in the Sample Browser (should be in your start-menu folder).

Find a sample/tutorial thats close to what you're trying to do, install a copy of it, load the solution/project from wherever you installed it [smile]

Although, as Calin pointed out, VC6 is something you should look to drop - especially now that VC8 Express Edition is free. VC6 is 7-8 years old now, it just doesn't compare to newer models [grin]

Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |

Topic Locked

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

Sign in to reply to this topic.