扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
#include <d3d9.h> // D3D标准头文件 #include <D3dx9math.h> // D3D数学库头文件 #include <stdio.h> // 这个不用我说了吧? #pragma comment( lib, "d3d9" ) // D3D的静态库 #pragma comment( lib, "d3dx9" ) // D3D数学库的静态库 |
#include "stdafx.h" #define MAX_LOADSTRING 100 HINSTANCE g_hInst; HWND g_hWnd; IDirect3D9 *g_pD3D; IDirect3DDevice9 *g_pd3dDevice; IDirect3DVertexBuffer9 *g_pVB; TCHAR szTitle[MAX_LOADSTRING]; TCHAR szWindowClass[MAX_LOADSTRING]; ATOM MyRegisterClass(HINSTANCE hInstance); BOOL InitInstance(HINSTANCE, int); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM); void OnIdle( void ); void OnCreate( HWND hWnd ); HRESULT InitD3D( void ); HRESULT CreateObject( void ); void ReleaseD3D( void ); HRESULT SetModalMatrix( void ); HRESULT SetProjMatrix( WORD wWidth, WORD wHeight ); void BeforePaint( void ); int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { MSG msg; HACCEL hAccelTable; LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_D3DTEST, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_D3DTEST); while ( true ) { if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } continue; } if ( WM_QUIT == msg.message ) { break; } OnIdle(); } UnregisterClass( szWindowClass, g_hInst ); return (int)msg.wParam; } ATOM MyRegisterClass( HINSTANCE hInstance ) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_D3DTEST); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = (LPCTSTR)IDC_D3DTEST; wcex.lpszClassName = szWindowClass; wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL); return RegisterClassEx(&wcex); } BOOL InitInstance( HINSTANCE hInstance, int nCmdShow ) { g_hInst = hInstance; CreateWindow( szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL ); if ( !g_hWnd ) { return FALSE; } ShowWindow( g_hWnd, nCmdShow ); UpdateWindow( g_hWnd ); return TRUE; } LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; switch (message) { case WM_CREATE: OnCreate( hWnd ); break; case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); switch (wmId) { case IDM_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_SIZE: SetProjMatrix( LOWORD( lParam ), HIWORD( lParam ) ); break; case WM_DESTROY: ReleaseD3D(); PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; } void OnCreate( HWND hWnd ) { g_hWnd = hWnd; InitD3D(); CreateObject(); } void ReleaseD3D( void ) { } HRESULT InitD3D( void ) { return S_OK; } void BeforePaint( void ) { } HRESULT CreateObject( void ) { return S_OK; } void OnIdle( void ) { } HRESULT SetModalMatrix( void ) { return S_OK; } HRESULT SetProjMatrix( WORD wWidth, WORD wHeight ) { return S_OK; } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者