聽說DirectX
#include
#include
#include
#pragma comment( lib
#pragma comment( lib
然後把winmain所在文件的代碼做如下的修改
#include
#define MAX_LOADSTRING
HINSTANCE g_hInst;
HWND g_hWnd;
IDirect
IDirect
IDirect
TCHAR szTitle[MAX_LOADSTRING];
TCHAR szWindowClass[MAX_LOADSTRING];
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE
LRESULT CALLBACK WndProc(HWND
LRESULT CALLBACK About(HWND
void OnIdle( void );
void OnCreate( HWND hWnd );
HRESULT InitD
HRESULT CreateObject( void );
void ReleaseD
HRESULT SetModalMatrix( void );
HRESULT SetProjMatrix( WORD wWidth
void BeforePaint( void );
int APIENTRY _tWinMain(HINSTANCE hInstance
{
MSG msg;
HACCEL hAccelTable;
LoadString(hInstance
LoadString(hInstance
MyRegisterClass(hInstance);
if (!InitInstance (hInstance
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance
while ( true )
{
if ( PeekMessage( &msg
{
if (!TranslateAccelerator(msg
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
continue;
}
if ( WM_QUIT == ssage )
{
break;
}
OnIdle();
}
UnregisterClass( szWindowClass
return (int)msg
}
ATOM MyRegisterClass( HINSTANCE hInstance )
{
WNDCLASSEX wcex;
wcex
wcex
wcex
wcex
wcex
wcex
wcex
wcex
wcex
wcex
wcex
wcex
return RegisterClassEx(&wcex);
}
BOOL InitInstance( HINSTANCE hInstance
{
g_hInst = hInstance;
CreateWindow( szWindowClass
if ( !g_hWnd )
{
return FALSE;
}
ShowWindow( g_hWnd
UpdateWindow( g_hWnd );
return TRUE;
}
LRESULT CALLBACK WndProc(HWND hWnd
{
int wmId
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
}
break;
case WM_SIZE:
SetProjMatrix( LOWORD( lParam )
break;
case WM_DESTROY:
ReleaseD
PostQuitMessage(
break;
default:
return DefWindowProc(hWnd
}
return
}
void OnCreate( HWND hWnd )
{
g_hWnd = hWnd;
InitD
CreateObject();
}
void ReleaseD
{
}
HRESULT InitD
{
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
{
return S_OK;
}
上面的代碼僅是一個框架
g_hInst = hInstance;
在創建窗體時
g_hWnd = hWnd;
這樣
下面我們來填寫代碼
g_pD
if( NULL == g_pD
{
return E_FAIL;
}
D
ZeroMemory( &d
d
d
d
g_pD
D
&d
g_pd
g_pd
D
g_pd
D
ZeroMemory( &mtrl
mtrl
mtrl
mtrl
mtrl
g_pd
return S_OK;
Direct
d
d
d
在這之後
From:http://tw.wingwit.com/Article/program/net/201311/12668.html