Sign in to follow this  
blakedev

[Solved]Syntax error with D3DXMatrixPerspectiveFovLH and custom camera class

Recommended Posts

Currently I am working on a game framework that incorporates a class to handle things such as graphics, input, cameras, etc. Basically, an object of the Graphics class is created (and is a singleton), along with a separate Camera object that is set to the active camera. My approach works fine until I want to do 3D by calling the D3DXMatrixPerspectiveFovLH function, which for some reason complains about a syntax error with a comma (C2059). Thing is, the function call requires five parameters (four commas), and I have them in all the right places. The error is always on that line, which I can comment out but the projection is messed up for any 3D rendering that I do. Thanks in advance My code: Camera's init function, where the syntax error resides:
void Camera::Init(float near, float far)
{
	D3DXMATRIX proj = Graphics::getInstance().GetProj();
	int width = Graphics::getInstance().GetWidth();
	int height = Graphics::getInstance().GetHeight();
	D3DXMatrixPerspectiveFovLH(&proj, D3DX_PI/4, width/height, near, far);
	Graphics::getInstance().GetDevice()->SetTransform(D3DTS_PROJECTION,  &Graphics::getInstance().GetProj());
}


And the Graphics class if applicable:
class Graphics
{
public:
	~Graphics(void);

	static Graphics& getInstance() { static Graphics pInstance; return pInstance;}

	void Init(int, int, int, bool, LPCSTR);
	void Shutdown(void);
	void BeginRender(void);
	void EndRender(void);
	bool Run(void);

	Camera* GetActiveCamera(void) { return m_ActiveCamera; }
	void SetActiveCamera(Camera* cam) { m_ActiveCamera = cam; }

	void SetClearColor(DWORD color) { m_dwClearColor = color; }

	LPDIRECT3DDEVICE9 GetDevice(void) { return pd3dDevice; }
	D3DXMATRIX GetProj(void) { return m_Proj; }
	int GetWidth(void) { return m_Width; }
	int GetHeight(void) { return m_Height; }

private:
	Graphics(void);

	Camera* m_ActiveCamera;

	LPDIRECT3D9             pD3D;
	LPDIRECT3DDEVICE9       pd3dDevice;
	
	// screen details
	int m_Width;
	int m_Height;
	int m_Bits;
	bool m_Fullscreen;

	DWORD m_dwClearColor;

	D3DXMATRIX m_Proj;
};


[Edited by - blakedev on April 22, 2008 9:17:47 PM]

Share this post


Link to post
Share on other sites
The word "near" and the word "far" are reserved C words. The compiler is expecting you to define some near pointer but finds a comma.

Change the arguments in Init to Near and Far, or nearWall and farWall or something.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this