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

天行健 君子當自強而不息

Direct3D中的繪制(5)

這個程序創建并渲染幾種不同的能夠使用D3DXCreate*函數創建的3D物體。

Uses a left-handed coordinate system to create a mesh containing an axis-aligned box.

HRESULT D3DXCreateBox(
LPDIRECT3DDEVICE9 pDevice,
FLOAT Width,
FLOAT Height,
FLOAT Depth,
LPD3DXMESH * ppMesh,
LPD3DXBUFFER * ppAdjacency
);

Parameters

pDevice
[in] Pointer to an IDirect3DDevice9 interface, representing the device associated with the created box mesh.
Width
[in] Width of the box, along the x-axis.
Height
[in] Height of the box, along the y-axis.
Depth
[in] Depth of the box, along the z-axis.
ppMesh
[out] Address of a pointer to the output shape, an ID3DXMesh interface.
ppAdjacency
[out] Address of a pointer to an ID3DXBuffer interface. When the method returns, this parameter is filled with an array of three DWORDs per face that specify the three neighbors for each face in the mesh. NULL can be specified.

Return Values

If the function succeeds, the return value is D3D_OK. If the function fails, the return value can be one of the following: D3DERR_INVALIDCALL, D3DXERR_INVALIDDATA, E_OUTOFMEMORY.

Remarks

The created box is centered at the origin.

This function creates a mesh with the D3DXMESH_MANAGED creation option and D3DFVF_XYZ | D3DFVF_NORMAL flexible vertex format (FVF).

Uses a left-handed coordinate system to create a mesh containing a cylinder.

HRESULT D3DXCreateCylinder(
LPDIRECT3DDEVICE9 pDevice,
FLOAT Radius1,
FLOAT Radius2,
FLOAT Length,
UINT Slices,
UINT Stacks,
LPD3DXMESH * ppMesh,
LPD3DXBUFFER * ppAdjacency
);

Parameters

pDevice
[in] Pointer to an IDirect3DDevice9 interface, representing the device associated with the created cylinder mesh.
Radius1
[in] Radius at the negative Z end. Value should be greater than or equal to 0.0f.
Radius2
[in] Radius at the positive Z end. Value should be greater than or equal to 0.0f.
Length
[in] Length of the cylinder along the z-axis.
Slices
[in] Number of slices about the main axis.
Stacks
[in] Number of stacks along the main axis.
ppMesh
[out] Address of a pointer to the output shape, an ID3DXMesh interface.
ppAdjacency
[out] Address of a pointer to an ID3DXBuffer interface. When the method returns, this parameter is filled with an array of three DWORDs per face that specify the three neighbors for each face in the mesh. NULL can be specified.

Return Values

If the function succeeds, the return value is D3D_OK. If the function fails, the return value can be one of the following: D3DERR_INVALIDCALL, D3DXERR_INVALIDDATA, E_OUTOFMEMORY.

Remarks

The created cylinder is centered at the origin, and its axis is aligned with the z-axis.

This function creates a mesh with the D3DXMESH_MANAGED creation option and D3DFVF_XYZ | D3DFVF_NORMAL flexible vertex format (FVF).

Uses a left-handed coordinate system to create a mesh containing a torus.

HRESULT D3DXCreateTorus(
LPDIRECT3DDEVICE9 pDevice,
FLOAT InnerRadius,
FLOAT OuterRadius,
UINT Sides,
UINT Rings,
LPD3DXMESH * ppMesh,
LPD3DXBUFFER * ppAdjacency
);

Parameters

pDevice
[in] Pointer to an IDirect3DDevice9 interface, representing the device associated with the created torus mesh.
InnerRadius
[in] Inner-radius of the torus. Value should be greater than or equal to 0.0f.
OuterRadius
[in] Outer-radius of the torus. Value should be greater than or equal to 0.0f.
Sides
[in] Number of sides in a cross-section. Value must be greater than or equal to 3.
Rings
[in] Number of rings making up the torus. Value must be greater than or equal to 3.
ppMesh
[out] Address of a pointer to the output shape, an ID3DXMesh interface.
ppAdjacency
[out] Address of a pointer to an ID3DXBuffer interface. When the method returns, this parameter is filled with an array of three DWORDs per face that specify the three neighbors for each face in the mesh. NULL can be specified.

Return Values

If the function succeeds, the return value is D3D_OK. If the function fails, the return value can be one of the following: D3DERR_INVALIDCALL, D3DXERR_INVALIDDATA, E_OUTOFMEMORY.

Remarks

The created torus is centered at the origin, and its axis is aligned with the z-axis. The inner radius of the torus is the radius of the cross-section (the minor radius), and the outer radius of the torus is the radius of the central hole.

This function returns a mesh that can be used later for drawing or manipulation by the application.

This function creates a mesh with the D3DXMESH_MANAGED creation option and D3DFVF_XYZ | D3DFVF_NORMAL flexible vertex format (FVF).

Uses a left-handed coordinate system to create a mesh containing a sphere.

HRESULT D3DXCreateSphere(
LPDIRECT3DDEVICE9 pDevice,
FLOAT Radius,
UINT Slices,
UINT Stacks,
LPD3DXMESH * ppMesh,
LPD3DXBUFFER * ppAdjacency
);

Parameters

pDevice
[in] Pointer to an IDirect3DDevice9 interface, representing the device associated with the created sphere mesh.
Radius
[in] Radius of the sphere. This value should be greater than or equal to 0.0f.
Slices
[in] Number of slices about the main axis.
Stacks
[in] Number of stacks along the main axis.
ppMesh
[out] Address of a pointer to the output shape, an ID3DXMesh interface.
ppAdjacency
[out] Address of a pointer to an ID3DXBuffer interface. When the method returns, this parameter is filled with an array of three DWORDs per face that specify the three neighbors for each face in the mesh. NULL can be specified.

Return Values

If the function succeeds, the return value is D3D_OK. If the function fails, the return value can be one of the following: D3DERR_INVALIDCALL, D3DXERR_INVALIDDATA, E_OUTOFMEMORY.

Remarks

The created sphere is centered at the origin, and its axis is aligned with the z-axis.

This function creates a mesh with the D3DXMESH_MANAGED creation option and D3DFVF_XYZ | D3DFVF_NORMAL flexible vertex format (FVF).

Builds a matrix using the specified offsets.

D3DXMATRIX * D3DXMatrixTranslation(
D3DXMATRIX * pOut,
FLOAT x,
FLOAT y,
FLOAT z
);

Parameters

pOut
[in, out] Pointer to the D3DXMATRIX structure that is the result of the operation.
x
[in] X-coordinate offset.
y
[in] Y-coordinate offset.
z
[in] Z-coordinate offset.

Return Values

Pointer to a D3DXMATRIX structure that contains a translated transformation matrix.

Remarks

The return value for this function is the same value returned in the pOut parameter. In this way, the D3DXMATRIXTranslation can be used as a parameter for another function.

運行截圖:

源程序:

/**************************************************************************************
 Renders several D3DX shapes in wireframe mode and has the camera fly around the scene.  
 Demonstrates the D3DXCreate* functions, and demonstrates more complex transformations 
 used to position the objects in the world and move the camera around the world.
 *************************************************************************************
*/

#include 
"d3dUtility.h"

#pragma warning(disable : 
4100)

#define TEAPOT_MESH        0
#define BOX_MESH        1
#define CYLINDER_MESH    2
#define TORUS_MESH        3
#define SPHERE_MESH        4
#define NUM_MESH        5

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

IDirect3DDevice9
*    g_d3d_device = NULL;
ID3DXMesh
*            g_object_meshes[NUM_MESH];

// world matrices for each object.
// these matrices specify the location of the objects in the world.
D3DXMATRIX g_object_world_matrices[NUM_MESH];

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

bool setup()
{    
    
// create the teapot geometry
    D3DXCreateTeapot(g_d3d_device, &g_object_meshes[TEAPOT_MESH], NULL);
    D3DXCreateBox(g_d3d_device, 
2.0f2.0f2.0f&g_object_meshes[BOX_MESH], NULL);
    D3DXCreateCylinder(g_d3d_device, 
1.0f1.0f3.0f1010&g_object_meshes[CYLINDER_MESH], NULL);
    D3DXCreateTorus(g_d3d_device, 
1.0f3.0f1010&g_object_meshes[TORUS_MESH], NULL);
    D3DXCreateSphere(g_d3d_device, 
1.0f1010&g_object_meshes[SPHERE_MESH], NULL);

    
// Build world matrices - position the objects in world space.
    
// For example, g_object_world_matrices[1] will position g_object_meshes[1] at (-5, 0, 5).
    
// Likewise, g_object_world_matrices[2] will position g_object_meshes[2] at (5, 0, -5).
    D3DXMatrixTranslation(&g_object_world_matrices[TEAPOT_MESH],    0.0f0.0f0.0f);
    D3DXMatrixTranslation(
&g_object_world_matrices[BOX_MESH],       -5.0f0.0f,  5.0f);
    D3DXMatrixTranslation(
&g_object_world_matrices[CYLINDER_MESH],  5.0f0.0f,  5.0f);
    D3DXMatrixTranslation(
&g_object_world_matrices[TORUS_MESH],       -5.0f0.0f-5.0f);
    D3DXMatrixTranslation(
&g_object_world_matrices[SPHERE_MESH],    5.0f0.0f-5.0f);

    
// set the projection matrix
    D3DXMATRIX proj;
    D3DXMatrixPerspectiveFovLH(
&proj, D3DX_PI * 0.5f, (float)WIDTH/HEIGHT, 1.0f1000.0f);
    g_d3d_device
->SetTransform(D3DTS_PROJECTION, &proj);

    
// set wireframe mode render state
    g_d3d_device->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);

    
return true;
}

void cleanup()
{
    
for(int i = 0; i < NUM_MESH; i++)
        safe_release
<ID3DXMesh*>(g_object_meshes[i]);
}

bool display(float time_delta)
{
    
// Animate the camera:
    
//
    
// The camera will circle around the center of the scene.  We use the sin and cos functions 
    
// to generate points on the circle, then scale them by 10 to further the radius.  
    
// In addition the camera will move up and down as it circles about the scene.
    static float angle = (3.0f * D3DX_PI) / 2.0f;
    
static float camera_height = 0.0f;
    
static float camera_height_dir = 10.0f;

    D3DXVECTOR3 position(cosf(angle) 
* 10.0f, camera_height, sinf(angle) * 10.0f);

    
// the camera is targetted at the origin of the world
    D3DXVECTOR3 target(0.0f0.0f0.0f);

    
// the worlds up vector
    D3DXVECTOR3 up(0.0f1.0f0.0f);

    D3DXMATRIX view_matrix;
    D3DXMatrixLookAtLH(
&view_matrix, &position, &target, &up);
    g_d3d_device
->SetTransform(D3DTS_VIEW, &view_matrix);

    
// compute the position for the next frame
    angle += time_delta;
    
if(angle >= 6.28f)
        angle 
= 0.0f;

    
// compute the height of the camera for the next frame
    camera_height += camera_height_dir * time_delta;
    
if(camera_height >= 20.0f || camera_height <= -20.0f)
        camera_height_dir 
= -camera_height_dir;
    
    
// draw the scene

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

    g_d3d_device
->BeginScene();

    
for(int i = 0; i < NUM_MESH; i++)
    {
        
// set the world matrix that positions the object
        g_d3d_device->SetTransform(D3DTS_WORLD, &g_object_world_matrices[i]);

        
// draw the object using the previously set world matrix
        g_object_meshes[i]->DrawSubset(0);
    }
    
    g_d3d_device
->EndScene();

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

    
return true;
}

LRESULT CALLBACK wnd_proc(HWND hwnd, UINT msg, WPARAM word_param, LPARAM long_param)
{
    
switch(msg)
    {
    
case WM_DESTROY:
        PostQuitMessage(
0);
        
break;

    
case WM_KEYDOWN:
        
if(word_param == VK_ESCAPE)
            DestroyWindow(hwnd);
        
break;
    }

    
return DefWindowProc(hwnd, msg, word_param, long_param);
}

int WINAPI WinMain(HINSTANCE inst, HINSTANCE, PSTR cmd_line, int cmd_show)
{
    
if(! init_d3d(inst, WIDTH, HEIGHT, true, D3DDEVTYPE_HAL, &g_d3d_device))
    {
        MessageBox(NULL, 
"init_d3d() - failed."0, MB_OK);
        
return 0;
    }

    
if(! setup())
    {
        MessageBox(NULL, 
"Steup() - failed."0, MB_OK);
        
return 0;
    }

    enter_msg_loop(display);

    cleanup();
    g_d3d_device
->Release();

    
return 0;
}

 

下載源程序


posted on 2008-03-14 18:52 lovedday 閱讀(989) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


公告

導航

統計

常用鏈接

隨筆分類(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>
            欧美一区二区三区在线观看视频 | 午夜影院日韩| 国产精品人成在线观看免费 | 国产欧美日韩综合| 欧美与欧洲交xxxx免费观看| 亚洲综合另类| 好看的日韩视频| 欧美激情亚洲国产| 亚洲视频每日更新| 亚洲自拍偷拍色片视频| 红桃av永久久久| 欧美国产激情二区三区| 欧美日韩一区二区高清| 欧美在线观看天堂一区二区三区| 久久精品国产2020观看福利| 亚洲欧洲一区二区在线观看| 日韩天堂在线视频| 国产日韩欧美精品在线| 欧美xx视频| 国产精品成人av性教育| 久久er99精品| 欧美精品videossex性护士| 亚洲永久免费观看| 久久久999精品| 99精品视频一区| 午夜久久久久久久久久一区二区| 亚洲二区在线视频| 一区二区三区免费观看| 国外成人在线视频网站| 亚洲人成免费| 国产视频久久| 亚洲精品一区二区三区不| 国产亚洲成精品久久| 亚洲欧洲日产国码二区| 国内成人精品视频| 一区二区国产精品| 亚洲人www| 久久九九热re6这里有精品| 在线亚洲欧美视频| 免费黄网站欧美| 久久久精品一区二区三区| 欧美日韩国产综合网| 免费日韩视频| 国产一区再线| 亚洲一区免费视频| 亚洲天堂av在线免费观看| 久久青青草综合| 久久久噜噜噜久久| 国产精品视频免费| 中文国产成人精品| 亚洲天堂免费观看| 欧美福利在线| 欧美国产高潮xxxx1819| 黄色小说综合网站| 性欧美暴力猛交另类hd| 午夜精品久久久久久久久久久久 | 中文国产一区| 亚洲视频精选| 欧美日韩精品免费看| 最近看过的日韩成人| 亚洲国产一区二区精品专区| 欧美呦呦网站| 久久九九精品99国产精品| 国产欧美精品在线播放| 亚洲先锋成人| 欧美亚洲免费高清在线观看| 国产精品久久久久久模特| 亚洲深夜福利视频| 亚洲欧美日韩一区二区在线| 国产精品福利久久久| 一区二区三区高清视频在线观看| 一本久道久久综合婷婷鲸鱼| 欧美韩日一区| 亚洲三级电影全部在线观看高清| 亚洲人成毛片在线播放女女| 欧美11—12娇小xxxx| 91久久中文| 久久伊人一区二区| 欧美寡妇偷汉性猛交| 亚洲美女毛片| 欧美日韩激情小视频| 亚洲午夜久久久久久久久电影网| 亚洲欧美日韩国产成人| 国产亚洲欧美激情| 久久精品国产欧美亚洲人人爽| 久久米奇亚洲| 亚洲美洲欧洲综合国产一区| 欧美日韩亚洲综合在线| 午夜欧美视频| 亚洲电影免费观看高清完整版在线观看| 亚洲日韩成人| 国产精品看片资源| 久久裸体视频| 野花国产精品入口| 久久久国产一区二区三区| 亚洲国产一区二区三区a毛片| 欧美精品1区2区| 亚洲欧美日韩综合国产aⅴ| 老司机午夜免费精品视频| 一区二区三区你懂的| 国产一区高清视频| 欧美日韩福利视频| 欧美一级黄色录像| 亚洲激情一区二区| 久久久女女女女999久久| 日韩视频精品在线| 狠狠久久亚洲欧美| 久久综合国产精品台湾中文娱乐网| 亚洲国产成人午夜在线一区| 欧美天天视频| 久久综合伊人| 午夜精品久久久久| 99ri日韩精品视频| 欧美插天视频在线播放| 欧美一区二区三区四区视频 | 欧美色123| 久久久久久亚洲精品不卡4k岛国| 日韩视频第一页| 欧美成人一区二免费视频软件| 宅男在线国产精品| 亚洲欧洲日本在线| 国产主播一区二区三区四区| 欧美少妇一区二区| 欧美成人免费网站| 久久久夜夜夜| 欧美一区二区三区视频在线观看| 日韩网站在线| 亚洲国产一区视频| 欧美va亚洲va国产综合| 久久久久91| 欧美在线视频观看| 亚洲专区在线| 亚洲永久免费av| 在线综合视频| 在线视频亚洲| 中日韩高清电影网| 亚洲精品网站在线播放gif| 在线观看福利一区| 在线国产精品一区| 亚洲第一中文字幕| 樱桃国产成人精品视频| 国产一区二区三区的电影| 国产日韩综合| 国产视频一区二区三区在线观看| 国产精品久久网站| 国产精品美女久久久久av超清| 欧美日韩无遮挡| 欧美手机在线视频| 国产精品久久久久影院亚瑟 | 久久久欧美精品sm网站| 久久精品麻豆| 葵司免费一区二区三区四区五区| 久久精品亚洲一区| 老司机一区二区三区| 蜜桃久久精品乱码一区二区| 巨胸喷奶水www久久久免费动漫| 久久视频一区| 欧美国产精品日韩| 榴莲视频成人在线观看| 欧美国产第一页| 亚洲狼人精品一区二区三区| 99国产精品国产精品久久| 在线一区亚洲| 性伦欧美刺激片在线观看| 久久九九全国免费精品观看| 老司机免费视频一区二区| 欧美精品一卡| 国产精品少妇自拍| 在线观看日韩www视频免费| 亚洲乱码国产乱码精品精天堂| 宅男精品视频| 久久久久久久一区二区三区| 亚洲成人在线视频播放 | 在线观看日韩av| 日韩手机在线导航| 欧美在线高清视频| 欧美激情影音先锋| 亚洲一区二区av电影| 午夜精品久久久久久久白皮肤| 久久久久久久久久久成人| 欧美久久久久久| 国产在线观看精品一区二区三区| 亚洲人在线视频| 欧美一级网站| 91久久国产综合久久蜜月精品 | 亚洲综合欧美| 欧美成人午夜| 午夜精彩国产免费不卡不顿大片| 久久影院午夜片一区| 国产精品久久午夜| 亚洲国产精品t66y| 午夜欧美精品| 亚洲人成网站在线播| 香蕉成人伊视频在线观看| 欧美精品一区二区蜜臀亚洲| 国模吧视频一区| 亚洲欧美日韩一区二区三区在线观看 | 亚洲一区三区视频在线观看| 久久一区二区三区四区| 99国产精品视频免费观看一公开 |