
Зануда
  
Профиль
Группа: Завсегдатай
Сообщений: 1364
Регистрация: 29.10.2005
Где: Канада
Репутация: нет Всего: 3
|
| Код | #include <windows.h> #include <d3d9.h>
HINSTANCE hInst; // global handle to hold the application instance HWND wndHandle; // global variable to hold the window handle
LPDIRECT3D9 pD3D; // the Direct3D object LPDIRECT3DDEVICE9 pd3dDevice; // the Direct3D device
bool initWindow( HINSTANCE hInstance ); bool initDirect3D(void); LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); void render(void); void cleanUp (void);
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow ) { if(!initWindow(hInstance)) return false;
if(!initDirect3D()) return false;
//main message loop MSG msg; ZeroMemory(&msg, sizeof(msg)); while( msg.message != WM_QUIT ) { if(PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else { render(); } } return (int) msg.wParam; }
/****************************************************************************** * bool initWindow( HINSTANCE hInstance ) * initWindow registers the window class for the application, creates the window ******************************************************************************/ bool initWindow(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 = 0; wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = NULL; wcex.lpszClassName = "DirectXExample"; wcex.hIconSm = 0; RegisterClassEx(&wcex);
wndHandle = CreateWindow("DirectXExample", // the window class to use "DirectXExample", // the title bar text WS_OVERLAPPEDWINDOW, // the window style CW_USEDEFAULT, // the starting x coordinate CW_USEDEFAULT, // the starting y coordinate 640, // the pixel width of the window 480, // the pixel height of the window NULL, // the parent window; NULL for desktop NULL, // the menu for the application; NULL for none hInstance, // the handle to the application instance NULL); // no values passed to the window
if(!wndHandle) return false;
ShowWindow(wndHandle, SW_SHOW); UpdateWindow(wndHandle); return true; }
/********************************************************************* * initDirect3D *********************************************************************/ bool initDirect3D(void) { pD3D = NULL; pd3dDevice = NULL;
if(NULL == (pD3D = Direct3DCreate9(D3D_SDK_VERSION))) { return false; }
// Fill the presentation parameters structure D3DPRESENT_PARAMETERS d3dpp; ZeroMemory(&d3dpp, sizeof(d3dpp)); d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; d3dpp.BackBufferCount = 1; d3dpp.BackBufferHeight = 480; d3dpp.BackBufferWidth = 640; d3dpp.hDeviceWindow = wndHandle;
// Create a default DirectX device if(FAILED(pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, wndHandle, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pd3dDevice))) { return false; } return true; }
/****************************************************************************** * LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, * LPARAM lParam) * The window procedure ******************************************************************************/ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_DESTROY: PostQuitMessage(0); break; }
return DefWindowProc(hWnd, message, wParam, lParam); }
/********************************************************************* * render *********************************************************************/ void render(void) { // Check to make sure you have a valid Direct3D device if(NULL == pd3dDevice) return; pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255), 1.0f, 0);
// Present the back buffer contents to the display pd3dDevice->Present( NULL, NULL, NULL, NULL); }
void cleanUp (void) { // Release the device and the Direct3D object if( pd3dDevice != NULL ) pd3dDevice->Release( ); if( pD3D != NULL ) pD3D->Release( ); }
|
Кричит: | Код | winmain.obj : error LNK2019: unresolved external symbol _Direct3DCreate9@4 referenced in function "bool __cdecl initDirect3D(void)" (?initDirect3D@@YA_NXZ) D:\Intel\example1\Debug\example1.exe : fatal error LNK1120: 1 unresolved externals
|
библиотеки все прописал... Добавлено @ 02:54 При этом если добавляю в опциях: 'd3d9.lib'то кричит: | Код | LINK : fatal error LNK1181: cannot open input file 'd3d9.lib'
|
--------------------
Если долго мучиться, что нибудь получится... 
|