Jump to content
  • Advertisement
Sign in to follow this  

error C2065: 'COUSTOMFVF' : undeclared identifier (Help)

This topic is 4215 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey there. i made this tutorials and i only get one wrong thing. and it is this: error C2065: 'COUSTOMFVF' : undeclared identifier i dont know what and what to do to fix it. here is my code. /**************************************************************** * example1 * this application shows how to setup a standard windows * application ****************************************************************/ #include <windows.h> #include <d3d9.h> // global variables HINSTANCE hInst; HWND wndHandle; LPDIRECT3D9 pD3D; LPDIRECT3DDEVICE9 pd3dDevice; LPDIRECT3DVERTEXBUFFER9 pD3DVB = NULL; #define CUSTOMFVF (D3DFVF_XYZRHW | D3DFVF_DIFFUSE) // forward declarations bool initWindow(HINSTANCE hInstance); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); bool InitDirect3D(); void Render(); void EXIT(); struct CUSTOMVERTEX { FLOAT x,y,z, rwh; DWORD color; }; 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(); } } EXIT(); return (int) msg.wParam; } 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); // create the window wndHandle = CreateWindow("DirectXExample", "DirectXExample", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, NULL, NULL, hInstance, NULL); if (!wndHandle) return false; ShowWindow(wndHandle, SW_SHOW); UpdateWindow(wndHandle); return true; } 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); } bool InitDirect3D() { VOID *pVoid; CUSTOMVERTEX OurVertices[] = { {320.0f, 50.0f, 1.0f, 1.0f, D3DCOLOR_XRGB(0, 0, 255),}, {520.0f, 400.0f, 1.0f, 1.0f, D3DCOLOR_XRGB(0, 255, 0),}, {120.0f, 400.0f, 1.0f, 1.0f, D3DCOLOR_XRGB(255, 0, 0),}, }; pD3D = Direct3DCreate9(D3D_SDK_VERSION); D3DDISPLAYMODE d3ddm; d3ddm.Format = D3DFMT_X8R8G8B8; d3ddm.Height = 480; d3ddm.RefreshRate = 0; d3ddm.Width = 640; D3DPRESENT_PARAMETERS d3dpp; ZeroMemory(&d3dpp,sizeof(d3dpp)); d3dpp.BackBufferCount = 1; d3dpp.BackBufferFormat = d3ddm.Format; d3dpp.BackBufferHeight = 480; d3dpp.BackBufferWidth = 640; d3dpp.hDeviceWindow = wndHandle; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.Windowed = TRUE; if(FAILED(pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,wndHandle,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp,&pd3dDevice))) { return FALSE; } pd3dDevice->CreateVertexBuffer(3*sizeof(CUSTOMVERTEX), 0, COUSTOMFVF, D3DPOOL_MANAGED, &pD3DVB, NULL ); pD3DVB->Lock(0,0, (void**)&pVoid, 0); memcpy(pVoid, OurVertices, sizeof(OurVertices)); pD3DVB->Unlock(); return TRUE; } void Render() { pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,50,255), 1.0f, 0); pd3dDevice->BeginScene(); pd3dDevice->SetFVF(COUSTOMFVF); pd3dDevice->SetStreamSource(0,pD3DVB,0,sizeof(CUSTOMVERTEX)); pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1); pd3dDevice->EndScene(); pd3dDevice->Present(NULL, NULL, NULL, NULL); } void EXIT() { pD3D->Release(); pd3dDevice->Release(); pD3DVB->Release(); }

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!