Jump to content
  • Advertisement
Sign in to follow this  

Distorted screen shows up after my app closes...

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

This is a weird (and bad) bug. My game runs fine it's written in c++ and DX 9.0c, but if after I run it.. If I run something like a java game, my entire screen gets covered in a garbaged up image of my game. Obviously I'm not cleaning up after myself properly, but I'm not sure what it is. Here's my cleanup code:

	//Game finished, so destroy game objects
	LogInfo("<br>Finish Game:");


	// Delete Mesh's

	//Game finished, so save statistics to log
	DWORD dwDuration = (m_dwEndTime - m_dwStartTime) / 1000;
	if((dwDuration != 0)&&(m_dwFrames != 0))
		//Log stats
		LogInfo("<li>Start Time (ms): %d", m_dwStartTime);
		LogInfo("<li>End Time (ms): %d", m_dwEndTime);
		LogInfo("<li>Duration (s): %d", dwDuration);
		LogInfo("<li>Total Frame Count: %d", m_dwFrames);
		LogInfo("<li>Average FPS: %d", (m_dwFrames / dwDuration));
		LogInfo("<li>Total Polygons: %d", m_dwTotalPolygons);
		LogInfo("<li>Average Polygons per Frame: %d", (m_dwTotalPolygons / m_dwFrames));
		LogInfo("<br>No statistics to report");


Here's my engine class:
class DXEngine : public CBase
	virtual ~DXEngine();
	// Global functions
	bool Initialise(HINSTANCE hInst, HWND hWnd, UINT nWidth, UINT nHeight);
	void MessageLoop();

	// Meshes
	CMesh* m_pEarth;

	// Fonts
	FontEngine m_font;


	// DirectX Variables
	LPD3DXSPRITE m_pd3dxSprite; // Interface to Sprite routines
	LPDIRECT3DVERTEXBUFFER9 m_pVertexBuffer; // The vertex buffer

	DWORD m_dwFrames;
	DWORD m_dwStartTime;
	DWORD m_dwEndTime;
	DWORD m_dwTotalPolygons;
	DWORD m_word;

	// 3d Graphics functions
	bool InitialiseLights();
	D3DFORMAT CheckDisplayMode(UINT nWidth, UINT nHeight, UINT nDepth);;
	bool InitialiseD3D(HWND hWnd, UINT nWidth, UINT nHeight);
	HRESULT InitialiseVertexBuffer();
	bool InitialiseGame();
	void Render();
	void SetupCamera();
	void RenderEarth();
	void CreateExplosion(D3DXVECTOR3 location);

	// Particle systems
	ParticleSys m_explosion1;
	ParticleSys m_explosion2;

	// 2d Graphics functions
	HRESULT BltSprite( D3DXMATRIX matWorld, LPDIRECT3DTEXTURE9 pSrcTexture, RECT *pSrcRect, DWORD dwFlags );
	LPDIRECT3DTEXTURE9 LoadTexture(char *filename);

	HRESULT Draw2d(LPDIRECT3DTEXTURE9 pSrcTexture, RECT *pSrcRect, D3DXVECTOR3 trans, float scale, DWORD dwFlags );

	void DrawShip(SPACESHIP player);
	void DrawBullets(BULLETSET bullets);
	void DrawBackground();
	void DrawLives();
	void DrawLoser();
	void DrawCountDown();
	// Direct Input
	DXInput Input;
	void ProcessKBInput();

	// Timer class
	Timer Timer;

	// Gameplay Variables
	GameModes gameMode;
	SPACESHIP m_player1;
	SPACESHIP m_player2;

	BULLETSET m_player1Bullets;
	BULLETSET m_player2Bullets;

	// Global class
	GLOBALS global;

	// Gameplay Functions
	void NewGame();
	void GameMain();

	//void ProcessKBInput();
	void HandleObjects();
	void MoveBullets();
	void BulletCollisionDetect();

	// MikHaven - mikhaven@hotmail.com
	float MenuCursorX;
	float MenuCursorY;
	GameStates state;
	void InitialiseMenu();
	void ProcessKBMenu();
	void RenderMenu();

I'm obviously not cleaning up something proplerly, anyone know what?

Share this post

Link to post
Share on other sites
You should release your objects in the reverse order that you created them so:

Release in this order

<Sprites, vbs, etc.>, then D3DDevice and last D3D...

I hope that will fix it

Share this post

Link to post
Share on other sites
my debugger says: Direct3D9: (ERROR) :Total Memory Unfreed From Current Process = 52952 bytes

How do I track down what isn't being freed?

Share this post

Link to post
Share on other sites
Try reading about memory; specifically allocation and deallocation. Basically what you have is a memory leak if im not mistaken; or you could use something like mmgr to override your new and delete commands and it should take care of it for you and give you information where its leaking.

Share this post

Link to post
Share on other sites
Is mmgr something I can download for free? Where do I get it? I'm using microsoft visual studio .net 2003

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!