DirectX9 示例:绘制茶壶
来源:互联网 发布:黑马程序员web前端视频 编辑:程序博客网 时间:2024/05/17 02:46
//////////////////////////////////////////////////////////////////////////////////////////////////// // File: teapot.cpp// // Author: Frank Luna (C) All Rights Reserved//// System: AMD Athlon 1800+ XP, 512 DDR, Geforce 3, Windows XP, MSVC++ 7.0 //// Desc: Renders a teapot in wireframe mode. Shows how to create a teapot // using the D3DXCreateTeapot function and how to render the teapot// using the ID3DXMesh::DrawSubset method.// //////////////////////////////////////////////////////////////////////////////////////////////////#include "d3dUtility.h"//// Globals//IDirect3DDevice9* Device = 0; const int Width = 640;const int Height = 480;// Mesh interface that will store the teapot data and contains// ma method to render the teapot data.ID3DXMesh* Teapot = 0;//// Framework Functions//bool Setup(){//// Create the teapot geometry.//D3DXCreateTeapot(Device, &Teapot, 0);//// Position and aim the camera.//D3DXVECTOR3 position(0.0f, 0.0f, -3.0f);D3DXVECTOR3 target(0.0f, 0.0f, 0.0f);D3DXVECTOR3 up(0.0f, 1.0f, 0.0f); D3DXMATRIX V;D3DXMatrixLookAtLH(&V, &position, &target, &up);Device->SetTransform(D3DTS_VIEW, &V);//// Set projection matrix.//D3DXMATRIX proj;D3DXMatrixPerspectiveFovLH(&proj,D3DX_PI * 0.5f, // 90 - degree(float)Width / (float)Height,1.0f,1000.0f);Device->SetTransform(D3DTS_PROJECTION, &proj);//// Switch to wireframe mode.//Device->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);return true;}void Cleanup(){d3d::Release<ID3DXMesh*>(Teapot);}bool Display(float timeDelta){if( Device ){//// Spin the teapot://D3DXMATRIX Ry;static float y = 0.0f;D3DXMatrixRotationY(&Ry, y);y += timeDelta;if(y >= 6.28f)y = 0.0f;Device->SetTransform(D3DTS_WORLD, &Ry);//// Draw the Scene://Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0);Device->BeginScene();// Draw teapot using DrawSubset method with 0 as the argument.Teapot->DrawSubset(0);Device->EndScene();Device->Present(0, 0, 0, 0);}return true;}//// WndProc//LRESULT CALLBACK d3d::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);}//// WinMain//int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE prevInstance, PSTR cmdLine, int showCmd){if(!d3d::InitD3D(hinstance,Width, Height, true, D3DDEVTYPE_HAL, &Device)){::MessageBox(0, "InitD3D() - FAILED", 0, 0);return 0;}if(!Setup()){::MessageBox(0, "Setup() - FAILED", 0, 0);return 0;}d3d::EnterMsgLoop( Display );Cleanup();Device->Release();return 0;}
0 0
- DirectX9 示例:绘制茶壶
- DirectX9 示例:绘制三角形
- DirectX9 示例:绘制正方体
- OpenGL绘制旋转茶壶
- DIRECTX9.0绘制流水线
- DirectX9绘制流水线
- 第五弹 带光照茶壶绘制
- DirectX9 示例:演示D3DXCreate*函数
- DirectX9示例程序(26)-shader
- [实例]OpenGL绘制茶壶(光照、三维变换)
- Directx9入门(2)绘制第一个2D图形
- DirectX9 龙书学习笔记(1) 矩形的绘制
- DirectX学习笔记(四):利用D3DX网格数据结构绘制可旋转茶壶
- DirectX学习笔记(四):利用D3DX网格数据结构绘制可旋转茶壶
- 水晶茶壶
- 茶壶泡饮法
- glTranslatef_茶壶
- 茶壶旋转
- 丑数
- Mybatis--持久成框架
- DirectX9 示例:绘制正方体
- [js]计算生日所在星期
- xamarin的一些插件
- DirectX9 示例:绘制茶壶
- DirectX9 示例:演示D3DXCreate*函数
- 读ApacheLang源码 - 01
- QT4.8下1024位RSA编解码
- 水题集
- OpenMesh修改CMakeLists文件之添加链接库
- GRE、PPTP、L2TP隧道协议
- HOOK钩子技术2 内联钩子Inline HOOK 通过DLL注入
- hduoj 5214 Movie 暴力