青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

天行健 君子當(dāng)自強而不息

DXUT框架剖析(13)

添加文本

DXUT框架對文本繪制進行了封裝,提供了類CDXUTHelper來簡化文本顯示,使用該接口大體分為3個步驟:初始化ID3DXSprite和ID3DXFont對象,顯示文本,釋放ID3DXSprite和ID3DXFont對象。

首先來看看CDXUTHelper的定義部分:

//--------------------------------------------------------------------------------------
// Manages the insertion point when drawing text
//--------------------------------------------------------------------------------------
class CDXUTTextHelper
{
public:
    CDXUTTextHelper( ID3DXFont
* pFont, ID3DXSprite* pSprite, int nLineHeight );

    
void SetInsertionPos( int x, int y )     { m_pt.x = x; m_pt.y = y; }
    
void SetForegroundColor( D3DXCOLOR clr ) { m_clr = clr; }

    
void Begin();
    HRESULT DrawFormattedTextLine( 
const WCHAR* strMsg,  );
    HRESULT DrawTextLine( 
const WCHAR* strMsg );
    HRESULT DrawFormattedTextLine( RECT 
&rc, DWORD dwFlags, const WCHAR* strMsg,  );
    HRESULT DrawTextLine( RECT 
&rc, DWORD dwFlags, const WCHAR* strMsg );
    
void End();

protected:
    ID3DXFont
*   m_pFont;
    ID3DXSprite
* m_pSprite;
    D3DXCOLOR    m_clr;
    POINT        m_pt;
    
int          m_nLineHeight;
};

 

接著來看看CDXUTHelper的實現(xiàn)部分:

//--------------------------------------------------------------------------------------

CDXUTTextHelper::CDXUTTextHelper( ID3DXFont
* pFont, ID3DXSprite* pSprite, int nLineHeight )
{
    m_pFont          
= pFont;
    m_pSprite      
= pSprite;
    m_clr          
= D3DXCOLOR(1,1,1,1);
    m_pt.x          
= 0
    m_pt.y          
= 0
    m_nLineHeight 
= nLineHeight;
}

//--------------------------------------------------------------------------------------

HRESULT CDXUTTextHelper::DrawFormattedTextLine( 
const WCHAR* strMsg,  )
{
    WCHAR strBuffer[
512];
    
    va_list args;
    va_start(args, strMsg);
    StringCchVPrintf( strBuffer, 
512, strMsg, args );
    strBuffer[
511= L'\0';
    va_end(args);

    
return DrawTextLine( strBuffer );
}

HRESULT CDXUTTextHelper::DrawTextLine( 
const WCHAR* strMsg )
{
    
if( NULL == m_pFont ) 
        
return DXUT_ERR_MSGBOX( L"DrawTextLine", E_INVALIDARG );    

    RECT rc;
    SetRect( 
&rc, m_pt.x, m_pt.y, 00 ); 

    HRESULT hr 
= m_pFont->DrawText( m_pSprite, strMsg, -1&rc, DT_NOCLIP, m_clr );

    
if( FAILED(hr) )
        
return DXTRACE_ERR_MSGBOX( L"DrawText", hr );

    m_pt.y 
+= m_nLineHeight;

    
return S_OK;
}


HRESULT CDXUTTextHelper::DrawFormattedTextLine( RECT 
&rc, DWORD dwFlags, const WCHAR* strMsg,  )
{
    WCHAR strBuffer[
512];
    
    va_list args;
    va_start(args, strMsg);
    StringCchVPrintf( strBuffer, 
512, strMsg, args );
    strBuffer[
511= L'\0';
    va_end(args);

    
return DrawTextLine( rc, dwFlags, strBuffer );
}


HRESULT CDXUTTextHelper::DrawTextLine( RECT 
&rc, DWORD dwFlags, const WCHAR* strMsg )
{
    
if( NULL == m_pFont ) 
        
return DXUT_ERR_MSGBOX( L"DrawTextLine", E_INVALIDARG );
    
    HRESULT hr 
= m_pFont->DrawText( m_pSprite, strMsg, -1&rc, dwFlags, m_clr );

    
if( FAILED(hr) )
        
return DXTRACE_ERR_MSGBOX( L"DrawText", hr );

    m_pt.y 
+= m_nLineHeight;

    
return S_OK;
}


//--------------------------------------------------------------------------------------

void CDXUTTextHelper::Begin()
{
    
if( m_pSprite )
        m_pSprite
->Begin( D3DXSPRITE_ALPHABLEND | D3DXSPRITE_SORT_TEXTURE );
}

void CDXUTTextHelper::End()
{
    
if( m_pSprite )
        m_pSprite
->End();
}

 

代碼相當(dāng)簡潔明了,需要說明的是函數(shù)StringCchVPrintf: 
StringCchVPrintf is a replacement for vsprintf. It accepts a format string and its arguments, provided as a va_list, and returns a formatted string. The size, in characters, of the destination buffer is provided to the function to ensure that StringCchVPrintf does not write past the end of this buffer.

Syntax

HRESULT StringCchVPrintf(      

    LPTSTR pszDest,
    size_t cchDest,
    LPCTSTR pszFormat,
    va_list argList
);

Parameters

pszDest
[out] Pointer to a buffer which receives the formatted, null-terminated string created from pszFormat and argList.
cchDest
[in] Size of the destination buffer, in characters. This value must be sufficiently large to accommodate the final formatted string plus 1 to account for the terminating null character. The maximum number of characters allowed is STRSAFE_MAX_CCH.
pszFormat
[in] Pointer to a buffer containing a printf-style format string. This string must be null-terminated.
argList
[in] A va_list containing the arguments to be inserted into pszFormat.

Return Value

Note that this function returns an HRESULT as opposed to vsprintf, which returns the number of characters written. It is strongly recommended that you use the SUCCEEDED and FAILED macros to test the return value of this function.

S_OK There was sufficient space for the result to be copied to pszDest without truncation and the buffer is null-terminated.
STRSAFE_E_INVALID_PARAMETER The value in cchDest is either 0 or larger than STRSAFE_MAX_CCH.
STRSAFE_E_INSUFFICIENT_BUFFER The copy operation failed due to insufficient buffer space. The destination buffer contains a truncated, null-terminated version of the intended result. In situations where truncation is acceptable, this may not necessarily be seen as a failure condition.
 

Remarks

StringCchVPrintf provides additional processing for proper buffer handling in your code. Poor buffer handling is implicated in many security issues that involve buffer overruns. StringCchVPrintf always null-terminates a non-zero-length destination buffer.

For more information on va_lists, see the conventions defined in Stdarg.h.

StringCchVPrintf can be used in its generic form, or specifically as StringCchVPrintfA (for ANSI strings) or StringCchVPrintfW (for Unicode strings). The form to use is determined by your data.

String Data Type String Literal Function
char "string" StringCchVPrintfA
TCHAR TEXT("string") StringCchVPrintf
WCHAR L"string" StringCchVPrintfW
 

StringCchVPrintf and its ANSI and Unicode variants are replacements for these functions:

  • vsprintf
  • vswprintf
  • wvsprintf
  • wvnsprintf
  • _vstprintf
  • _vsnprintf
  • _vsnwprintf
  • _vsntprintf

Behavior is undefined if the strings pointed to by pszDest, pszFormat, or any argument strings overlap.

Neither pszFormat nor pszDest should be NULL. See StringCchVPrintfEx if you require the handling of null string pointer values.

以及ID3DXSprite::Begin()的聲明:

Prepares a device for drawing sprites.

HRESULT Begin(
DWORD Flags
);

Parameters

Flags
[in] Combination of zero or more flags that describe sprite rendering options. For this method, the valid flags are:
  • D3DXSPRITE_ALPHABLEND
  • D3DXSprite__BILLBOARD
  • D3DXSPRITE_DONOTMODIFY_RENDERSTATE
  • D3DXSPRITE_DONOTSAVESTATE
  • D3DXSPRITE_OBJECTSPACE
  • D3DXSprite__SORT_DEPTH_BACKTOFRONT
  • D3DXSprite__SORT_DEPTH_FRONTTOBACK
  • D3DXSprite__SORT_TEXTURE
For a description of the flags and for information on how to control device state capture and device view transforms, see D3DXSPRITE.

Return Values

If the method succeeds, the return value is S_OK. If the method fails, the return value can be one of the following: D3DERR_INVALIDCALL, D3DERR_OUTOFVIDEOMEMORY, D3DXERR_INVALIDDATA, E_OUTOFMEMORY.

Remarks

This method must be called from inside a IDirect3DDevice9::BeginScene . . . IDirect3DDevice9::EndScene sequence. ID3DXSprite::Begin cannot be used as a substitute for either IDirect3DDevice9::BeginScene or ID3DXRenderToSurface::BeginScene.

This method will set the following states on the device.

Render States:

Type (D3DRENDERSTATETYPE) Value
D3DRS_ALPHABLENDENABLE TRUE
D3DRS_ALPHAFUNC D3DCMP_GREATER
D3DRS_ALPHAREF 0x00
D3DRS_ALPHATESTENABLE AlphaCmpCaps
D3DRS_BLENDOP D3DBLENDOP_ADD
D3DRS_CLIPPING TRUE
D3DRS_CLIPPLANEENABLE FALSE
D3DRS_COLORWRITEENABLE D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED
D3DRS_CULLMODE D3DCULL_NONE
D3DRS_DESTBLEND D3DBLEND_INVSRCALPHA
D3DRS_DIFFUSEMATERIALSOURCE D3DMCS_COLOR1
D3DRS_ENABLEADAPTIVETESSELLATION FALSE
D3DRS_FILLMODE D3DFILL_SOLID
D3DRS_FOGENABLE FALSE
D3DRS_INDEXEDVERTEXBLENDENABLE FALSE
D3DRS_LIGHTING FALSE
D3DRS_RANGEFOGENABLE FALSE
D3DRS_SEPARATEALPHABLENDENABLE FALSE
D3DRS_SHADEMODE D3DSHADE_GOURAUD
D3DRS_SPECULARENABLE FALSE
D3DRS_SRCBLEND D3DBLEND_SRCALPHA
D3DRS_SRGBWRITEENABLE FALSE
D3DRS_STENCILENABLE FALSE
D3DRS_VERTEXBLEND FALSE
D3DRS_WRAP0 0

Texture Stage States:

Stage Identifier Type (D3DTEXTURESTAGESTATETYPE) Value
0 D3DTSS_ALPHAARG1 D3DTA_TEXTURE
0 D3DTSS_ALPHAARG2 D3DTA_DIFFUSE
0 D3DTSS_ALPHAOP D3DTOP_MODULATE
0 D3DTSS_COLORARG1 D3DTA_TEXTURE
0 D3DTSS_COLORARG2 D3DTA_DIFFUSE
0 D3DTSS_COLOROP D3DTOP_MODULATE
0 D3DTSS_TEXCOORDINDEX 0
0 D3DTSS_TEXTURETRANSFORMFLAGS D3DTTFF_DISABLE
1 D3DTSS_ALPHAOP D3DTOP_DISABLE
1 D3DTSS_COLOROP D3DTOP_DISABLE

Sampler States:

Sampler Stage Index Type (D3DSAMPLERSTATETYPE) Value
0 D3DSAMP_ADDRESSU D3DTADDRESS_CLAMP
0 D3DSAMP_ADDRESSV D3DTADDRESS_CLAMP
0 D3DSAMP_MAGFILTER D3DTEXF_ANISOTROPIC if TextureFilterCaps includes D3DPTFILTERCAPS_MAGFANISOTROPIC; otherwise D3DTEXF_LINEAR
0 D3DSAMP_MAXMIPLEVEL 0
0 D3DSAMP_MAXANISOTROPY MaxAnisotropy
0 D3DSAMP_MINFILTER D3DTEXF_ANISOTROPIC if TextureFilterCaps includes D3DPTFILTERCAPS_MINFANISOTROPIC; otherwise D3DTEXF_LINEAR
0 D3DSAMP_MIPFILTER D3DTEXF_LINEAR if TextureFilterCaps includes D3DPTFILTERCAPS_MIPFLINEAR; otherwise D3DTEXF_POINT
0 D3DSAMP_MIPMAPLODBIAS 0
0 D3DSAMP_SRGBTEXTURE 0

Note    This method disables N-patches.

D3DXSPRITE

The following flags are used to specify sprite rendering options to the flags parameter in the ID3DXSprite::Begin method:

#define Description
D3DXSPRITE_DONOTSAVESTATE The device state is not to be saved or restored when ID3DXSprite::Begin or ID3DXSprite::End is called.
D3DXSPRITE_DONOTMODIFY_RENDERSTATE The device render state is not to be changed when ID3DXSprite::Begin is called. The device is assumed to be in a valid state to draw vertices containing UsageIndex = 0 in the D3DDECLUSAGE_POSITION, D3DDECLUSAGE_TEXCOORD, and D3DDECLUSAGE_COLOR data.
D3DXSPRITE_OBJECTSPACE The world, view, and projection transforms are not modified. The transforms currently set to the device are used to transform the sprites when the batched sprites are drawn (when ID3DXSprite::Flush or ID3DXSprite::End is called). If this flag is not specified, then world, view, and projection transforms are modified so that sprites are drawn in screen-space coordinates.
D3DXSPRITE_BILLBOARD Each sprite will be rotated about its center so that it is facing the viewer. ID3DXSprite::SetWorldViewLH or ID3DXSprite::SetWorldViewRH must be called first.
D3DXSPRITE_ALPHABLEND Enables alpha blending with D3DRS_ALPHATESTENABLE set to TRUE (for nonzero alpha). D3DBLEND_SRCALPHA will be the source blend state, and D3DBLEND_INVSRCALPHA will be the destination blend state in calls to IDirect3DDevice9::SetRenderState. See Alpha Blending State (Direct3D 9). ID3DXFont expects this flag to be set when drawing text.
D3DXSPRITE_SORT_TEXTURE Sort sprites by texture prior to drawing. This can improve performance when drawing non-overlapping sprites of uniform depth.

You may also combine D3DXSPRITE_SORT_TEXTURE with either D3DXSPRITE_SORT_DEPTH_FRONTTOBACK or D3DXSPRITE_SORT_DEPTH_BACKTOFRONT. This will sort the list of sprites by depth first and texture second.

D3DXSPRITE_SORT_DEPTH_FRONTTOBACK Sprites are sorted by depth in front-to-back order prior to drawing. This procedure is recommended when drawing opaque sprites of varying depths.

You may combine D3DXSPRITE_SORT_DEPTH_FRONTTOBACK with D3DXSPRITE_SORT_TEXTURE to sort first by depth, and second by texture.

D3DXSPRITE_SORT_DEPTH_BACKTOFRONT Sprites are sorted by depth in back-to-front order prior to drawing. This procedure is recommended when drawing transparent sprites of varying depths.

You may combine D3DXSPRITE_SORT_DEPTH_BACKTOFRONT with D3DXSPRITE_SORT_TEXTURE to sort first by depth, and second by texture.

D3DXSPRITE_DO_NOT_ADDREF_TEXTURE Disables calling AddRef() on every draw, and Release() on Flush() for better performance.

 

初始化ID3DXSprite和ID3DXFont對象

在回調(diào)函數(shù)OnCreateDevice()中創(chuàng)建ID3DXFont對象:

//--------------------------------------------------------------------------------------
// Create any D3DPOOL_MANAGED resources here
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc,
void* pUserContext )
{
D3DXCreateFont(pd3dDevice, 18, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_DONTCARE, L"Arial", &g_font);
    return S_OK;
}

 

繪制文本

//--------------------------------------------------------------------------------------
// Render the helper information
//--------------------------------------------------------------------------------------
void RenderText()
{
CDXUTTextHelper text_helper(g_font, g_text_sprite, 20);
	text_helper.Begin();
	// show frame and device states
text_helper.SetInsertionPos(5, 5);
text_helper.SetForegroundColor( D3DXCOLOR(1.0f, 0.475f, 0.0f, 1.0f) );
text_helper.DrawTextLine( DXUTGetFrameStats(true) );
text_helper.DrawTextLine( DXUTGetDeviceStats() );
	// show other simple information
text_helper.SetForegroundColor( D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f) );
text_helper.DrawTextLine(L"Put whatever misc status here");
	// show helper information
	const D3DSURFACE_DESC* surface_desc = DXUTGetBackBufferSurfaceDesc();
	if(g_show_help)
{
text_helper.SetInsertionPos(10, surface_desc->Height - 15 * 6);
text_helper.SetForegroundColor( D3DXCOLOR(1.0f, 0.475f, 0.0f, 1.0f) );
text_helper.DrawTextLine(L"Controls (F1 to hide):");
		text_helper.SetInsertionPos(40, surface_desc->Height - 15 * 5);
text_helper.DrawTextLine(L"Quir: ESC");
}
else
{
text_helper.SetInsertionPos(10, surface_desc->Height - 15 * 4);
text_helper.SetForegroundColor( D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f) );
text_helper.DrawTextLine(L"Press F1 for help");
}
	text_helper.End();
}

 

處理鍵盤消息

程序通過鍵盤上的"F1"鍵切換來表明是否顯示簡單幫助文本,處理代碼如下:

//--------------------------------------------------------------------------------------
// Handle keybaord event
//--------------------------------------------------------------------------------------
void CALLBACK OnKeyboardProc(UINT charater, bool is_key_down, bool is_alt_down, void* user_context)
{
if(is_key_down)
{
switch(charater)
{
case VK_F1:
g_show_help = !g_show_help;
break;
}
}
}

 

運行效果圖:

 

主程序:

#include "dxstdafx.h"
#include 
"resource.h"

#pragma warning(disable : 
4127)

ID3DXFont
*        g_font;
ID3DXSprite
*    g_text_sprite;
bool            g_show_help = true;

#define release_com(p)    do { if(p) { (p)->Release(); (p) = NULL; } } while(0)

//--------------------------------------------------------------------------------------
// Rejects any devices that aren't acceptable by returning false
//--------------------------------------------------------------------------------------
bool CALLBACK IsDeviceAcceptable( D3DCAPS9* pCaps, D3DFORMAT AdapterFormat, 
                                  D3DFORMAT BackBufferFormat, 
bool bWindowed, void* pUserContext )
{
    
// Typically want to skip backbuffer formats that don't support alpha blending

    IDirect3D9
* pD3D = DXUTGetD3DObject(); 

    
if( FAILED( pD3D->CheckDeviceFormat( pCaps->AdapterOrdinal, pCaps->DeviceType, AdapterFormat, 
                    D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_TEXTURE, BackBufferFormat ) ) )
        
return false;

    
return true;
}


//--------------------------------------------------------------------------------------
// Before a device is created, modify the device settings as needed.
//--------------------------------------------------------------------------------------
bool CALLBACK ModifyDeviceSettings( DXUTDeviceSettings* pDeviceSettings, const D3DCAPS9* pCaps, void* pUserContext )
{
    
// If video card does not support hardware vertex processing, then uses sofaware vertex processing.
    if((pCaps->DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0)
        pDeviceSettings
->BehaviorFlags = D3DCREATE_SOFTWARE_VERTEXPROCESSING;

    
static bool is_first_time = true;

    
if(is_first_time)
    {
        is_first_time 
= false;

        
// if using reference device, then pop a warning message box.
        if(pDeviceSettings->DeviceType == D3DDEVTYPE_REF)
            DXUTDisplaySwitchingToREFWarning();
    }

    
return true;
}


//--------------------------------------------------------------------------------------
// Create any D3DPOOL_MANAGED resources here 
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, 
                                 
void* pUserContext )
{
    D3DXCreateFont(pd3dDevice, 
180, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY,
                   DEFAULT_PITCH 
| FF_DONTCARE, L"Arial"&g_font);

    
return S_OK;
}


//--------------------------------------------------------------------------------------
// Create any D3DPOOL_DEFAULT resources here 
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnResetDevice( IDirect3DDevice9* pd3dDevice, 
                                
const D3DSURFACE_DESC* pBackBufferSurfaceDesc, 
                                
void* pUserContext )
{
    g_font
->OnResetDevice();
    D3DXCreateSprite(pd3dDevice, 
&g_text_sprite);

    
// setup view matrix

    D3DXMATRIX mat_view;
    D3DXVECTOR3 eye(
0.0f0.0f-5.0f);
    D3DXVECTOR3  at(
0.0f0.0f,  0.0f);
    D3DXVECTOR3  up(
0.0f1.0f,  0.0f);

    D3DXMatrixLookAtLH(
&mat_view, &eye, &at, &up);
    pd3dDevice
->SetTransform(D3DTS_VIEW, &mat_view);

    
// set projection matrix
    D3DXMATRIX mat_proj;
    
float aspect = (float)pBackBufferSurfaceDesc->Width / pBackBufferSurfaceDesc->Height;
    D3DXMatrixPerspectiveFovLH(
&mat_proj, D3DX_PI/4, aspect, 1.0f100.0f);
    pd3dDevice
->SetTransform(D3DTS_PROJECTION, &mat_proj);

    
return S_OK;
}

//--------------------------------------------------------------------------------------
// Release resources created in the OnResetDevice callback here 
//--------------------------------------------------------------------------------------
void CALLBACK OnLostDevice( void* pUserContext )
{
    g_font
->OnLostDevice();
    release_com(g_text_sprite);
}


//--------------------------------------------------------------------------------------
// Release resources created in the OnCreateDevice callback here
//--------------------------------------------------------------------------------------
void CALLBACK OnDestroyDevice( void* pUserContext )
{
    release_com(g_font);
}

//--------------------------------------------------------------------------------------
// Handle updates to the scene
//--------------------------------------------------------------------------------------
void CALLBACK OnFrameMove( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
{
}

//--------------------------------------------------------------------------------------
// Render the helper information
//--------------------------------------------------------------------------------------
void RenderText()
{
    CDXUTTextHelper text_helper(g_font, g_text_sprite, 
20);
    
    text_helper.Begin();

    
// show frame and device states
    text_helper.SetInsertionPos(55);
    text_helper.SetForegroundColor( D3DXCOLOR(
1.0f0.475f0.0f1.0f) );
    text_helper.DrawTextLine( DXUTGetFrameStats(
true) );
    text_helper.DrawTextLine( DXUTGetDeviceStats() );

    
// show other simple information
    text_helper.SetForegroundColor( D3DXCOLOR(1.0f1.0f1.0f1.0f) );
    text_helper.DrawTextLine(L
"Put whatever misc status here");

    
// show helper information
    
    
const D3DSURFACE_DESC* surface_desc = DXUTGetBackBufferSurfaceDesc();

    
if(g_show_help)
    {
        text_helper.SetInsertionPos(
10, surface_desc->Height - 15 * 6);
        text_helper.SetForegroundColor( D3DXCOLOR(
1.0f0.475f0.0f1.0f) );
        text_helper.DrawTextLine(L
"Controls (F1 to hide):");
        
        text_helper.SetInsertionPos(
40, surface_desc->Height - 15 * 5);
        text_helper.DrawTextLine(L
"Quir: ESC");
    }
    
else
    {
        text_helper.SetInsertionPos(
10, surface_desc->Height - 15 * 4);
        text_helper.SetForegroundColor( D3DXCOLOR(
1.0f1.0f1.0f1.0f) );
        text_helper.DrawTextLine(L
"Press F1 for help");
    }

    text_helper.End();
}

//--------------------------------------------------------------------------------------
// Render the scene 
//--------------------------------------------------------------------------------------
void CALLBACK OnFrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
{
    HRESULT hr;

    
// Clear the render target and the zbuffer 
    V( pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(0555), 1.0f0) );

    
// Render the scene
    if( SUCCEEDED( pd3dDevice->BeginScene() ) )
    {
        RenderText();
        V( pd3dDevice
->EndScene() );
    }
}


//--------------------------------------------------------------------------------------
// Handle messages to the application 
//--------------------------------------------------------------------------------------
LRESULT CALLBACK MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, 
                          
bool* pbNoFurtherProcessing, void* pUserContext )
{
    
return 0;
}


//--------------------------------------------------------------------------------------
// Handle keybaord event
//--------------------------------------------------------------------------------------
void CALLBACK OnKeyboardProc(UINT charater, bool is_key_down, bool is_alt_down, void* user_context)
{
    
if(is_key_down)
    {
        
switch(charater)
        {
        
case VK_F1:
            g_show_help 
= !g_show_help;
            
break;
        }
    }
}


//--------------------------------------------------------------------------------------
// Initialize everything and go into a render loop
//--------------------------------------------------------------------------------------
INT WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, int )
{
    
// Enable run-time memory check for debug builds.
#if defined(DEBUG) | defined(_DEBUG)
    _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF 
| _CRTDBG_LEAK_CHECK_DF );
#endif

    
// Set the callback functions
    DXUTSetCallbackDeviceCreated( OnCreateDevice );
    DXUTSetCallbackDeviceReset( OnResetDevice );
    DXUTSetCallbackDeviceLost( OnLostDevice );
    DXUTSetCallbackDeviceDestroyed( OnDestroyDevice );
    DXUTSetCallbackMsgProc( MsgProc );
    DXUTSetCallbackFrameRender( OnFrameRender );
    DXUTSetCallbackFrameMove( OnFrameMove );
    DXUTSetCallbackKeyboard(OnKeyboardProc);
   
    
// TODO: Perform any application-level initialization here

    
// Initialize DXUT and create the desired Win32 window and Direct3D device for the application
    DXUTInit( truetruetrue ); // Parse the command line, handle the default hotkeys, and show msgboxes
    DXUTSetCursorSettings( truetrue ); // Show the cursor and clip it when in full screen
    DXUTCreateWindow( L"AddText" );
    DXUTCreateDevice( D3DADAPTER_DEFAULT, 
true640480, IsDeviceAcceptable, ModifyDeviceSettings );

    
// Start the render loop
    DXUTMainLoop();

    
// TODO: Perform any application-level cleanup here

    
return DXUTGetExitCode();
}

 

 

下載示例工程


posted on 2008-05-17 17:38 lovedday 閱讀(2753) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發(fā)表評論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


公告

導(dǎo)航

統(tǒng)計

常用鏈接

隨筆分類(178)

3D游戲編程相關(guān)鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲日产国产精品| 欧美激情视频免费观看| 久久国产精品一区二区三区四区| 国产日韩欧美一区二区三区在线观看| 久久久久一本一区二区青青蜜月| 在线视频精品| 一本色道久久综合精品竹菊| 亚洲一区二区三区四区五区午夜| 在线看欧美视频| 亚洲视频二区| 亚洲制服丝袜在线| 久久久99精品免费观看不卡| 亚洲香蕉在线观看| 欧美亚洲视频一区二区| 久久久国产精品一区二区中文 | 国产精品xxx在线观看www| 欧美亚男人的天堂| 亚洲人成网站777色婷婷| 日韩天堂在线视频| 在线观看精品视频| 欧美在线免费视屏| 久久久高清一区二区三区| 国产日本欧美一区二区三区在线| 午夜精品免费| 欧美成人一区在线| 午夜欧美不卡精品aaaaa| 亚洲高清不卡av| 欧美日韩亚洲一区在线观看| 亚洲欧洲美洲综合色网| 1024国产精品| 一本色道久久| 亚洲视频二区| 一本色道久久88亚洲综合88| 欧美午夜寂寞影院| 亚洲欧美日韩视频二区| 一区二区毛片| 免费亚洲一区二区| 欧美一区二区三区视频在线 | 在线观看一区| 国产精品v日韩精品| 欧美日在线观看| 国产精品午夜电影| 国产日本亚洲高清| 在线视频国产日韩| 亚洲免费av电影| 羞羞漫画18久久大片| 久久久久久久97| 日韩视频一区二区三区在线播放免费观看 | 欧美日韩a区| 日韩视频在线一区二区三区| 亚洲国产精品视频| 另类av导航| 一区二区日韩伦理片| 夜夜夜精品看看| 国产毛片精品国产一区二区三区| 中文在线资源观看网站视频免费不卡| 亚洲国产精品久久人人爱蜜臀 | 午夜精品一区二区三区在线视| 日韩特黄影片| 国产欧美日韩综合| 亚洲电影av| 国产精品视频你懂的| 久久精品天堂| 欧美精品18videos性欧美| 亚洲视频每日更新| 久久精品人人做人人综合| 欧美在线视频日韩| 亚洲国产三级网| 在线视频你懂得一区| 国产区欧美区日韩区| 久久人人看视频| 国产精品激情偷乱一区二区∴| 快播亚洲色图| 欧美性理论片在线观看片免费| 久久免费视频观看| 国产精品扒开腿做爽爽爽软件 | 欧美理论在线播放| 久热精品视频在线| 国产日韩欧美视频| 日韩视频一区二区三区在线播放 | 亚洲丶国产丶欧美一区二区三区 | 亚洲一区二区在线看| 亚洲在线1234| 在线观看久久av| 久热国产精品视频| 欧美精品1区| 久久综合九色99| 国产精品日日摸夜夜添夜夜av| 亚洲免费小视频| 欧美日本亚洲韩国国产| 校园激情久久| 欧美久久电影| 欧美大片在线观看一区| 国产精品一级| 亚洲尤物视频在线| 亚洲伦理在线观看| 午夜视频在线观看一区二区三区| 亚洲一区二区三区在线视频| 亚洲国产日韩欧美在线图片| 欧美在线观看一区二区| 午夜久久99| 欧美日韩不卡合集视频| 欧美成人免费大片| 91久久精品日日躁夜夜躁欧美| 午夜精品久久久久久久久久久久久 | 亚洲精品一线二线三线无人区| 蜜桃精品一区二区三区| 亚洲视频在线一区| 麻豆成人在线播放| 亚洲视频在线观看一区| 国产在线精品一区二区夜色| 欧美不卡视频一区发布| 一区二区欧美日韩视频| 久久综合九色综合欧美就去吻| 韩国久久久久| 欧美日韩亚洲国产精品| 久久久久青草大香线综合精品| 美女黄网久久| 亚洲午夜精品久久| 国产婷婷色一区二区三区在线| 久久亚洲精品伦理| 在线综合亚洲| 亚洲经典一区| 久久精品成人一区二区三区蜜臀| 亚洲欧洲日韩在线| 国产美女精品视频| 欧美日韩dvd在线观看| 午夜一区二区三视频在线观看 | 国产精品一二三四| 亚洲永久精品大片| 欧美国产日韩在线观看| 亚洲免费在线观看| 日韩视频免费观看高清在线视频 | 欧美日本国产在线| 久久久中精品2020中文| 日韩一二三区视频| 亚洲欧洲中文日韩久久av乱码| 亚洲人成网在线播放| 亚洲欧美日韩一区| 欧美刺激性大交免费视频| 一区二区三区欧美视频| 久久精品中文字幕一区二区三区 | 亚洲乱码日产精品bd| 久久综合伊人77777| 欧美自拍偷拍午夜视频| 久久青草欧美一区二区三区| 久久久另类综合| 欧美激情亚洲精品| 亚洲国产高清视频| 99www免费人成精品| 9l国产精品久久久久麻豆| 欧美一级艳片视频免费观看| 欧美激情精品久久久久| 国产精品美女久久久久久2018| 亚洲国产精品va在线看黑人动漫 | 亚洲精品中文在线| 久久久久久久尹人综合网亚洲| 欧美美女喷水视频| 亚洲激情不卡| 欧美在线一区二区| 国内精品免费午夜毛片| 午夜亚洲一区| 99re6这里只有精品| 久久综合网络一区二区| 国产一区在线免费观看| 久久精品国产亚洲高清剧情介绍| 亚洲国产激情| 欧美黄色免费| 亚洲经典自拍| 欧美电影打屁股sp| 亚洲黄网站在线观看| 欧美激情亚洲国产| 免费国产自线拍一欧美视频| 国产亚洲毛片在线| 亚洲一区免费网站| 日韩视频―中文字幕| 国产欧美日韩在线视频| 欧美自拍偷拍| 久久精品日韩欧美| 国产综合视频在线观看| 亚洲二区精品| 欧美激情网友自拍| 91久久久久久| av不卡在线观看| 国产精品乱子久久久久| 老司机午夜精品视频| 狠色狠色综合久久| 欧美成人精品福利| 国产精品入口麻豆原神| 久久嫩草精品久久久精品一| 欧美精品导航| 最新成人av网站| 樱桃国产成人精品视频| 亚洲摸下面视频| 欧美在线播放一区| 国产区精品在线观看| 欧美在线网站| 久久午夜羞羞影院免费观看| 亚洲精品一级| 亚洲在线1234|