d3d實現乙個旋轉的三角形

2021-05-22 20:22:37 字數 2402 閱讀 6585

#include "d3d9.h"

#include "d3dx9math.h"

#pragma comment(lib,"d3d9.lib")   

#pragma comment(lib,"d3dx9.lib")

#pragma comment(lib, "winmm.lib")

lpdirect3d9 g_pd3d = null;//direct3d¶ôïó

lpdirect3ddevice9 g_pd3ddevice = null;//direct3dé豸¶ôïó

idirect3dvertexbuffer9  *g_pvb = null;

int g_rotatey = 0;

struct customvertex ;

#define d3dfvf_custovmvertex    (d3dfvf_xyz | d3dfvf_diffuse)

//³õê¼»¯direct3d

hresult init3d(hwnd hwnd)

//éèöãd3dpersent_parameters½á¹¹£¬×¼±¸´´½¨direct3dé豸¶ôïó

d3dpresent_parameters d3***;

zeromemory(&d3***,sizeof(d3***));

d3***.windowed = true;

d3***.swapeffect = d3dswapeffect_discard;

d3***.backbufferformat = d3dfmt_unknown;

//´´½¨direct3dé豸¶ôïó

if (failed(g_pd3d->createdevice(d3dadapter_default,d3ddevtype_hal,hwnd,

d3dcreate_software_vertexprocessing,

&d3***,&g_pd3ddevice)))

g_pd3ddevice->setrenderstate(d3drs_cullmode, d3dcull_none);

g_pd3ddevice->setrenderstate(d3drs_lighting, false);

return s_ok;

}void setupmatrices()

hresult initvb(void)

, //µãa£¬ºìé«

, //µãb£¬âìé«

,//µãc£¬ç³à¶

};if(failed(g_pd3ddevice->createvertexbuffer(sizeof(vertex), 0, d3dfvf_custovmvertex, d3dpool_default, &g_pvb, null)))

void* pvertices;

g_pvb->lock( 0, sizeof(vertex), (void**)&pvertices, 0 );

memcpy( pvertices, vertex, sizeof(vertex) );

g_pvb->unlock();

return s_ok;

}//êí·å´´½¨¶ôïó

void cleanup()

//êí·ådirect3dé豸¶ôïó

if (g_pd3ddevice != null)

//êí·ådirect3d¶ôïó

if (g_pd3d != null)

}//äöè¾í¼ðî

void render()

//½«ôúºó쨻º³åçø»æöæµäí¼ðîìá½»µ½ç°ì¨»º³åçøïôê¾

g_pd3ddevice->present(null,null,null,null);

}//ïû¦àí

lresult winapi msgproc(hwnd hwnd, uint msg, wparam wparam, lparam lparam)

return defwindowproc(hwnd, msg, wparam, lparam);

}void callback timerproc(hwnd hwnd,

uint umsg,

uint_ptr idevent,

dword dwtime

)//³ìðòèë¿ú

int winapi winmain(hinstance hinst,

hinstance,

lptstr,

int)

;registerclas***( &wc );

//³õê¼»¯direct3d

if (succeeded(init3d(hwnd)))}}

}unregisterclass("classname",wc.hinstance);

return 0;

}

D3D基本三角形面的繪製

include gameengine gameengine common.h include h c c c c direct3drelease bool c created3ddevice hwnd hwnd,bool bfullscreen 建立idirect3d9物件 m pidirect3d...

D 空心三角形

把乙個字元三角形掏空,就能節省材料成本,減輕重量,但關鍵是為了追求另一種視覺效果。在設計的過程中,需要給出各種花紋的材料和大小尺寸的三角形樣板,通過電腦臨時做出來,以便看看效果。input 每行包含乙個字元和乙個整數n 0a 7 sample output x aa a a a a a a a a ...

問題 D 萊布尼茨三角形

請小夥伴們對自己ac的題目進行標記,注意每人只能標記一次!不知道的不要標記,惡意標記者將 賬號!時間限制 1 sec 記憶體限制 128 mb 提交 狀態 題目描述 世界上著名的萊布尼茨三角形如圖所示,請程式設計輸出圖中排在第n行從左邊數第m個位置上的數。輸入 共一行,有二個整數n 和m n 15 ...