//-----------------------------------------------------------------------------
// File: D3DApp.cpp
//
// Desc: Application class for the Direct3D samples framework library.
//
// Copyright (c) 1998-2000 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#define STRICT
#include <windows.h>
#include <windowsx.h>
#include <basetsd.h>
#include <mmsystem.h>
#include <stdio.h>
#include <tchar.h>
#include <D3D8.h>
#include "D3DApp.h"
#include "D3DUtil.h"
#include "DXUtil.h"
#include "D3DRes.h"
//-----------------------------------------------------------------------------
// Global access to the app (needed for the global WndProc())
//-----------------------------------------------------------------------------
static CD3DApplication* g_pD3DApp = NULL;
//-----------------------------------------------------------------------------
// Name: CD3DApplication()
// Desc: Constructor
//-----------------------------------------------------------------------------
CD3DApplication::CD3DApplication()
{
g_pD3DApp = this;
m_dwNumAdapters = 0;
m_dwAdapter = 0L;
m_pD3D = NULL;
m_pd3dDevice = NULL;
m_hWnd = NULL;
m_hWndFocus = NULL;
m_bActive = FALSE;
m_bReady = FALSE;
m_dwCreateFlags = 0L;
m_bFrameMoving = TRUE;
m_bSingleStep = FALSE;
m_fFPS = 0.0f;
m_strDeviceStats[0] = _T('\0');
m_strFrameStats[0] = _T('\0');
m_strWindowTitle = _T("D3D8 Application");
m_dwCreationWidth = 400;
m_dwCreationHeight = 300;
m_bUseDepthBuffer = FALSE;
m_dwMinDepthBits = 16;
m_dwMinStencilBits = 0;
m_bShowCursorWhenFullscreen = FALSE;
}
//-----------------------------------------------------------------------------
// Name: WndProc()
// Desc: Static msg handler which passes messages to the application class.
//-----------------------------------------------------------------------------
LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
return g_pD3DApp->MsgProc( hWnd, uMsg, wParam, lParam );
}
//-----------------------------------------------------------------------------
// Name: Create()
// Desc:
//-----------------------------------------------------------------------------
HRESULT CD3DApplication::Create( HINSTANCE hInstance )
{
HRESULT hr;
// Create the Direct3D object
m_pD3D = Direct3DCreate8( D3D_SDK_VERSION );
if( m_pD3D == NULL )
return DisplayErrorMsg( D3DAPPERR_NODIRECT3D, MSGERR_APPMUSTEXIT );
// Build a list of Direct3D adapters, modes and devices. The
// ConfirmDevice() callback is used to confirm that only devices that
// meet the app's requirements are considered.
if( FAILED( hr = BuildDeviceList() ) )
{
SAFE_RELEASE( m_pD3D );
return DisplayErrorMsg( hr, MSGERR_APPMUSTEXIT );
}
// Unless a substitute hWnd has been specified, create a window to
// render into
if( m_hWnd == NULL)
{
// Register the windows class
WNDCLASS wndClass = { 0, WndProc, 0, 0, hInstance,
LoadIcon( hInstance, MAKEINTRESOURCE(IDI_MAIN_ICON) ),
LoadCursor( NULL, IDC_ARROW ),
(HBRUSH)GetStockObject(WHITE_BRUSH),
NULL, _T("D3D Window") };
RegisterClass( &wndClass );
// Set the window's initial style
m_dwWindowStyle = WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|
WS_MINIMIZEBOX|WS_VISIBLE;
// Set the window's initial width
RECT rc;
SetRect( &rc, 0, 0, m_dwCreationWidth, m_dwCreationHeight );
AdjustWindowRect( &rc, m_dwWindowStyle, TRUE );
// Create the render window
m_hWnd = CreateWindow( _T("D3D Window"), m_strWindowTitle, m_dwWindowStyle,
CW_USEDEFAULT, CW_USEDEFAULT,
(rc.right-rc.left), (rc.bottom-rc.top), 0L,
LoadMenu( hInstance, MAKEINTRESOURCE(IDR_MENU) ),
hInstance, 0L );
}
// The focus window can be a specified to be a different window than the
// device window. If not, use the device window as the focus window.
if( m_hWndFocus == NULL )
m_hWndFocus = m_hWnd;
// Save window properties
m_dwWindowStyle = GetWindowLong( m_hWnd, GWL_STYLE );
GetWindowRect( m_hWnd, &m_rcWindowBounds );
GetClientRect( m_hWnd, &m_rcWindowClient );
// Initialize the app's custom scene stuff
if( FAILED( hr = OneTimeSceneInit() ) )
{
SAFE_RELEASE( m_pD3D );
return DisplayErrorMsg( hr, MSGERR_APPMUSTEXIT );
}
// Initialize the 3D environment for the app
if( FAILED( hr = Initialize3DEnvironment() ) )
{
SAFE_RELEASE( m_pD3D );
return DisplayErrorMsg( hr, MSGERR_APPMUSTEXIT );
}
// Setup the app so it can support single-stepping
DXUtil_Timer( TIMER_START );
// The app is ready to go
m_bReady = TRUE;
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: SortModesCallback()
// Desc: Callback function for sorting display modes (used by BuildDeviceList).
//-----------------------------------------------------------------------------
int SortModesCallback( const VOID* arg1, const VOID* arg2 )
{
D3DDISPLAYMODE* p1 = (D3DDISPLAYMODE*)arg1;
D3DDISPLAYMODE* p2 = (D3DDISPLAYMODE*)arg2;
if( p1->Format > p2->Format ) return -1;
if( p1->Format < p2->Format ) return +1;
if( p1->Width < p2->Width ) return -1;
if( p1->Width > p2->Width ) return +1;
if( p1->Height < p2->Height ) return -1;
if( p1->Height > p2->Height ) return +1;
return 0;
}
//-----------------------------------------------------------------------------
// Name: BuildDeviceList()
// Desc:
//-----------------------------------------------------------------------------
HRESULT CD3DApplication::BuildDeviceList()
{
const DWORD dwNumDeviceTypes = 2;
const TCHAR* strDeviceDescs[] = { _T("HAL"), _T("REF") };
const D3DDEVTYPE DeviceTypes[] = { D3DDEVTYPE_HAL, D3DDEVTYPE_REF };
BOOL bHALExists = FALSE;
BOOL bHALIsWindowedCompatible = FALSE;
BOOL bHALIsDesktopCompatible = FALSE;
BOOL bHALIsSampleCompatible = FALSE;
// Loop through all the adapters on the system (usually, there's just one
// unless more than one graphics card is present).
for( UINT iAdapter = 0; iAdapter < m_pD3D->GetAdapterCount(); iAdapter++ )
{
// Fill in adapter info
D3DAdapterInfo* pAdapter = &m_Adapters[m_dwNumAdapters];
m_pD3D->GetAdapterIdentifier( iAdapter, 0, &pAdapter->d3dAdapterIdentifier );
m_pD3D->GetAdapterDisplayMode( iAdapter, &pAdapter->d3ddmDesktop );
pAdapter->dwNumDevices = 0;
pAdapter->dwCurrentDevice = 0;
// Enumerate all display modes on this adapter
D3DDISPLAYMODE modes[100];
D3DFORMAT formats[20];
DWORD dwNumFormats = 0;
DWORD dwNumModes = 0;
DWORD dwNumAdapterModes = m_pD3D->GetAdapterModeCount( iAdapter );
// Add the adapter's current desktop format to the list of formats
formats[dwNumFormats++] = pAdapter->d3ddmDesktop.Format;
for( UINT iMode = 0; iMode < dwNumAdapterModes; iMode++ )
{
// Get the display mode attributes
D3DDISPLAYMODE DisplayMode;
m_pD3D->EnumAdapterModes( iAdapter, iMode, &DisplayMode );
// Filter out lo
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Beginning Game Audio Programming (884个子文件)
Ch14p1_SkyBox_Right.bmp 257KB
Ch14p1_SkyBox_Back.bmp 257KB
Ch13p1_SkyBox_Back.bmp 257KB
Ch13p1_SkyBox_Right.bmp 257KB
Ch14p1_SkyBox_Left.bmp 257KB
Ch13p1_SkyBox_Left.bmp 257KB
Ch14p1_SkyBox_Top.bmp 257KB
Ch13p1_SkyBox_Top.bmp 257KB
Ch14p1_SkyBox_Front.bmp 257KB
Ch14p1_Skybox_Bottom.bmp 257KB
Ch13p1_SkyBox_Front.bmp 257KB
Ch13p1_Skybox_Bottom.bmp 257KB
Premier.Press.Beginning.Game.Audio.Programming.eBook-LiB.chm 7.08MB
d3dapp.cpp 67KB
d3dapp.cpp 67KB
netconnect.cpp 61KB
dsutil.cpp 51KB
dsutil.cpp 51KB
dxutil.cpp 37KB
dxutil.cpp 37KB
dxutil.cpp 37KB
dxutil.cpp 37KB
dxutil.cpp 37KB
dxutil.cpp 37KB
dxutil.cpp 37KB
dxutil.cpp 37KB
dxutil.cpp 37KB
dxutil.cpp 37KB
dxutil.cpp 37KB
dxutil.cpp 37KB
dxutil.cpp 37KB
dxutil.cpp 37KB
dxutil.cpp 37KB
dxutil.cpp 37KB
dxutil.cpp 37KB
dxutil.cpp 37KB
dxutil.cpp 37KB
dxutil.cpp 37KB
dxutil.cpp 23KB
d3dfont.cpp 23KB
d3dfont.cpp 23KB
dmutil.cpp 22KB
dmutil.cpp 22KB
d3dutil.cpp 20KB
d3dutil.cpp 20KB
d3dfile.cpp 20KB
d3dfile.cpp 20KB
dxutil.cpp 19KB
dxutil.cpp 19KB
AudioManager.cpp 18KB
AudioManager.cpp 18KB
AudioManager.cpp 18KB
AudioManager.cpp 18KB
AudioManager.cpp 18KB
Ch13p1_3DSound.cpp 18KB
Ch14p1_3DOpenALSound.cpp 18KB
D3DHelperFuncs.cpp 17KB
D3DHelperFuncs.cpp 17KB
AudioManager.cpp 17KB
AudioManager.cpp 17KB
AudioManager.cpp 14KB
Ch16p1_VoiceChat.cpp 14KB
netvoice.cpp 14KB
AudioManager.cpp 13KB
AudioManager.cpp 12KB
Ch15p2_I3DL2EnvEditor.cpp 12KB
AudioManager.cpp 10KB
AudioManager.cpp 9KB
Ch17p1_Visuals.cpp 9KB
Ch15p1_I3DL2Reverb.cpp 9KB
MP3AudioTag.cpp 8KB
MP3AudioTag.cpp 8KB
MP3AudioTag.cpp 8KB
MP3AudioTag.cpp 8KB
MP3AudioTag.cpp 8KB
MP3AudioTag.cpp 8KB
MP3AudioTag.cpp 8KB
MP3AudioTag.cpp 8KB
MP3AudioTag.cpp 8KB
MP3AudioTag.cpp 8KB
MP3AudioTag.cpp 8KB
Ch2p1_ToneGenerator.cpp 8KB
CDPlayer.cpp 8KB
diutil.cpp 8KB
diutil.cpp 8KB
Ch9p1_CDPlayer.cpp 7KB
Mixer.cpp 6KB
Mixer.cpp 6KB
Mixer.cpp 6KB
Mixer.cpp 6KB
Mixer.cpp 6KB
Mixer.cpp 6KB
Mixer.cpp 6KB
Mixer.cpp 6KB
Mixer.cpp 6KB
Mixer.cpp 6KB
Mixer.cpp 6KB
Mixer.cpp 6KB
Mixer.cpp 6KB
Effect.cpp 6KB
共 884 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
emacs
- 粉丝: 5
- 资源: 41
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功