📄 d3dapp.h
字号:
/*
* Copyright (C) 1995, 1996 Microsoft Corporation. All Rights Reserved.
*
* File: d3dapp.h
*
* Header to be included in source using D3DApp. Contains D3DApp function
* prototypes and defines.
*
* D3DApp is a collection of helper functions for Direct3D applications.
* D3DApp consists of the following files:
* d3dapp.h Main D3DApp header to be included by application
* d3dappi.h Internal header
* d3dapp.c D3DApp functions seen by application.
* ddcalls.c All calls to DirectDraw objects except textures
* d3dcalls.c All calls to Direct3D objects except textures
* texture.c Texture loading and managing texture list
* misc.c Miscellaneous calls
*/
#ifndef __D3DAPP_H__
#define __D3DAPP_H__
#define INITGUID
#include <ddraw.h>
#include <d3d.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* DEFINES
*/
#define D3DAPP_WINDOWMINIMUM 50 /* smallest buffer size allowed */
#define D3DAPP_DEFAULTWINDOWDIM 320 /* replaces window size if invalid */
#define D3DAPP_MINBUFFERSIZE 15360 /* minimum "maximum buffer size" for a
D3D driver to be accepted */
#define D3DAPP_MINVERTEXCOUNT 320 /* minimum "maximum vertex count" for a
D3D driver to be accepted */
#define D3DAPP_MAXD3DDRIVERS 5 /* maximum Direct3D drivers ever expected
to find */
#define D3DAPP_MAXDDDRIVERS 3 /* maximum DirectDraw drivers ever expected
to find */
#define D3DAPP_MAXTEXTUREFORMATS 50 /* maximum texture formats */
#define D3DAPP_MAXMODES 50 /* maximum display modes ever expected to
be reported by DirectDraw */
#define D3DAPP_MAXTEXTURES 15 /* maximum number of textures that wil be
loaded and managed */
#define D3DAPP_MAXCLEARRECTS 30 /* maximum num. rectangles (ie extents)
for clearing */
#define D3DAPP_BOGUS -100 /* unused parameters accept this */
#define D3DAPP_YOUDECIDE -25 /* Use this for certain parameters to
have D3DApp decide an appropriate
value for you */
#define D3DAPP_USEWINDOW -24 /* Used in place of fullscreen mode */
/*
* DATA STRUCTURES
*/
/*
* D3DAppDDDriver structure
* Describes a DD driver
*/
typedef struct tagD3DAppDDDriver {
char Name[30]; /* short name of the driver */
DDCAPS HWCaps; /* Hardware capabilities */
GUID Guid; /* it's GUID */
BOOL bIsPrimary; /* is this the primary device */
} D3DAppDDDriver;
/*
* D3DAppD3DDriver structure
* Describes a D3D driver
*/
typedef struct tagD3DAppD3DDriver {
char Name[30]; /* short name of the driver */
char About[50]; /* short string about the driver */
D3DDEVICEDESC Desc; /* D3DDEVICEDESC for complete information */
GUID Guid; /* it's GUID */
BOOL bIsHardware; /* does this driver represent a hardware device? */
BOOL bDoesTextures; /* does this driver do texture mapping? */
BOOL bDoesZBuffer; /* can this driver use a z-buffer? */
BOOL bCanDoWindow; /* can it render to Window's display depth? */
} D3DAppD3DDriver;
/*
* D3DAppTextureFormat stucture
* Describes a texture format
*/
typedef struct tagD3DAppTextureFormat {
DDSURFACEDESC ddsd; /* DDSURFACEDESC for complete information */
BOOL bPalettized; /* is this format palettized */
int RedBPP; /* number of red, */
int BlueBPP; /* blue, */
int GreenBPP; /* and green bits per pixel */
int IndexBPP; /* number of bits in palette index */
} D3DAppTextureFormat;
/*
* D3DAppMode structure
* Describes a display mode
*/
typedef struct tagD3DAppMode {
int w; /* width */
int h; /* height */
int bpp; /* bits per pixel */
BOOL bThisDriverCanDo; /*can current D3D driver render in this mode?*/
} D3DAppMode;
/*
* D3DAppInfo structure
* Contains all the information D3DApp makes available to the application. A
* pointer to the internal, read only copy is returned by the initializing
* function.
*/
typedef struct tagD3DAppInfo {
HWND hwnd; /*handle of window being managed*/
/*
* Direct3D objects and information
*/
LPDIRECT3D lpD3D; /* D3D object */
LPDIRECT3DDEVICE lpD3DDevice; /* D3D device */
LPDIRECT3DVIEWPORT lpD3DViewport; /* D3D viewport, created by
application */
int NumDrivers; /* number of D3D drivers avail. */
int CurrDriver; /* number of curr. D3D driver */
D3DAppD3DDriver Driver[D3DAPP_MAXD3DDRIVERS]; /* avail. drivers*/
D3DAppD3DDriver ThisDriver; /* description of this driver,
identical to Driver[CurrDriver] */
int NumTextureFormats; /* num texture formats avail*/
int CurrTextureFormat; /* current texture format
will only change if driver changes or when app changes it*/
D3DAppTextureFormat TextureFormat[D3DAPP_MAXTEXTUREFORMATS];
/* description of all avail. formats */
D3DAppTextureFormat ThisTextureFormat; /* description of this format,
identical to TextureFormat[CurrTextureFormat] */
int NumTextures; /* number of textures in D3DApp's
texture list */
char ImageFile[D3DAPP_MAXTEXTURES][50]; /* files */
D3DTEXTUREHANDLE TextureHandle[D3DAPP_MAXTEXTURES]; /* handles */
LPDIRECTDRAWSURFACE lpTextureSurf[D3DAPP_MAXTEXTURES]; /* surfaces */
LPDIRECT3DTEXTURE lpTexture[D3DAPP_MAXTEXTURES]; /* texture objs */
int NumUsableTextures; /* the number of currently usable
textures (e.g. for a hardware
device there may not be enough
video memory*/
/*
* DirectDraw objects and information
*/
LPDIRECTDRAW lpDD; /* DirectDraw object */
BOOL bIsPrimary; /* Is this the primary DD device?
If FALSE, we're using a hardware DD device that cannot
display a window and so only fullscreen modes are available */
LPDIRECTDRAWSURFACE lpFrontBuffer; /* front buffer surface */
LPDIRECTDRAWSURFACE lpBackBuffer; /* back buffer surface */
LPDIRECTDRAWSURFACE lpZBuffer; /* z-buffer surface */
BOOL bBackBufferInVideo; /* back buf in video mem? */
BOOL bZBufferInVideo; /* is Z-buf in video mem? */
int NumModes; /* number of available display modes */
int CurrMode; /* number of current display mode (only
when fullscreen) */
D3DAppMode Mode[D3DAPP_MAXMODES]; /* desc avail modes */
D3DAppMode ThisMode; /* description of this mode, identical
to Mode[CurrMode] */
BOOL bFullscreen; /* in fullscreen exclusive mode? */
D3DAppMode WindowsDisplay; /* current Windows disply mode */
SIZE szClient; /* dimensions of client win */
POINT pClientOnPrimary; /* position of client win */
BOOL bPaused; /* the app is paused */
BOOL bAppActive; /* the app is active */
BOOL bTexturesDisabled; /* textures are disabled */
BOOL bOnlySystemMemory; /* all surfaces forced into
system memory */
BOOL bOnlyEmulation; /* no hardware DD or D3D
devices allowed */
BOOL bMinimized; /* app window is minimized */
BOOL bRenderingIsOK; /* All objects etc. necessary
for rendering are in ok */
} D3DAppInfo;
/*
* D3DAppRenderState structure
* The "render state" is the status of this collection of D3D options and
* variables. This structure is used to get and set the render state. The
* render state will only change during program initialization and when
* the application sets it.
*/
typedef struct tagD3DAppRenderState {
BOOL bZBufferOn; /* Z buffer is on */
BOOL bPerspCorrect; /* perspective correction is on */
D3DSHADEMODE ShadeMode; /* flat, gouraud, phong? */
D3DTEXTUREFILTER TextureFilter; /* linear or bi-linear texture filter */
D3DTEXTUREBLEND TextureBlend; /* Use shade mode or copy mode? */
D3DFILLMODE FillMode; /* solid, lines or points? */
BOOL bDithering; /* dithering is on */
BOOL bSpecular; /* specular highlights are on */
BOOL bAntialiasing; /* anti-aliasing is on */
BOOL bFogEnabled; /* fog is on */
D3DCOLOR FogColor; /* fog color */
D3DFOGMODE FogMode; /* linear, exp. etc. */
D3DVALUE FogStart; /* begining depth */
D3DVALUE FogEnd; /* ending depth */
} D3DAppRenderState;
/*
* FUNCTION PROTOTYPES
*/
/*
* D3DAppEnumerateDDDevices
*
* All the 3d capable DirectDraw devices including the primary display are
* found. The driver information structures are filled in with appropriate
* information. lpDriver must point to an array with at least D3DAPP_MAXDDDRIVERS
* elements.
*/
BOOL D3DAppEnumerateDDDevices(int* NumDevices, D3DAppDDDriver* lpDriver);
/*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -