Home > Back-end >  Help: DirectX 8.0 source code error
Help: DirectX 8.0 source code error

Time:12-16

Learn a book "the 2 d programming" in the Direct3D, only writing theory in the book, not the experimental steps,
The first chapter in the first quarter of the source code, there is no through,

The experimental configuration:
Windows 7, DX8_SDK
Cfree5.0, set up the Include and Library catalog, the source code is not through,
Vc + + 6.0, set up the Include and Library catalog, the source code is not through,

Online to see the following:
"The second step: the library files needed to add links, such as dxguid. Lib, d3d9. Lib, d3dx9. Lib, etc.,... "

This step I don't understand, don't know whether because of lack of this step? In view of the DX8 and the source code, how to set?

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Download: source + the 2 d programming "in the" Direct3D PDF
https://download.csdn.net/download/u010971968/5882089

PDF online reading
https://ishare.iask.sina.com.cn/f/22639180.html

Attached source Example1_1, all available in the above link to download

//Example1_1 
//the main CPP
//Ernest Pazera
//04 oct2001
//TGO - 01 - C
//Libs: d3d8 lib

#include //include Windows stuff
#include //standard input/output
# include "D3D8. H"//include direct3d8 stuff

//constants
//the window class name
Const char * WINDOWCLASS="3 d42dgp";
//window title
Const char * WINDOWTITLE="Example (TGO - 01 - C) 1.1: Creating and Destroying the an IDirect3D8 object";

//globals
//the instance handle
HINSTANCE g_hInstance=NULL;
//window handle
HWND g_hWnd=NULL;
//IDirect3D8 pointer
IDirect3D8 * g_pd3d=NULL;

//function as
//winmain
Int WINAPI WinMain (HINSTANCE HINSTANCE, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd);
//window procedure
LRESULT a CALLBACK TheWindowProc (HWND HWND, UINT uMsg, WPARAM WPARAM, LPARAM LPARAM);
//initialization
Void Prog_Init ();
//clean up
Void Prog_Done ();


//window procedure
LRESULT a CALLBACK TheWindowProc (HWND HWND, UINT uMsg, WPARAM WPARAM, LPARAM LPARAM)
{
//which message did we get?
The switch (uMsg)
{
Case WM_DESTROY://the window being destroyed
{
//the quit

The PostQuitMessage (0);

//the message is handled, return 0

Return (0);

} break;
Default://all other messages, send to the default handler
Return (DefWindowProc (hWnd uMsg, wParam, lParam));
}
}

//winmain
Int WINAPI WinMain (HINSTANCE HINSTANCE, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
//, grab the instance handle
G_hInstance=hInstance;

//redirect stderr and stdout output
Freopen (" stderr. TXT ", "w", stderr);
Freopen (" stdout. TXT ", "w", stdout);

//the fill in the window class
Modifed WNDCLASSEX wc.
Wc. CbClsExtra=0;//no extra class information
Wc. CbSize=sizeof (modifed WNDCLASSEX);//the size of structure
Wc. CbWndExtra=0;//no extra window information
Wc. HbrBackground=(HBRUSH) GetStockObject (BLACK_BRUSH);//black brush
Wc. HCursor=NULL;//no cursor
Wc. HIcon=NULL;//no icon
Wc. HIconSm=NULL;//no small icon
The wc. The hInstance=g_hInstance;//the instance handle
Wc. LpfnWndProc=TheWindowProc;//window procedure
Wc. LpszClassName=WINDOWCLASS;//the name of the class
Wc. LpszMenuName=NULL;//no menu
Wc. Style=CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_OWNDC;//class styles

//register the window class
RegisterClassEx (& amp; Wc);

//create Windows
G_hWnd=CreateWindowEx (0, WINDOWCLASS, WINDOWTITLE WS_OVERLAPPEDWINDOW, 0, 0, 320, 240, NULL, NULL, g_hInstance, NULL);

//show the window
ShowWindow (g_hWnd, nShowCmd);

//initialization
Prog_Init ();

MSG MSG.
//the message pump
For (; ; )
{
//check for a message
If (PeekMessage (& amp; MSG, NULL, 0, 0, PM_REMOVE))
{
//the message exists

//check for the quit message
If (MSG) message==WM_QUIT) break;

//translate the message
TranslateMessage (& amp; MSG);

//dispatch the message
DispatchMessage (& amp; MSG);
}
}

//clean up
Prog_Done ();

//exit
Return (MSG. WParam);
}

//initialization
Void Prog_Init ()
{
//create the IDirect3D8 object
G_pd3d=Direct3DCreate8 (D3D_SDK_VERSION);

//the error check
If (g_pd3d)
{
//success
Fprintf (stdout, "IDirect3D8 object created successfully. \ n");
}
The else
{
//failure
Fprintf (stderr, "IDirect3D8 object creation failed. \ n");
}
}

//clean up
Void Prog_Done ()
{
//safe release of IDirect3D8 object
If (g_pd3d)
{
//release
G_pd3d - & gt; Release ();

//set to null
G_pd3d=NULL;

//report action
Fprintf (stdout, "IDirect3D8 object released. \ n");
}
}






CodePudding user response:

VC6:
Engineering, setting, C/C + +, classification: the Preprocessor, additional include path: fill in the attached header file directory commas between multiple
nullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related