I want dead the problem kill me

Started by
8 comments, last by derek7 18 years, 10 months ago


#ifndef __d3dUtilityH__
#define __d3dUtilityH__

#include "CCamera.h"
#include <d3dx9.h>
#include <d3d9.h>


	const D3DXCOLOR      WHITE( D3DCOLOR_XRGB(255, 255, 255) );
	const D3DXCOLOR      BLACK( D3DCOLOR_XRGB(  0,   0,   0) );
	const D3DXCOLOR        RED( D3DCOLOR_XRGB(255,   0,   0) );
	const D3DXCOLOR      GREEN( D3DCOLOR_XRGB(  0, 255,   0) );
	const D3DXCOLOR       BLUE( D3DCOLOR_XRGB(  0,   0, 255) );
	const D3DXCOLOR     YELLOW( D3DCOLOR_XRGB(255, 255,   0) );
	const D3DXCOLOR       CYAN( D3DCOLOR_XRGB(  0, 255, 255) );
	const D3DXCOLOR    MAGENTA( D3DCOLOR_XRGB(255,   0, 255) );

	//
	// Materials
	//

	D3DMATERIAL9 InitMtrl(D3DXCOLOR a, D3DXCOLOR d, D3DXCOLOR s, D3DXCOLOR e, float p);

	const D3DMATERIAL9 WHITE_MTRL  = InitMtrl(WHITE, WHITE, WHITE, BLACK, 2.0f);
	const D3DMATERIAL9 RED_MTRL    = InitMtrl(RED, RED, RED, BLACK, 2.0f);
	const D3DMATERIAL9 GREEN_MTRL  = InitMtrl(GREEN, GREEN, GREEN, BLACK, 2.0f);
	const D3DMATERIAL9 BLUE_MTRL   = InitMtrl(BLUE, BLUE, BLUE, BLACK, 2.0f);
	const D3DMATERIAL9 YELLOW_MTRL = InitMtrl(YELLOW, YELLOW, YELLOW, BLACK, 2.0f);

	//strcpy
	void CopyString(const char* input, char** output);

	int EnterMsgLoop( 
		bool (*ptr_display)(float timeDelta));


	template<class T> void Release(T t)
	{
		if( t )
		{
			t->Release();
			t = 0;
		}
	}
		
	template<class T> void Delete(T t)
	{
		if( t )
		{
			delete t;
			t = 0;
		}
	}


	//
	//
	//
	void CameraByKey(float,Camera&);
	void CameraByMouse(Camera&);
	void Cleanup();

	char* fpsCount(float sumtimeDelta);

#endif // __d3dUtilityH__

the head file work fine with some cpp file it need,but no work with other cpp . there are many error rise.but I know these error is not actual error.something else cause these error.these error is C2059 C2143 C2988 ... but if I put the head file at top of the cpp ,I mean above all other .h file all is ok. what the hell is the problem? I guess template is "big problem"
Advertisement
header file
// ...	extern const D3DXCOLOR WHITE, BLACK, RED, GREEN, ........// ...


source file
// ...	const D3DXCOLOR      WHITE( D3DCOLOR_XRGB(255, 255, 255) ),	                     BLACK( D3DCOLOR_XRGB(  0,   0,   0) ),	                       RED( D3DCOLOR_XRGB(255,   0,   0) ),	                     GREEN( D3DCOLOR_XRGB(  0, 255,   0) ),	                      BLUE( D3DCOLOR_XRGB(  0,   0, 255) ),	                    YELLOW( D3DCOLOR_XRGB(255, 255,   0) ),	                    CYAN( D3DCOLOR_XRGB(  0, 255, 255) ),	                   MAGENTA( D3DCOLOR_XRGB(255,   0, 255) );// ...
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
probably it is not this reason.because the const in head file is ok.

this head file in other cpp is ok.

just not work in some cpp .
no skilled man could resolve this problem?
template<class T> void Delete(T t){  if( t )  {      delete t;      t = 0;  }}


You don't need to check that t != 0 as delete 0 is a no-op (no operation).
Also to get the effect you really want it should be:

template<class T> void Delete(T*& t){  delete t;  t = 0;}

That way, you really are deleting a pointer and setting it to zero will affect the pointer passed to you because it has been passed by reference.
I'm going to venture a guess that smart_idiot is right
If CCamera.h references any DX types (or any other type that is defined in headers included by d3d9.h/d3dx9.h), then it needs to be listed after d3dx9.h/d3d9.h in the header file.
Quote:Original post by Catafriggm
I'm going to venture a guess that smart_idiot is right


I'm going to venture a guess that he's not (although he usually is) - const variables are implicitly static, by which I mean they will not be exported outside of the translation unit (that is, defining the same const variable in two .cpp files is perfectly fine).

That said, I could be totally missing something that smart_idiot's noticed, in which case ignore me. Especially considering I can't tell what the hell the the OP is saying most of the time, and see no problems with his code, and am guessing the bug is elsewhere.

Dave Hunt: CCamera.h should include d3d9.h/d3dx9.h itself if it uses types from those headers.

derek7: Post the full errors, not just their codes.
Open up CCamera.h and make sure that your CCamera class has a semi-colon at the end. Look for any other missing semi-colons in that file.
I solve this problem through removing template define.the camera.h may be just fine.beacuse
the Uitility.h work fine with some cpp.
#ifndef __cameraH__#define __cameraH__#include <d3dx9.h>#include "aabb.h"class Camera{public:	enum CameraType { LANDOBJECT, AIRCRAFT };	Camera();	Camera(CameraType cameraType);	~Camera();	void strafe(float units); // left/right	void fly(float units);    // up/down	void walk(float units);   // forward/backward		void pitch(float angle); // rotate on right vector	void yaw(float angle);   // rotate on up vector	void roll(float angle);  // rotate on look vector	void getViewMatrix(D3DXMATRIX* V); 	void setCameraType(CameraType cameraType); 	void getPosition(D3DXVECTOR3* pos); 	void setPosition(D3DXVECTOR3* pos); 	void getRight(D3DXVECTOR3* right);	void getUp(D3DXVECTOR3* up);	void getLook(D3DXVECTOR3* look);	void getTranslationMatrix(D3DXMATRIX *);	AABB &updateAABB();	private:		CameraType  _cameraType;	D3DXVECTOR3 _right;	D3DXVECTOR3 _up;	D3DXVECTOR3 _look;	D3DXVECTOR3 _pos;	AABB _box;	AABB t;};#endif // __cameraH__#ifndef __aabb__#define __aabb__#include <d3dx9.h>struct AABB{	D3DXVECTOR3 max;	D3DXVECTOR3 min;};bool    intersectAABBs(	const AABB &box1,	const AABB &box2,	AABB *boxIntersect);#endif

This topic is closed to new replies.

Advertisement