#include"d3d9.h" #include"d3dx9.h" //-------------------------global variables--------- LPDIRECT3D9 g_pD3D=NULL; LPDIRECT3DDEVICE9 g_pd3dDevice=NULL; VOID Cleanup() { if( g_pd3dDevice != NULL) g_pd3dDevice->Release(); if( g_pD3D != NULL) g_pD3D->Release(); } HRESULT Init(HWND hWnd){ if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) ) return E_FAIL; D3DPRESENT_PARAMETERS d3dpp; ZeroMemory( &d3dpp, sizeof(d3dpp) ); d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice ) ) ) return E_FAIL; return S_OK; } void Render() { // Clear the back buffer to a blue color g_p
Directx09 创建窗口代码
最新推荐文章于 2019-06-29 04:12:04 发布
这篇博客展示了如何利用DirectX09 API创建窗口并初始化设备,包括D3D9头文件的包含、全局变量的声明、Cleanup函数、Init初始化函数、Render渲染函数以及消息处理函数MsgProc的实现。通过WinMain函数进行窗口创建和消息循环。
摘要由CSDN通过智能技术生成