| CODE |
| #include <windows.h> #include <d3d9.h> LRESULT WINAPI MsgProc(HWND, UINT, WPARAM, LPARAM); //void Render(void); INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT ) { // Register the window class. WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L, hInst, NULL, NULL, NULL, NULL, "D3D Tutorial", NULL }; RegisterClassEx( &wc ); // Create the application's window. HWND hwnd = CreateWindow( "D3D Tutorial", "D3D Tutorial 01: CreateDevice", WS_OVERLAPPEDWINDOW, 100, 100, 300, 300, GetDesktopWindow(), NULL, hInst, NULL ); IDirect3D9* g_pD3D=Direct3DCreate9( D3D_SDK_VERSION ); if(NULL==g_pD3D) return false; D3DPRESENT_PARAMETERS d3dpp; ZeroMemory( &d3dpp, sizeof(d3dpp) ); d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; IDirect3DDevice9*g_pd3dDevice; if(D3D_OK==g_pD3D->CreateDevice( D3DADAPTER_DEFAULT,//default value D3DDEVTYPE_HAL, hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice)) return false; MSG msg; while( GetMessage( &msg, NULL, 0, 0 ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } } LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { switch( msg ) { case WM_DESTROY: PostQuitMessage( 0 ); return 0; case WM_PAINT: //Render(); ValidateRect( hWnd, NULL ); return 0; } return DefWindowProc( hWnd, msg, wParam, lParam ); } |
| QUOTE |
| Error: 'C:\BORLAND\BCC55\LIB\D3D9.LIB' contains invalid OMF record, type 0x21 (possibly COFF) |
| CODE |
| #include <Windows.h> #include <D3D9.h> #include <D3DX9.h> PASCAL WinMain(HINSTANCE ThisApp, HINSTANCE, LPSTR, INT) { WNDCLASS* W = new WNDCLASS; memset(W, 0, sizeof(*W)); W->hInstance = ThisApp; W->lpszClassName = "W"; W->lpfnWndProc = DefWindowProc; RegisterClass(W); delete W; HWND Window = CreateWindowEx(WS_EX_TOPMOST, "W", "D3D9", WS_POPUP | WS_VISIBLE, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), 0, 0, ThisApp, 0); IDirect3D9* Direct3D = Direct3DCreate9(D3D_SDK_VERSION); D3DPRESENT_PARAMETERS d3dpp = { 640, 480, D3DFMT_R5G6B5, 1, D3DMULTISAMPLE_NONE, 0, D3DSWAPEFFECT_FLIP, Window, FALSE, FALSE, (D3DFORMAT)0, 0, D3DPRESENT_RATE_DEFAULT, D3DPRESENT_INTERVAL_DEFAULT }; IDirect3DDevice9* D3DDevice = 0; Direct3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, Window, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &D3DDevice); HCURSOR PreviousCursor = SetCursor(0); ID3DXMesh* Teapot = 0; D3DXCreateTeapot(D3DDevice, &Teapot, 0); MSG Msg; while(GetAsyncKeyState(VK_END) ? 0 : 1) { if(PeekMessage(&Msg, 0, 0, 0, PM_REMOVE)) { TranslateMessage(&Msg); DispatchMessage(&Msg); } else { D3DDevice->Clear(0, 0, D3DCLEAR_TARGET, D3DCOLOR_XRGB(70, 80, 255), 1.0f, 0); D3DDevice->BeginScene(); Teapot->DrawSubset(0); D3DDevice->EndScene(); D3DDevice->Present(0, 0, 0, 0); } } SetCursor(PreviousCursor); if(Teapot) Teapot->Release(); if(D3DDevice) D3DDevice->Release(); if(Direct3D) Direct3D->Release(); return(Msg.wParam); } |
| QUOTE |
| Error E2268 C:\Borland\BCC55\Include\d3dx9math.inl 1515: Call to undefined function 'sqrtf' in function D3DXVec2Length(const D3DXVECTOR2 *) Error E2268 C:\Borland\BCC55\Include\d3dx9math.inl 1647: Call to undefined function 'sqrtf' in function D3DXVec3Length(const D3DXVECTOR3 *) Error E2268 C:\Borland\BCC55\Include\d3dx9math.inl 1792: Call to undefined function 'sqrtf' in function D3DXVec4Length(const D3DXVECTOR4 *) Error E2268 C:\Borland\BCC55\Include\d3dx9math.inl 1962: Call to undefined function 'sqrtf' in function D3DXQuaternionLength(const D3DXQUATERNION *) Warning W8010 C:\Borland\BCC55\Include\d3dx9core.h 485: Continuation character \ found in // comment Warning W8010 C:\Borland\BCC55\Include\d3dx9core.h 486: Continuation character \ found in // comment Warning W8010 C:\Borland\BCC55\Include\d3dx9core.h 487: Continuation character \ found in // comment Warning W8010 C:\Borland\BCC55\Include\d3dx9core.h 488: Continuation character \ found in // comment Warning W8010 C:\Borland\BCC55\Include\d3dx9core.h 489: Continuation character \ found in // comment |
| CODE |
| inline float sqrtf(float f) {return(sqrt((double)f));} |
| QUOTE | ||
You can fix the sqrtf errors (or indeed any errors from math functions ending with 'f') by the obvious:
|
| QUOTE |
| Is that some sort of function that only exists with VC++? |
| QUOTE |
| And I suppose D3DXCreateTeapot would be in d3dx9.dll or d3dx9d.dll |
| QUOTE |
| Doesn't exist in VC++4 either... But does work in VC++6. I don't think it's ANSI. |
| QUOTE |
| Because I can't either find a d3dx9.dll nor a d3dx9d.dll in the system32 dir. |
| QUOTE |
| it goes into fullscreen mode and the screen becomes a light blue. I can exit it by pushing end. It's eating up all CPU power and the screen resolution changes to (I think) 640x480. Is that what's supposed to happen? |
| QUOTE |
| That's because they're in the system dir, not the system32 dir. |
| QUOTE |
| Exactly. (Correction: sky blue (j/k)) |