⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.h

📁 <B>很多DirectX 9.0游戏编程源码例子</B>
💻 H
字号:
//-----------------------------------------------------------------------------
// Name: D3DFrame_UnitTemplate
//
// Description: Example code showing how to create a simple tile map
//				using an array of integers that point to textures
//				in memory.
//
// File Function: Header file for the program (main.h)
//
// Code: 
//		Copyright (c) 2002 LostLogic Corporation. All rights reserved.
//
// Original D3D Application Shell Code: 
//		Copyright (c) 1997-2001 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#define STRICT
#include <windows.h>
#include <commctrl.h>
#include <commdlg.h>
#include <math.h>
#include <tchar.h>
#include <stdio.h>
#include <D3DX9.h>
#include "DXUtil.h"
#include "D3DEnumeration.h"
#include "D3DSettings.h"
#include "D3DApp.h"
#include "D3DFont.h"
#include "D3DUtil.h"
#include "UnitTemplateClasses.h"

// Structure for the tile vertex data
struct TILEVERTEX
{
    D3DXVECTOR3 position;	// The position
	D3DXVECTOR3 vecNorm;	// The normals
    FLOAT       tu, tv;		// The texture coordinates (U,V)
};

// Our custom FVF, which describes our custom vertex structure
// D3DFVF_XYZ		= Coordinate information
// D3DFVF_NORMAL	= Normal information
// D3DFVF_TEX1		= Texture information
#define D3DFVF_TILEVERTEX ( D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1 )

// Macro for figuring out degrees
#define PI 3.1415926535897932384626433832795
#define DegToRad(deg) ((deg/180.0f)*PI)

//-----------------------------------------------------------------------------
// Desc: Application class. The base class (CD3DApplication) provides the 
//       generic functionality needed in all Direct3D samples. CD3DFramework 
//       adds functionality specific to this sample program.
//-----------------------------------------------------------------------------
class CD3DFramework : public CD3DApplication
{
    // Font to display FPS and video info
	CD3DFont*				m_pStatsFont;
	// Integer array used for tile map
	int						m_iTileMap[ 100 ];
	short					m_shTileMapWidth;
	short					m_shTileMapHeight;
	// Buffer to hold textures
	LPDIRECT3DTEXTURE9      m_pTexture[ 32 ];
	// Window dimensions
	short					m_shWindowWidth;
	short					m_shWindowHeight;
	// Buffer to hold vertices
	LPDIRECT3DVERTEXBUFFER9 m_pVBTile; 
	// Buffer to hold vertices
	LPDIRECT3DVERTEXBUFFER9 m_pVBUnit;
	// Unit manager
	CUnitManager			m_UnitManager;
	// Current unit actions
	int						m_iAction;

protected:
    HRESULT OneTimeSceneInit();
    HRESULT InitDeviceObjects();
    HRESULT RestoreDeviceObjects();
    HRESULT InvalidateDeviceObjects();
    HRESULT DeleteDeviceObjects();
    HRESULT Render();
    HRESULT FinalCleanup();
    HRESULT CreateD3DXTextMesh( LPD3DXMESH* ppMesh, TCHAR* pstrFont, DWORD dwSize );
	// Create tile vertex buffer
	void vInitTileVB( void );
	// Draw a tile on-screen
	void vDrawTile( float fXPos, float fYPos, float fXSize, float fYSize, int iTexture );
	// Draw a unit on-screen
	void vDrawUnit( float fXPos, float fYPos, float fXSize, float fYSize, float fRot, CUnitAnimation *animObj, int iTexture, int iOwner );
	// Initialize game units
	void vInitializeUnits( void );
	void vUpdateUnits( void );

public:
    LRESULT MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
    CD3DFramework();
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -