Thread: Trouble with Windows/DirectX programming

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    141

    Trouble with Windows/DirectX programming

    UPDATE:
    I put the
    Code:
    LPDIRECT3D9 g_pDirect3D = NULL;
    LPDIRECT3DDEVICE9 g_pDirect3D_Device = NULL;
    At the top, now all I get is:
    error C2065: 'WndProc' : undeclared identifier

    Update: I just fixed the wndproc thing, just a typo there..

    I compiled, and debuged and got this:

    Code:
    1>main.obj : error LNK2019: unresolved external symbol _Direct3DCreate9@4 referenced in function _WinMain@16
    1>fatal error LNK1120: 1 unresolved externals
    Code:
    
    #include <windows.h>
    #include <d3d9.h>
    
    /// Update 1
    LPDIRECT3D9 g_pDirect3D = NULL;
    LPDIRECT3DDEVICE9 g_pDirect3D_Device = NULL;
    
    // Update 2, changed WinProc to WndProc, silly typo xD
    LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lParam);
    
    int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nShow)
    {
    	MSG msg;
    
    	WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_VREDRAW|CS_HREDRAW|CS_OWNDC,WndProc, 
    		0,0,hInstance, NULL, NULL, (HBRUSH)(COLOR_WINDOW+1),NULL, "DX9_TUTORIAL1_CLASS", NULL };
    
    	RegisterClassEx(&wc);
    
    	HWND hMainWnd = CreateWindow(
    		"DX9_TUTORIAL1_CLASS", 
    		"DirectX9 test", 
    		WS_OVERLAPPEDWINDOW, 
    		100,100,
    		300,300,
    		NULL,
    		NULL,
    		hInstance, 
    		NULL);
    
    
    	g_pDirect3D = Direct3DCreate9(D3D_SDK_VERSION);
    
    	D3DPRESENT_PARAMETERS PresentParams;
    
    	memset(&PresentParams, 0, sizeof(D3DPRESENT_PARAMETERS));
    
    	PresentParams.Windowed = TRUE;
    	PresentParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
    
    
    	g_pDirect3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hMainWnd, 
    		D3DCREATE_SOFTWARE_VERTEXPROCESSING, &PresentParams, &g_pDirect3D_Device);
    
    	ShowWindow(hMainWnd, nShow);
    	UpdateWindow(hMainWnd);
    
    
    	while (GetMessage(&msg, NULL, 0, 0))
    	{
    
    		TranslateMessage(&msg);
    		DispatchMessage(&msg);
    
    	}
    
    
    	return 0;
    
    
    }
    
    LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
    
    	switch(msg)
    	{
    	
    	case WM_DESTROY:
    		PostQuitMessage(0);
    		return 0;
    
    	case WM_PAINT:
    		g_pDirect3D_Device->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255),1.0f, 0);
    		g_pDirect3D_Device->Present(NULL, NULL, NULL, NULL);
    		ValidateRect(hwnd, NULL);
    		return 0;
    
    	}
    
    	g_pDirect3D_Device->Release();
    	g_pDirect3D->Release();
    	return DefWindowProc(hwnd, msg, wParam, lParam);
    
    }
    Most of the errors are just saying an unidentifier

    Code:
    (10) : error C2065: 'WndProc' : undeclared identifier
    (27) : error C2065: 'g_pDirect3D' : undeclared identifier
    (37) : error C2065: 'g_pDirect3D' : undeclared identifier
    (37) : error C2227: left of '->CreateDevice' must point to class/struct/union/generic type
    1>        type is ''unknown-type''
    (37) : error C2065: 'g_pDirect3D_Device' : undeclared identifier
    (68) : error C2065: 'g_pDirect3D_Device' : undeclared identifier
    (68) : error C2227: left of '->Clear' must point to class/struct/union/generic type
    1>        type is ''unknown-type''
    (69) : error C2065: 'g_pDirect3D_Device' : undeclared identifier
    (69) : error C2227: left of '->Present' must point to class/struct/union/generic type
    1>        type is ''unknown-type''
    (75) : error C2065: 'g_pDirect3D_Device' : undeclared identifier
    (75) : error C2227: left of '->Release' must point to class/struct/union/generic type
    1>        type is ''unknown-type''
    (76) : error C2065: 'g_pDirect3D' : undeclared identifier
    (76) : error C2227: left of '->Release' must point to class/struct/union/generic type
    Last edited by bobbelPoP; 07-05-2008 at 12:15 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trouble with assignment in C
    By mohanlon in forum C Programming
    Replies: 17
    Last Post: 06-23-2009, 10:44 AM
  2. Replies: 6
    Last Post: 01-03-2007, 03:02 PM
  3. Is it so trouble?
    By Yumin in forum Tech Board
    Replies: 4
    Last Post: 01-30-2006, 04:10 PM
  4. trouble scanning in... and link listing
    By panfilero in forum C Programming
    Replies: 14
    Last Post: 11-21-2005, 12:58 PM
  5. C++ program trouble
    By senrab in forum C++ Programming
    Replies: 7
    Last Post: 04-29-2003, 11:55 PM