Chapter 1: Initialization of Direct3D

zhaozj2021-02-16  53

Start now, DirectX9.0's post. The first chapter, the initialization of DirectX.

1, project preparation

Need to insert .lib file

D3DXOF.LIB DXGUID.LIB D3DX9DT.LIB D3D9.LIB Winmm.lib

A total of 5

2 code composition

1 project file, 2 head files, 2 .cpp files. Head file

STDAFX.H

The top-level file of the project.

D3DSetup9.h

CD3DSETUP9 definition file

.cpp file:

Main.cpp

Winmain () function and windproc () functions. In short, just call CD3DSETUP9 class

D3DSETUP.CPP

Member function of the CD3DSetup class implements file, initialization, and render (), etc.

3 detailed implementation

//stdafx.h

#pragma overce # include

//d3dsetup9.h

#include "stdafx.h" #include // Memory Release #define Safe_Delete (p) {if (p) {delete (p); (p) = null;}} #define safe_delete_Array (p) { IF (p) {delete [] (p); (p) = null;}} #define safe_release (p) {if (p) {(p) -> Release (); (p) = null;}} / / Direct3D9 class class CD3DSetup9 {LPDIRECT3D9 m_pD3D; LPDIRECT3DDEVICE9 m_pd3dDevice; D3DPRESENT_PARAMETERS param; int m_iwidth, m_iheight; // windows width and height int m_iloop; HRESULT InitD3D (HWND hWnd, BOOL bWin); // Direct3D9

HRESULT Apploop (); // public: cd3dsetup9 (); ~ cd3dsetup9 (); HRESULT RUN (Hinstance Hinst, Char Szwinname [], int Width, int Height, Bool bwin; ///////

LRESULT MSGPROC (HWND HWND, UINT UMSG, WPARAM WPARAM, LPARAM LPARAM); HRESULT RENDER (); // HRESULT CLEANUP (); ///};

........ (Continu ..

转载请注明原文地址:https://www.9cbs.com/read-18369.html

New Post(0)