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

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

D3D中的字體繪制(2)

9.3 D3DXCreateText

最后的函數(shù)是被用來創(chuàng)建一個(gè)3D 文字網(wǎng)格,圖9.1顯示了實(shí)例“D3DXCreateText”所繪制的3D文本網(wǎng)格。

 

該函數(shù)的原型是:

HRESULT D3DXCreateText(

       LPDIRECT3DDEVICE9 pDevice,

       HDC hDC,

       LPCTSTR pText,

       FLOAT Deviation,

       FLOAT Extrusion,

       LPD3DXMESH* ppMesh,

       LPD3DXBUFFER* ppAdjacency,

       LPGLYPHMETRICSFLOAT pGlyphMetrics

);

這個(gè)函數(shù)如果調(diào)用成功則返回D3D_OK。

pDevice — 和mesh關(guān)聯(lián)的device。

hDC — 我們將要用來產(chǎn)生mesh的包含描述字體的設(shè)備環(huán)境句柄。

pText — 指向以null結(jié)束的字符串的指針,此字符串是用來指定創(chuàng)建什么文字mesh。

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

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

ppMesh — 返回創(chuàng)建的mesh。

ppAdjacency — 返回創(chuàng)建mesh的相關(guān)信息。假如你不需要它可以將其指定為null。

pGlyphMetrics — 一個(gè)指向LPGLYPHMETRICSFLOAT結(jié)構(gòu)數(shù)組的指針,它包含了字型米數(shù)據(jù)。假如你不關(guān)心此數(shù)據(jù),你可以把它設(shè)置為0。


來看一個(gè)示例,首先來看看其中用到的API函數(shù)使用說明:

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) 評(píng)論(0)  編輯 收藏 引用


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


公告

導(dǎo)航

統(tǒng)計(jì)

常用鏈接

隨筆分類(178)

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

搜索

最新評(píng)論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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精品国产| 亚洲福利国产精品| 欧美高清自拍一区| 亚洲高清久久| 99国产精品久久久久久久成人热| 999在线观看精品免费不卡网站| 日韩视频免费观看高清完整版| 亚洲性感美女99在线| 午夜久久一区| 欧美不卡福利| 国产精品一区二区在线观看网站 | 欧美激情亚洲另类| 欧美午夜精品久久久久久久| 国产日韩欧美在线播放| 亚洲国产成人精品久久| 亚洲线精品一区二区三区八戒| 篠田优中文在线播放第一区| 久久亚洲春色中文字幕| 最新日韩在线视频| 欧美一区二区福利在线| 欧美精品一区二区在线观看| 国产亚洲欧美另类一区二区三区| 亚洲精华国产欧美| 久久成人18免费网站| 欧美黄色精品| 午夜精品久久久久影视| 欧美理论电影在线播放| 国模精品一区二区三区| 亚洲午夜免费福利视频| 欧美好吊妞视频| 欧美一区二区视频在线观看2020| 欧美精品1区2区3区| 伊人久久婷婷色综合98网| 亚洲视频在线观看免费| 欧美国产精品专区| 亚洲欧美中文日韩v在线观看| 欧美国产视频一区二区| 一区二区亚洲欧洲国产日韩| 欧美一区二区视频在线观看| 日韩视频免费在线观看| 欧美精品日韩精品| 亚洲第一狼人社区| 欧美在线一区二区| 日韩亚洲精品电影| 欧美日韩国产免费| 日韩一区二区精品视频| 欧美国产日韩一区二区| 猫咪成人在线观看| 亚洲国产国产亚洲一二三| 久久久一区二区| 欧美亚洲一区二区三区| 亚洲精品欧美极品| 亚洲自拍16p| 性欧美暴力猛交69hd| 亚洲毛片播放| 欧美日韩国产一区二区| 亚洲精品孕妇| 亚洲肉体裸体xxxx137| 你懂的视频一区二区| 亚洲国产成人av在线| 欧美激情一区二区在线| 欧美成人69av| 中文在线不卡视频| 中文在线资源观看视频网站免费不卡| 欧美色播在线播放| 先锋亚洲精品| 久久狠狠婷婷| 91久久在线观看| 日韩一区二区精品| 国产精品vip| 久久国产精品亚洲77777| 欧美在线资源| 亚洲国产cao| 日韩手机在线导航| 国产精品麻豆成人av电影艾秋| 欧美亚洲午夜视频在线观看| 翔田千里一区二区| 在线观看日韩av先锋影音电影院| 亚洲高清123| 亚洲日本在线视频观看| 亚洲国产小视频在线观看| 麻豆成人综合网| 最新亚洲一区| 99精品视频一区二区三区| 国产精品香蕉在线观看| 久久午夜国产精品| 欧美高清视频www夜色资源网| 亚洲免费影院| 亚洲精品美女久久久久| 亚洲欧美国产视频| 亚洲欧美日韩区| 国内精品久久久久久久97牛牛| 久久精品国产欧美亚洲人人爽| 亚洲一区二区欧美日韩| 国产精品福利网站| 亚洲国产成人精品久久久国产成人一区| 最新高清无码专区| 午夜精品久久久99热福利| 91久久久久久| 欧美日韩成人一区二区| 久久精品导航| 久久人人爽爽爽人久久久| 日韩视频在线观看国产| 99re66热这里只有精品3直播| 国产在线不卡精品| 亚洲电影免费观看高清完整版在线| 欧美午夜不卡视频| 久久激情五月激情| 欧美日韩在线播放三区| 99精品热6080yy久久| 久久久中精品2020中文| 欧美区日韩区| 久久久夜精品| 欧美特黄一区| 另类成人小视频在线| 国产欧美日韩精品在线| 欧美国产大片| 亚洲第一区在线| 亚洲欧美精品在线观看| 亚洲在线视频| 欧美成黄导航| 欧美激情精品久久久久久大尺度| 国产亚洲一区二区在线观看| 99pao成人国产永久免费视频| 亚洲乱码国产乱码精品精可以看| 亚洲欧美999| 欧美一区二区精品| 欧美成人精品在线视频| 欧美激情综合| 黄色成人小视频| 久久婷婷麻豆| 国产乱码精品一区二区三区五月婷| 亚洲全黄一级网站| 99精品国产在热久久| 久热精品视频在线免费观看| 六月婷婷久久| 国内揄拍国内精品久久| 亚洲欧美激情精品一区二区| 亚洲性夜色噜噜噜7777| 久久成人亚洲| 久久福利影视| 亚洲黄页一区| 久久久国产精品一区二区三区| 亚洲综合电影一区二区三区| 欧美精品久久99| 欧美成人精品影院| 亚洲国产成人一区| 久久乐国产精品| 久久久一二三| 国语自产偷拍精品视频偷| 久久夜色精品国产| 久久先锋影音av| 精品福利免费观看| 久久人人爽爽爽人久久久| 免费av成人在线| 一本色道久久88亚洲综合88| 欧美极品在线观看| 日韩亚洲在线| 亚洲一二三区精品| 久久裸体视频| 91久久国产综合久久91精品网站| 老色鬼久久亚洲一区二区| 欧美日韩另类字幕中文| 亚洲男女自偷自拍图片另类| 亚洲欧美激情视频在线观看一区二区三区| 欧美国产在线视频| 最新日韩在线| 亚洲综合激情| 激情五月婷婷综合| 蜜臀久久99精品久久久久久9| 欧美搞黄网站| 99热这里只有精品8| 欧美日韩亚洲激情| 久久夜色精品国产| 亚洲激情视频在线播放| 亚洲午夜精品一区二区三区他趣| 国产精品入口麻豆原神| 久久精品视频va| 亚洲精品免费一二三区| 香蕉久久精品日日躁夜夜躁| 亚洲精品一区二区三区在线观看| 欧美日韩一区三区四区| 欧美一级久久久久久久大片| 欧美二区视频| 韩日精品在线| 国产精品自拍网站| 欧美成人精品在线播放| 亚洲一区二区免费| 欧美+日本+国产+在线a∨观看|