Syntax Error : Identifier

Hey guys, I'm am still a semi beginner at C++ programming. I have this issue with an syntax error identifier that I just cannot see any reason for no matter how hard I look. If anyone could help it would be much appreciated.

Here are the classes involved:

Direct3D.h
#ifndef DIRECT3D_H_
#define DIRECT3D_H_

#include <d3dx9.h>
#include <vector>

#include "Singleton.h"
#include "GameEntity.h"
#include "ThirdPersonCamera.h"

class Direct3D : public Singleton<Direct3D>		//Inherits from singleton
{
private:
	LPDIRECT3D9 m_d3dObject;
	LPDIRECT3DDEVICE9 m_d3dDevice;

	Direct3D();		//Private constructor and destructor so that object creation
	~Direct3D();	//and deletion is handled by the Singleton class.

public:
	LPDIRECT3DDEVICE9 GetDevice() { return m_d3dDevice; }
	bool Initialise(HWND hwnd, bool fullscreen);	//Hides the complex direct3D initialisation code in one method.
	void Draw(ThirdPersonCamera* cam, std::vector<GameEntity*> entities);	//This function draws our list of entities to the screen
	void Release();									//Clean up, called by the destructor

	//In order for singleton to be able to access the private constructor we have to friend
	//the direct3D version of singleton like this:
	friend class Singleton<Direct3D>;
};

#endif


ThirdPersonCamera.h
#ifndef THIRDPERSONCAMERA_H_
#define THIRDPERSONCAMERA_H_

#include <d3dx9.h>
#include "Direct3D.h"
#include "Player.h"

class ThirdPersonCamera 
{
private:
	D3DXMATRIX m_view;
	D3DXMATRIX m_projection;

	D3DXVECTOR3 m_position;
	D3DXVECTOR3 m_lookAt;
	D3DXVECTOR3 m_up;

	float m_fov;
	float m_aspectRatio;
	float m_nearPlane;
	float m_farPlane;

public:
	ThirdPersonCamera(D3DXVECTOR3 position, D3DXVECTOR3 lookAt, D3DXVECTOR3 up, float fov,
			float aspectRatio, float nPlane, float fPlane);

	void Update(Player* player);

	const D3DXMATRIX* GetView() {return &m_view; }
	const D3DXMATRIX* GetProjection() {return &m_projection; }


};

#endif



Direct3D.cpp

#include "Direct3D.h"

Direct3D::Direct3D()
{
	m_d3dObject = NULL;
	m_d3dDevice = NULL;
}

Direct3D::~Direct3D()
{
	Release();
}

bool Direct3D::Initialise(HWND hwnd, bool fullscreen)
{
	//This method really just takes the code that we've been using
	//all along and places it in an object.

	D3DDISPLAYMODE DisplayMode;

	// This will allow us to set the parameters of the screen.
	D3DPRESENT_PARAMETERS Present_Parameters;

	// This is used to get the capabilities of the hardware.
	D3DCAPS9 D3DCaps;

	// It is always a good idea to clear out memory in object although not necessary.
	ZeroMemory(&Present_Parameters, sizeof(Present_Parameters));

	// Create the Direct3D object to get everything started.
	m_d3dObject = Direct3DCreate9(D3D_SDK_VERSION);

	// Error checking.  Make sure that it was successful.
	if(m_d3dObject == NULL)
	{
		MessageBox(NULL, "Error, couldn't initialize DirectX!?!",
			"Error!", MB_OK);
		return false;
	}

	// This function will get the display mode of the device and place it in DisplayMode.
	if(FAILED(m_d3dObject->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &DisplayMode)))
	{
		MessageBox(NULL, "Error setting the display mode.", "Error!", MB_OK);
		return false;
	}

	// Get the capabilities of the hardware.
	if(FAILED(m_d3dObject->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &D3DCaps)))
		return false;

	// Test which is supported, hardware or software vertex processing.
	DWORD VertexProcessing = 0;

	if(D3DCaps.VertexProcessingCaps != 0)
		VertexProcessing |= D3DCREATE_HARDWARE_VERTEXPROCESSING;
	else
		VertexProcessing |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;

	// Here we are setting the applications parameters...
	if(fullscreen)
	{
		Present_Parameters.Windowed = FALSE;               // Window mode (fullscreen).
		Present_Parameters.BackBufferWidth = DisplayMode.Width;
		Present_Parameters.BackBufferHeight = DisplayMode.Height;
	}
	else
	{
		Present_Parameters.Windowed = TRUE;                   // Window mode (not fullscreen).
	}
	Present_Parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;   // Dealing with animation (see doc).
	Present_Parameters.BackBufferFormat = DisplayMode.Format;// Render to the area of the screen.
	Present_Parameters.BackBufferCount = 1;                  // Number of back buffers.
	Present_Parameters.EnableAutoDepthStencil = TRUE;        // Check documentation.
	Present_Parameters.AutoDepthStencilFormat = D3DFMT_D16;  // Check documentation.

	// Now we must create the rendering device.
	if(FAILED(m_d3dObject->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd,
		D3DCREATE_SOFTWARE_VERTEXPROCESSING,
		&Present_Parameters, &m_d3dDevice)))
	{
		MessageBox(NULL, "CreateDevice() failed!  Make sure you have DirectX 9.",
			"Error!", MB_OK);
		return false;
	}

	// One last check to be sure.
	if(m_d3dDevice == NULL)
	{
		MessageBox(NULL, "m_d3dDevice is equal to NULL!?!", "Error!", MB_OK);
		return false;
	}
	m_d3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE);

	m_d3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);// Culling off.
	m_d3dDevice->SetRenderState(D3DRS_ZENABLE, TRUE);         // Enable depth testing.

	D3DXMATRIX View;
	D3DXVECTOR3 Eye(0.0f, 10.0f, -10.0f);     // Position of view.
	D3DXVECTOR3 LookAt(0.0f, 0.0f, 0.0f);   // Point view is looking at.
	D3DXVECTOR3 Up(0.0f, 1.0f, 0.0f);       // Which way is up.

	// Set all the values this matrix will need to know (position, look at point, etc).
	D3DXMatrixLookAtLH(&View, &Eye, &LookAt, &Up);

	// Move the "view" to the position and values we set above.
	m_d3dDevice->SetTransform(D3DTS_VIEW, &View);

	D3DXMATRIX Projection;

	// Set the perspective information.
	D3DXMatrixPerspectiveFovLH(&Projection, 45.0f, 640/480, 0.1f, 500.0f);

	// Set the projection.
	m_d3dDevice->SetTransform(D3DTS_PROJECTION, &Projection);

	return true;
}

void Direct3D::Draw( ThirdPersonCamera* cam, std::vector<GameEntity*> entities)
{
	//Here we go through our list of entities and call draw.
	m_d3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
		D3DCOLOR_XRGB(0,0,0), 1.0f, 0);

	m_d3dDevice->BeginScene();

	for(unsigned int i = 0; i < entities.size(); i++)
	{
		entities[i]->Draw(m_d3dDevice);
	}

	m_d3dDevice->EndScene();
	m_d3dDevice->Present(NULL, NULL, NULL, NULL);
}

void Direct3D::Release()
{
	//This method cleans up the Direct3D objects that have been created.
	if(m_d3dDevice)
	{
		m_d3dDevice->Release();
		m_d3dDevice = NULL;
	}

	if(m_d3dObject)
	{
		m_d3dObject->Release();
		m_d3dObject = NULL;
	}
}


ThirdPersonCamera.cpp
#include "ThirdPersonCamera.h"

ThirdPersonCamera::ThirdPersonCamera(D3DXVECTOR3 position, D3DXVECTOR3 lookAt, D3DXVECTOR3 up, float fov,
			float aspectRatio, float nPlane, float fPlane)
{
	

	m_position = position;
	m_lookAt = lookAt;
	m_up = up;
	m_fov = fov;
	m_aspectRatio = aspectRatio;
	m_nearPlane = nPlane;
	m_farPlane = fPlane;
}

void ThirdPersonCamera::Update(Player* player)
{
	D3DXVECTOR3 offset(0, 5, -5);

	D3DXMatrixLookAtLH(&m_view, &m_position, &m_lookAt, &m_up);
	D3DXMatrixPerspectiveFovLH(&m_projection, m_fov, m_aspectRatio, m_nearPlane, m_farPlane);
}


and the errors

1>------ Build started: Project: The Best RPG, Configuration: Debug Win32 ------
1>  main.cpp
1>c:\users\user\documents\visual studio 2012\projects\the best rpg\the best rpg\direct3d.h(29): error C2061: syntax error : identifier 'ThirdPersonCamera'
1>c:\users\user\documents\visual studio 2012\projects\the best rpg\the best rpg\main.cpp(191): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\user\documents\visual studio 2012\projects\the best rpg\the best rpg\main.cpp(215): error C2660: 'Direct3D::Draw' : function does not take 2 arguments
1>  ThirdPersonCamera.cpp
1>c:\users\user\documents\visual studio 2012\projects\the best rpg\the best rpg\direct3d.h(29): error C2061: syntax error : identifier 'ThirdPersonCamera'
1>  Direct3D.cpp
1>  Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



If you need any other parts of the code please let me know. thanks!
I don't think you need to do this:
1
2
3
4
5
6
7
8
9
#ifndef THIRDPERSONCAMERA_H_
#define THIRDPERSONCAMERA_H_

#include <d3dx9.h>
#include "Direct3D.h"  //i don't think you need to include this file
#include "Player.h"

class ThirdPersonCamera 
{


this error:
c:\users\user\documents\visual studio 2012\projects\the best rpg\the best rpg\main.cpp(215): error C2660: 'Direct3D::Draw' : function does not take 2 arguments
1> ThirdPersonCamera.cpp

is in the main.cpp file. So is the one above it.
Last edited on
for(unsigned int i = 0; i < entities.size(); i++)

what type does entities.size() return?

if it returns int, you should have

for(int i = 0; i < entities.size(); i++)
Thanks for your replies. the errors in the main.cpp are being caused by the syntax error : idenifier because that Draw function takes in a ThirdPersonCamera, what I need to deal with is the identifier errors, i tested removing the include you mentioned but it is required.

Thanks again
It is required for the DirectX stuff. The reason why I mention this is because if you have a circular dependency the compiler will generate unknown identifier errors because it does not know how to build your object.

Consider removing your directx header and replace in its stead the dirextx includes required to make your thirdpersoncamera class work.
Topic archived. No new replies allowed.