Skip to main content
gamedev.net
🔒 Locked

Class library error

Started by PuterPaul Sep 8, 2003 at 6:06 AM 1 replies 600+ views
Original Post
PuterPaul
PuterPaul
I''m getting the followign link error when trying to compile my classes into a dll
inking...
DxWindow.obj : error LNK2001: unresolved external symbol "public: void __thiscall DxWindow::MsgPump(void)" (?MsgPump@DxWindow@@QAEXXZ)
Debug/DirectXObjects.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe. 
Here are the source files Dx3dDevic.h
#ifndef DX3DDEVICE_H
#define DX3DDEVICE_H

#include <d3d9.h>
#include <windows.h>

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


class Dx3dDevice  
{
public:
	Dx3dDevice();
	virtual ~Dx3dDevice();
	HRESULT InitD3D( HWND hWnd );
	VOID CleanUp();
	LPDIRECT3DDEVICE9 Get3dDevice();
	VOID Render();
private:
	LPDIRECT3D9             m_pD3D; // Used to create the D3DDevice

	LPDIRECT3DDEVICE9       m_pd3dDevice; // Our rendering device


};

#endif
Dx3dDevice.cpp
// DxDevice.cpp: implementation of the DxDevice class.

//

//////////////////////////////////////////////////////////////////////


#include "Dx3dDevice.h"

//////////////////////////////////////////////////////////////////////

// Construction/Destruction

//////////////////////////////////////////////////////////////////////


Dx3dDevice::Dx3dDevice()
{
	m_pD3D		 = NULL;
	m_pd3dDevice = NULL;
}

Dx3dDevice::~Dx3dDevice()
{	
}

HRESULT Dx3dDevice::InitD3D(HWND hWnd)
{	
    // Create the D3D object, which is needed to create the D3DDevice.

    if( NULL == ( m_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
        return E_FAIL;

    // Set up the structure used to create the D3DDevice. Most parameters are

    // zeroed out. We set Windowed to TRUE, since we want to do D3D in a

    // window, and then set the SwapEffect to "discard", which is the most

    // efficient method of presenting the back buffer to the display.  And 

    // we request a back buffer format that matches the current desktop display 

    // format.

    D3DPRESENT_PARAMETERS d3dpp; 
    ZeroMemory( &d3dpp, sizeof(d3dpp) );
    d3dpp.Windowed = TRUE;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;

    // Create the Direct3D device. Here we are using the default adapter (most

    // systems only have one, unless they have multiple graphics hardware cards

    // installed) and requesting the HAL (which is saying we want the hardware

    // device rather than a software one). Software vertex processing is 

    // specified since we know it will work on all cards. On cards that support 

    // hardware vertex processing, though, we would see a big performance gain 

    // by specifying hardware vertex processing.

    if( FAILED( m_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
                                      D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                      &d3dpp, &m_pd3dDevice ) ) )
    {
        return E_FAIL;
    }

    // Device state would normally be set here


    return S_OK;
}

VOID Dx3dDevice::CleanUp()
{	
    if( m_pd3dDevice != NULL) 
        m_pd3dDevice->Release();

    if( m_pD3D != NULL)
        m_pD3D->Release();
}

LPDIRECT3DDEVICE9 Dx3dDevice::Get3dDevice()
{
	return m_pd3dDevice;
}

VOID Dx3dDevice::Render()
{	
    if( NULL == m_pd3dDevice )
        return;

    // Clear the backbuffer to a blue color

    m_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
    
    // Begin the scene

    if( SUCCEEDED( m_pd3dDevice->BeginScene() ) )
    {
        // Rendering of scene objects can happen here

    
        // End the scene

        m_pd3dDevice->EndScene();
    }

    // Present the backbuffer contents to the display

    m_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
DxWindow.h
// DxWindow.h: interface for the DxWindow class.

//

//////////////////////////////////////////////////////////////////////


#ifndef DXWINDOW_H
#define DXWINDOW_H
#include "Dx3dDevice.h"

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


class DxWindow  
{
public:
	DxWindow();
	virtual ~DxWindow();
	LRESULT WINAPI MsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
	void MsgPump();
	int WINAPI Create(HINSTANCE hInst, HINSTANCE, LPSTR, INT);
private:
	Dx3dDevice* m_D3D;	

};

#endif
DxWindow.cpp
// DxWindow.cpp: implementation of the DxWindow class.

//

//////////////////////////////////////////////////////////////////////


#include "DxWindow.h"

//////////////////////////////////////////////////////////////////////

// Construction/Destruction

//////////////////////////////////////////////////////////////////////

static DxWindow *dxwin = NULL;
LRESULT WINAPI WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
	return dxwin->MsgProc( hWnd, msg, wParam, lParam );
}

int WINAPI DxWindow::Create(HINSTANCE hInst, HINSTANCE, LPSTR, INT)
{
	// Register the window class

	WNDCLASSEX wc = 	{
		sizeof(WNDCLASSEX),
			CS_CLASSDC,
			WndProc,
			0L,
			0L,
			GetModuleHandle(NULL),
			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, wc.hInstance, NULL );

    // Initialize Direct3D

    if( SUCCEEDED( m_D3D->InitD3D( hWnd ) ) )
    { 
        // Show the window

        ShowWindow( hWnd, SW_SHOWDEFAULT );
        UpdateWindow( hWnd );

		// Enter Message loop

		MsgPump();
	}	

    UnregisterClass( "D3D Tutorial", wc.hInstance );

	return 0;
}


LRESULT WINAPI DxWindow::MsgProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
{	
    switch( msg )
    {
        case WM_DESTROY:
            m_D3D->CleanUp();
            PostQuitMessage( 0 );
            return 0;

        case WM_PAINT:
            m_D3D->Render();
            ValidateRect( hWnd, NULL );
            return 0;
    }

    return DefWindowProc( hWnd, msg, wParam, lParam );
}

DxWindow::DxWindow()
{
	dxwin = NULL;
}

DxWindow::~DxWindow()
{

}
Has anyone got any ideas???
VolkerG
VolkerG
Can't find the implementation of DxWindow::MsgPump anywhere. That's just what the linker is telling you.

[edited by - VolkerG on September 8, 2003 7:10:46 AM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.