我有一本书:Frank Luna撰写的“DirectX 9.0c 3D游戏编程简介–一种着色器方法”。

官方站点已死,我似乎找不到用于所有项目的3个主要文件。

  • d3dApp.h
  • d3dApp.cpp
  • d3dUtil.h

  • 有人知道我在哪里可以买到吗?

    我发现的就是:
  • http://www.d3dcoder.net/
  • http://www.d3dcoder.net/phpBB/

  • 但是那里没有任何资料。
    我也发现了一些碎片
    //A sample directX demo outputting some flashing color text
    
    #include "d3dApp.h"
    #include <tchar.h>
    #include <crtdbg.h>
    
    //Our application is derived from the D3DAPP class, making setup for a game
    //or other program easier in the long run
    class HelloD3DApp : public D3DApp
    {
    public:
        HelloD3DApp(HINSTANCE hInstance, std::string winCaption, D3DDEVTYPE devType, DWORD requestedVP);
        ~HelloD3DApp();
    
        bool checkDeviceCaps();
        void onLostDevice();
        void onresetDevice();
        void updateScene(float dt);
        void drawScene();
    
    private:
    
        ID3DXFont* mFont;
    };
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance,
                       PSTR cmdLine, int showCmd)
    {
        // Enable run-time memory check for debug builds.
        #if defined(DEBUG) | defined(_DEBUG)
            _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
        #endif
    
    
        HelloD3DApp app(hInstance, "Hello Direct3D", D3DDEVTYPE_HAL, D3DCREATE_HARDWARE_VERTEXPROCESSING);
        gd3dApp = &app;
    
        return gd3dApp->run();
    }
    
    HelloD3DApp::HelloD3DApp(HINSTANCE hInstance, std::string winCaption, D3DDEVTYPE devType, DWORD requestedVP)
    : D3DApp(hInstance, winCaption, devType, requestedVP)
    {
        srand(time_t(0));
    
        if(!checkDeviceCaps())
        {
            MessageBox(0, "checkDeviceCaps() Failed", 0, 0);
            PostQuitMessage(0);
        }
    
        LOGFONTA font;
        font.lfHeight          = 80;
                    font.lfWidth            = 40;
        font.lfEscapement       = 0;
        font.lfOrientation      = 0;
                    font.lfWeight          = FW_BOLD;
                    font.lfItalic          = true;
        font.lfUnderline        = false;
        font.lfStrikeOut        = false;
                    font.lfCharSet        = DEFAULT_CHARSET;
                    font.lfOutPrecision  = OUT_DEFAULT_PRECIS;
        font.lfClipPrecision    = CLIP_CHARACTER_PRECIS;
                    font.lfQuality        = DEFAULT_QUALITY;
                    font.lfPitchAndFamily   = DEFAULT_PITCH | FF_DONTCARE;
                   _tcscpy(font.lfFaceName, _T("Times New Roman"));
    
        HR(D3DXCreateFontIndirect(gd3dDevice, &font, &mFont));
    }
    
    HelloD3DApp::~HelloD3DApp()
    {
        ReleaseCOM(mFont);
    }
    
    bool HelloD3DApp::checkDeviceCaps()
    {
        // Nothing to check.
        return true;
    }
    
    void HelloD3DApp::onLostDevice()
    {
        HR(mFont->OnLostDevice());
    }
    
    void HelloD3DApp::onresetDevice()
    {
        HR(mFont->onresetDevice());
    }
    
    void HelloD3DApp::updateScene(float dt)
    {
    }
    
    void HelloD3DApp::drawScene()
    {
        HR(gd3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255, 255, 255), 1.0f, 0));
    
        RECT formatRect;
        GetClientRect(mhMainWnd, &formatRect);
    
        HR(gd3dDevice->BeginScene());
    
        mFont->DrawText(TEXT("Hello </DIC>!"), -1,
            &formatRect, DT_CENTER | DT_VCENTER,
            D3DCOLOR_XRGB(rand() % 256, rand() % 256, rand() % 256));
    
        HR(gd3dDevice->EndScene());
        HR(gd3dDevice->Present(0, 0, 0, 0));
    }
    

    但这对我也没有帮助。

    最佳答案

    d3dApp.h

    d3dApp.cpp

    d3dUtil.h

    这些文件与zip文件中的文件相同。

    关于c++ - 在哪里可以找到 “Introduction to 3D game programming with DirectX 9.0c”的源代码示例?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7626954/

    10-10 08:56