#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£¬ç³à¶
, //µãa£¬ºìé«
, //µãb£¬âìé«
,//µãc£¬ç³à¶
, //µãb£¬âìé«
,//µãc£¬ç³à¶
,//µãc£¬ç³à¶
, //µãa£¬ºìé«
,//µãc£¬ç³à¶
,//µã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 d3d9.h include d3dx9math.h pragma comment lib,d3d9.lib pragma comment lib,d3dx9.lib pragma comment lib,winmm.lib lpdirect3d9 g pd3d null direc...
使用CSS3實現乙個3D相簿
css3系列我已經寫過兩篇文章,感興趣的同學可以先看一下 第一篇主要列出了一些常用或經典的css3技巧和方法 第二篇是乙個用css3實現的立方體例項,詳細講解了3d旋轉和transform等屬性。本文再來利用css3屬性來編寫乙個例項,話不多說,先直接看看效果。因為前面已經講解過一些屬性的用法,此篇...
如何使用CSS3實現乙個3D相簿
css3系列我已經寫過兩篇文章了,在這貼出鏈結,感興趣的同學可以看一下css3初體驗之奇技淫巧,css3 3d立方體效果 transform也不過如此 第一篇主要列出了一些常用或經典的css3技巧和方法 第二篇是乙個用css3實現的立方體例項,詳細講解了3d旋轉和transform等屬性。本文再來利...