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

天行健 君子當自強而不息

D3D中的字體繪制(2)

9.3 D3DXCreateText

最后的函數是被用來創建一個3D 文字網格,圖9.1顯示了實例“D3DXCreateText”所繪制的3D文本網格。

 

該函數的原型是:

HRESULT D3DXCreateText(

       LPDIRECT3DDEVICE9 pDevice,

       HDC hDC,

       LPCTSTR pText,

       FLOAT Deviation,

       FLOAT Extrusion,

       LPD3DXMESH* ppMesh,

       LPD3DXBUFFER* ppAdjacency,

       LPGLYPHMETRICSFLOAT pGlyphMetrics

);

這個函數如果調用成功則返回D3D_OK。

pDevice — 和mesh關聯的device。

hDC — 我們將要用來產生mesh的包含描述字體的設備環境句柄。

pText — 指向以null結束的字符串的指針,此字符串是用來指定創建什么文字mesh。

Deviation — 字型輪廓段數間距,該值必須大于等于0。當它為0時,段數等于字體原始設計單位(該值越接近0,那么字體就越光滑)。

Extrusion — 文字在z軸方向的深度。

ppMesh — 返回創建的mesh。

ppAdjacency — 返回創建mesh的相關信息。假如你不需要它可以將其指定為null。

pGlyphMetrics — 一個指向LPGLYPHMETRICSFLOAT結構數組的指針,它包含了字型米數據。假如你不關心此數據,你可以把它設置為0。


來看一個示例,首先來看看其中用到的API函數使用說明:

The CreateCompatibleDC function creates a memory device context (DC) compatible with the specified device.

HDC CreateCompatibleDC(
HDC
hdc // handle to DC
);

Parameters

hdc
[in] Handle to an existing DC. If this handle is NULL, the function creates a memory DC compatible with the application's current screen.

Return Values

If the function succeeds, the return value is the handle to a memory DC.

If the function fails, the return value is NULL.

Windows NT/2000/XP: To get extended error information, call GetLastError.

Remarks

A memory DC exists only in memory. When the memory DC is created, its display surface is exactly one monochrome pixel wide and one monochrome pixel high. Before an application can use a memory DC for drawing operations, it must select a bitmap of the correct width and height into the DC. To select a bitmap into a DC, use the CreateCompatibleBitmap function, specifying the height, width, and color organization required.

When a memory DC is created, all attributes are set to normal default values. The memory DC can be used as a normal DC. You can set the attributes; obtain the current settings of its attributes; and select pens, brushes, and regions.

The CreateCompatibleDC function can only be used with devices that support raster operations. An application can determine whether a device supports these operations by calling the GetDeviceCaps function.

When you no longer need the memory DC, call the DeleteDC function.

Windows 2000 and later: If hdc is NULL, the thread that calls CreateCompatibleDC owns the HDC that is created. When this thread is destroyed, the HDC is no longer valid. Thus, if you create the HDC andpass it to another thread, then exit the first thread, the second thread will not be able to use the HDC.

ICM: If the DC that is passed to this function is enabled for Independent Color Management (ICM), the DC created by the function is ICM-enabled. The source and destination color spaces are specified in the DC.

The CreateFontIndirect function creates a logical font that has the specified characteristics. The font can subsequently be selected as the current font for any device context.

HFONT CreateFontIndirect(
CONST LOGFONT*
lplf // characteristics
);

Parameters

lplf
[in] Pointer to a LOGFONT structure that defines the characteristics of the logical font.

Return Values

If the function succeeds, the return value is a handle to a logical font.

If the function fails, the return value is NULL.

Windows NT/2000/XP: To get extended error information, call GetLastError.

Remarks

The CreateFontIndirect function creates a logical font with the characteristics specified in the LOGFONT structure. When this font is selected by using the SelectObject function, GDI's font mapper attempts to match the logical font with an existing physical font. If it fails to find an exact match, it provides an alternative whose characteristics match as many of the requested characteristics as possible.

To get the appropriate font on different language versions of the OS, call EnumFontFamiliesEx with the desired font characteristics in the LOGFONT structure, retrieve the appropriate typeface name, and create the font using CreateFont or CreateFontIndirect.

When you no longer need the font, call the DeleteObject function to delete it.

The SelectObject function selects an object into the specified device context (DC). The new object replaces the previous object of the same type.

HGDIOBJ SelectObject(
HDC
hdc, // handle to DC
HGDIOBJ hgdiobj // handle to object
);

Parameters

hdc
[in] Handle to the DC.
hgdiobj
[in] Handle to the object to be selected. The specified object must have been created by using one of the following functions.
 

Return Values

If the selected object is not a region and the function succeeds, the return value is a handle to the object being replaced. If the selected object is a region and the function succeeds, the return value is one of the following values.

Value Meaning
SIMPLEREGION Region consists of a single rectangle.
COMPLEXREGION Region consists of more than one rectangle.
NULLREGION Region is empty.

If an error occurs and the selected object is not a region, the return value is NULL. Otherwise, it is HGDI_ERROR.

Remarks

This function returns the previously selected object of the specified type. An application should always replace a new object with the original, default object after it has finished drawing with the new object.

An application cannot select a bitmap into more than one DC at a time.

ICM: If the object being selected is a brush or a pen, color management is performed.


主程序:

//////////////////////////////////////////////////////////////////////////////////////////////////
// Demonstrates how to create and render 3D text using D3DXCreateText.
//////////////////////////////////////////////////////////////////////////////////////////////////

#include 
"d3dUtility.h"

#pragma warning(disable : 
4996)

const int WIDTH  = 640;
const int HEIGHT = 480;

IDirect3DDevice9
*    g_d3d_device; 
ID3DXMesh
*            g_text_mesh;

////////////////////////////////////////////////////////////////////////////////////////////////

bool Setup()
{
    
// Get a handle to a device context
    HDC hdc = CreateCompatibleDC(NULL);

    
// Describe the font we want.

    LOGFONT lf;
    ZeroMemory(
&lf, sizeof(LOGFONT));

    lf.lfHeight         
= 25;    // in logical units
    lf.lfWidth          = 12;    // in logical units
    lf.lfEscapement     = 0;        
    lf.lfOrientation    
= 0;     
    lf.lfWeight         
= 500;   // boldness, range 0(light) - 1000(bold)
    lf.lfItalic         = FALSE;   
    lf.lfUnderline      
= FALSE;    
    lf.lfStrikeOut      
= FALSE;    
    lf.lfCharSet        
= DEFAULT_CHARSET;
    lf.lfOutPrecision   
= 0;              
    lf.lfClipPrecision  
= 0;          
    lf.lfQuality        
= 0;           
    lf.lfPitchAndFamily 
= 0;   

    strcpy(lf.lfFaceName, 
"Times New Roman"); // font style

    
// Create the font and select it with the device context.
    HFONT hFont = CreateFontIndirect(&lf);
    HFONT hFontOld 
= (HFONT)SelectObject(hdc, hFont); 

    
// Create the text mesh based on the selected font in the HDC.
    D3DXCreateText(g_d3d_device, hdc, "Direct3D"0.001f0.4f&g_text_mesh, NULL, NULL);    
    
    
// Restore the old font and free the acquired HDC.    
    SelectObject(hdc, hFontOld);
    DeleteObject(hFont);
    DeleteDC(hdc);

    
// Lights

    D3DXVECTOR3 dir(
0.0f-0.5f1.0f);
    D3DXCOLOR col 
= WHITE;
    D3DLIGHT9 light 
= InitDirectionalLight(&dir, &col);

    g_d3d_device
->SetLight(0&light);
    g_d3d_device
->LightEnable(0, TRUE);

    g_d3d_device
->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE);
    g_d3d_device
->SetRenderState(D3DRS_SPECULARENABLE, TRUE);

    
// Set camera

    D3DXVECTOR3 pos(
0.0f1.5f-3.3f);
    D3DXVECTOR3 target(
0.0f0.0f0.0f);
    D3DXVECTOR3 up(
0.0f1.0f0.0f);

    D3DXMATRIX V;
    D3DXMatrixLookAtLH(
&V, &pos, &target, &up);
    g_d3d_device
->SetTransform(D3DTS_VIEW, &V);
    
    
// Set projection matrix.    
    D3DXMATRIX proj;
    D3DXMatrixPerspectiveFovLH(
&proj, D3DX_PI * 0.25f, (float)WIDTH / HEIGHT, 0.01f1000.0f);
    g_d3d_device
->SetTransform(D3DTS_PROJECTION, &proj);

    
return true;
}

void Cleanup()
{
    Release
<ID3DXMesh*>(g_text_mesh);
}

bool Display(float timeDelta)
{
    
// Update: Spin the 3D text.

    D3DXMATRIX y_rot_matrix, tran_matrix;

    
static float y = 0.0f;
    D3DXMatrixRotationY(
&y_rot_matrix, y);
    y 
+= timeDelta;

    
if(y >= 6.28f)
        y 
= 0.0f;

    D3DXMatrixTranslation(
&tran_matrix, -1.6f0.0f0.0f);
    tran_matrix 
*= y_rot_matrix;

    g_d3d_device
->SetTransform(D3DTS_WORLD, &tran_matrix);
    
    
// Render

    g_d3d_device
->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x000000001.0f0);

    g_d3d_device
->BeginScene();
    g_d3d_device
->SetMaterial(&WHITE_MTRL);
    g_text_mesh
->DrawSubset(0);
    g_d3d_device
->EndScene();

    g_d3d_device
->Present(NULL, NULL, NULL, NULL);

    
return true;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    
switch( msg )
    {
    
case WM_DESTROY:
        PostQuitMessage(
0);
        
break;
        
    
case WM_KEYDOWN:
        
if( wParam == VK_ESCAPE )
            DestroyWindow(hwnd);
        
break;
    }

    
return DefWindowProc(hwnd, msg, wParam, lParam);
}

int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE prevInstance, PSTR cmdLine, int showCmd)
{
    
if(!InitD3D(hinstance, WIDTH, HEIGHT, true, D3DDEVTYPE_HAL, &g_d3d_device))
    {
        MessageBox(
0"InitD3D() - FAILED"00);
        
return 0;
    }
        
    
if(!Setup())
    {
        MessageBox(
0"Setup() - FAILED"00);
        
return 0;
    }

    EnterMsgLoop( Display );
    Cleanup();

    g_d3d_device
->Release();

    
return 0;
}


下載源程序

posted on 2008-03-26 18:50 lovedday 閱讀(1749) 評論(0)  編輯 收藏 引用

公告

導航

統計

常用鏈接

隨筆分類(178)

3D游戲編程相關鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            欧美成人自拍视频| 亚洲专区免费| 国产一区二区三区无遮挡| 亚洲国产第一页| 久久只精品国产| 欧美伊人精品成人久久综合97| 国产精品丝袜xxxxxxx| 久久免费一区| 亚洲日韩成人| 欧美一区二区精品在线| 91久久香蕉国产日韩欧美9色| 欧美日韩国产丝袜另类| 一区二区三区.www| 99国产精品国产精品毛片| 免费国产一区二区| 亚洲欧洲在线一区| 激情五月婷婷综合| 国产精品你懂得| 欧美精品一区在线| 欧美成人一区二区| 国产精品久久久久秋霞鲁丝 | 国产欧美日韩视频在线观看| 麻豆精品精品国产自在97香蕉| 亚欧成人在线| 性欧美大战久久久久久久免费观看| 午夜激情亚洲| 亚洲欧美清纯在线制服| 久久久久久国产精品mv| 99精品视频网| 欧美高清视频一区二区| 亚洲国产精品va在线看黑人| 香蕉视频成人在线观看| 在线亚洲欧美专区二区| 亚洲成人中文| 久久综合五月| 日韩一级在线观看| 亚洲精品人人| 国产精品美女久久久久久2018| 亚洲综合国产精品| 香蕉久久夜色精品| 国产一级一区二区| 99人久久精品视频最新地址| 性做久久久久久免费观看欧美| 亚洲一区二区三区中文字幕在线| 亚洲免费在线观看| 亚洲高清视频在线观看| 最新亚洲激情| 欧美成人午夜剧场免费观看| 亚洲精品九九| 亚洲小视频在线观看| 国产精品一区一区三区| 久久久综合网| 亚洲三级影片| 影音先锋成人资源站| 欧美高清视频免费观看| 亚洲成人在线网| 亚洲午夜激情免费视频| 国产欧美一区二区精品性| 蜜臀av一级做a爰片久久| 亚洲人成网在线播放| 国产精品成人免费| 久久婷婷蜜乳一本欲蜜臀| 亚洲美女淫视频| 麻豆精品传媒视频| 在线精品福利| 国产精品网站在线| 免费看av成人| 亚洲欧美一区二区三区久久| 亚洲国产精品热久久| 久久精品91久久久久久再现| 一本色道久久88综合日韩精品 | 亚洲人成77777在线观看网| 久久精品91| 亚洲视频在线观看免费| 伊人久久大香线| 国产精品综合久久久| 欧美日韩国产在线| 久久久久久久成人| 欧美一级理论性理论a| 夜夜狂射影院欧美极品| 亚洲二区视频在线| 久久午夜激情| 欧美在线一区二区| 亚洲在线播放电影| 99视频一区二区| 亚洲一区二区成人| 久久久午夜电影| 亚洲香蕉伊综合在人在线视看| 欧美福利视频在线观看| 久久高清国产| 欧美在线亚洲综合一区| 亚洲电影天堂av| 亚洲综合激情| 韩日成人av| 亚洲婷婷综合久久一本伊一区| 国内精品久久久久久久果冻传媒| 亚洲精品视频一区二区三区| 国内揄拍国内精品少妇国语| 欧美视频免费在线观看| 久久综合伊人77777| 欧美在线日韩在线| 亚洲欧美怡红院| 亚洲午夜一区二区三区| 一本色道久久加勒比88综合| 亚洲精品日产精品乱码不卡| 欧美激情亚洲激情| 亚洲国产精品传媒在线观看 | 99国产精品久久久久久久| 精品1区2区3区4区| 亚洲高清av| 91久久精品国产91性色tv| 在线看日韩欧美| 亚洲国产成人porn| 亚洲每日在线| 亚洲图片欧洲图片日韩av| 一区二区国产日产| 亚洲欧美国产高清va在线播| 一区二区三区黄色| 欧美激情综合在线| 欧美国产日韩免费| 精品51国产黑色丝袜高跟鞋| 篠田优中文在线播放第一区| 国产精品99久久久久久www| 久久亚洲精品一区二区| 免费观看久久久4p| 亚洲欧美99| 欧美一级久久| 久久精品视频在线观看| 久久久久se| 在线一区二区三区做爰视频网站| 欧美在线看片| 欧美在线播放一区| 小黄鸭精品aⅴ导航网站入口| 亚洲专区在线视频| 亚洲一二三区精品| 亚洲一区二区三区在线看| 亚洲综合99| 久久五月婷婷丁香社区| 美女日韩在线中文字幕| 欧美一区免费视频| 红桃av永久久久| 欧美福利视频网站| 国产啪精品视频| 欧美色欧美亚洲另类二区| 91久久夜色精品国产九色| 亚洲激情网站免费观看| 99这里只有久久精品视频| 午夜精品偷拍| 欧美成人国产一区二区| 久久国产主播| 亚洲人成高清| 久久综合九色| 亚洲精品视频在线观看网站| 亚洲天堂网在线观看| 久久免费高清| 国产精品久久久久久亚洲毛片| 国产专区一区| 亚洲一区三区在线观看| 欧美~级网站不卡| 亚洲一区美女视频在线观看免费| 久久天天狠狠| 国产精品美女主播| 日韩视频在线免费观看| 久久狠狠婷婷| 制服丝袜亚洲播放| 欧美r片在线| 含羞草久久爱69一区| 亚洲性感美女99在线| 欧美国产激情| 久久成人免费网| 欧美调教视频| 亚洲美女在线观看| 亚洲深夜福利网站| 在线观看亚洲精品| 亚洲欧美韩国| 亚洲经典自拍| 久久人91精品久久久久久不卡| 欧美视频中文字幕在线| 尤物精品在线| 久久精品夜色噜噜亚洲a∨| 一区二区高清在线观看| 欧美电影在线| 亚洲国产视频一区二区| 欧美一区二区三区男人的天堂 | 国产美女诱惑一区二区| 欧美三级午夜理伦三级中文幕| 国产精品毛片在线看| 欧美极品在线观看| 久久婷婷人人澡人人喊人人爽| 久久av一区二区三区亚洲| 亚洲欧美网站| 久久精品在线免费观看| 欧美性大战xxxxx久久久| 羞羞视频在线观看欧美| 久久噜噜亚洲综合| 制服诱惑一区二区| 亚洲自拍偷拍一区| 蜜臀av在线播放一区二区三区| 欧美色欧美亚洲高清在线视频| 国产在线拍偷自揄拍精品|