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

📄 main.h

📁 <B>很多DirectX 9.0游戏编程源码例子</B>
💻 H
字号:
//-----------------------------------------------------------------------------
// Name: D3D_InputBox
//
// Description: Example code showing how to input text into a graphic text box.
//
// File Function: Header file for the program (main.h)
//
// Code: 
//		Copyright (c) 2002 LostLogic Corporation. All rights reserved.
//
// Libraries Required:
//		d3d9.lib dxguid.lib d3dx9dt.lib d3dxof.lib comctl32.lib	winmm.lib dinput8.lib
//
// Local Files Required:
//		main.cpp
//		main.h
//		MouseZoneClass.h
//		MouseZoneClass.cpp
//
// DX Files: 
//		Copyright (c) 1997-2001 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#ifndef MAIN_H
#define MAIN_H

// Set the direct input version
#define DIRECTINPUT_VERSION 0x0800

#define STRICT
#include <windows.h>
#include <commctrl.h>
#include <commdlg.h>
#include <math.h>
#include <tchar.h>
#include <stdio.h>
#include <D3DX9.h>
#include <dinput.h>
#include "DXUtil.h"
#include "D3DUtil.h"
#include "MouseZoneClass.h"

//-----------------------------------------------------------------------------
// Global variables
//-----------------------------------------------------------------------------
LPDIRECT3D9             g_pD3D				= NULL; // Used to create the D3DDevice
LPDIRECT3DDEVICE9       g_pd3dDevice		= NULL; // Our rendering device
LPDIRECT3DVERTEXBUFFER9 g_pVBInterface		= NULL; // Buffer to hold vertices

// Global array to hold interface graphics
LPDIRECT3DTEXTURE9      g_pTexture[ 32 ];

// Viewable window offsets
int						g_iXOffset = 0;
int						g_iYOffset = 0;

// Window dimensions
int						g_iWindowWidth	= 640;
int						g_iWindowHeight = 480;

// A structure for our custom vertex type
struct CUSTOMVERTEX
{
    D3DXVECTOR3 position;	// The position
	D3DXVECTOR3 vecNorm;	// The normal
    FLOAT       tu, tv;		// The texture coordinates
	FLOAT       tu2, tv2;   // The texture coordinates
};
// Custom FVF, which describes the custom vertex structure
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX2)

//-----------------------------------------------------------------------------
// Function headers
//-----------------------------------------------------------------------------
void vDrawInterfaceObject( int iXPos, int iYPos, float fXSize, float fYSize, int iTexture );
void vInitInterfaceObjects( void );
LRESULT WINAPI fnMessageProcessor( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
HRESULT InitD3D( HWND hWnd );
void vRender( void );
void vCleanup( void );
void vCheckInput( void );
void vSetupMouseZones( int iMenu );

// Global mouse zone class
MouseZoneClass	MZones;

// Navigation menu ID
int		g_iCurrentScreen = 0;

// Mouse button state variables
bool	g_bLeftButton = 0;
bool	g_bRightButton = 0;

// Highlight state variables
bool	g_bMainMenu_NewGame_Highlight = 0;
bool	g_bMainMenu_LoadGame_Highlight = 0;
bool	g_bMainMenu_SaveGame_Highlight = 0;
bool	g_bMainMenu_Options_Highlight = 0;

// Global handle to the game window
HWND	g_hWnd;

//
// Text input variables
//
const	GAMEINPUT_NAME = 0;
const	GAMEINPUT_CHAT = 1;

bool	g_bTextInputActive = 0;
int		g_iTextInputFieldID = 0;
short	g_shTextInputPosition = 0;
short	g_shTextInputXPos = 0;
short	g_shTextInputYPos = 0;
char	g_szTextInputBuffer[ 64 ];
DWORD	g_dwTextInputTimer = 0;
bool	g_bTextInputCursorFlash = 0;
short	g_shTextMaxSize = 26;

// Font to display text fields
LPD3DXFONT		pD3DXFont = NULL;
HFONT			hFont = NULL;

//------------------------------------------------------------------------
//
//	DIRECT INPUT DATA
//
//------------------------------------------------------------------------
#include <dinput.h>

// Keyboard buffer size
const int  KEYBOARD_BUFFERSIZE			= 10;
// Error codes
const int  INPUTERROR_SUCCESS			= 0;
const int  INPUTERROR_NODI				= 1;
const int  INPUTERROR_NOKEYBOARD		= 2;
const int  INPUTERROR_KEYBOARDEXISTS	= 3;
const int  INPUTERROR_DI_EXISTS			= 4;
// Device pointers
LPDIRECTINPUT8					pDI			= NULL;         
LPDIRECTINPUTDEVICE8			pKeyboard	= NULL; 
// Keyboard buffers
BYTE							diks[ 256 ][ KEYBOARD_BUFFERSIZE ];
BYTE							ascKeys[ 256 ][ KEYBOARD_BUFFERSIZE ];
// Keyboard layout
HKL								g_Layout;
// Program instance pointer
HINSTANCE						g_hInstance;
// Global if SHIFT key is down
bool							g_bShift = 0;

//-----------------------------------------------------------------------------
// Function headers
//-----------------------------------------------------------------------------
int	iInitDirectInput(void);
int iInitKeyboard(HWND hWnd);
BYTE Scan2Ascii(DWORD scancode);
int iReadKeyboard( void );

#endif

⌨️ 快捷键说明

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