Jump to content
  • Advertisement
Sign in to follow this  

[Solved]Syntax error with D3DXMatrixPerspectiveFovLH and custom camera class

This topic is 3715 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

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

	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; }


	Camera* m_ActiveCamera;

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

	DWORD m_dwClearColor;


[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
Sign in to follow this  

  • Advertisement

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!