Advertisement

Access Violation

Started by March 09, 2003 12:12 PM
0 comments, last by MrBeaner 21 years, 8 months ago
I have a textLog class which writes to a text log (surpise!) It works fine in it''s own test environment, but when i add it to my engine i get an access violation. here is the header file:
  
/*
	VectorThunder vector engine.
	Patrick O''Grady
	:)
*/

#ifndef _VT_
#define _VT_

#include <windows.h>
#include <Dxerr8.h>

#include "DirectX.h"
#include "DIControl.h"
#include "GraphicObject.h"
#include "DeviceMan.h"
#include "CTextLog.h"
#include "CMath.h"
//#include "CStatBar.h"
//menu class

//--------------------global constants------------------

const int DEFAULT_WINDOW_WIDTH = 640;
const int DEFAULT_WINDOW_HEIGHT = 480;
const bool DEFAULT_WINDOW_STATE = false;

class VT
{
public:

	VT();
	~VT();

/*------------------Initialization methods---------------------*/
	bool Init(HWND hWnd, HINSTANCE hInst, CTextLog* GameLog);
	bool Init(int Width, int Height, HWND hWnd, HINSTANCE hInst, bool bWindowed, CTextLog* GameLog);
	bool ReInitVideo(int Width , int Height, bool bWindowed);

	bool HasCollided(BaseVectorObject* Obj1, BaseVectorObject* Obj2);
	CVector* GetRotation(CVector Point1, CVector Point2);
	
	bool GetInput(INPUTBUFFER& Buffer);

	bool Run();

/*You must tell the engine that you are rendering*/
	void BeginRender();
	void EndRender();
/*You must tell the engine that you are done rendering.*/

protected:

	DeviceMan GDevice;
	DIKeyboard KeyBoard;
	DIMouse Mouse;
	CTextLog* Log;
	CMath Math;
};

#endif /* _VT_ */

  
and here is the area where it dies:
  
bool VT::Init(HWND hWnd, HINSTANCE hInst, CTextLog* GameLog)
{
	HRESULT r;

	Log = GameLog;  // this value is passed in through the main app.  I get the access violation here.  CTextLog is initialized earilier in another class which calls VT::Init(...).

...
}
  
It''s declared as a public member in teh CAppClass, so i''m not ure what is going on. What usually causes an access violation? Thanks for your help! EOF
------------------------------------------VOTE Patrick O'GradyWrite in Presidential CandidateThe Candidate who Cares.
What causes an access violation?

Well, I guess it has someting to do with the reference to memory that doen't belong to your application, i.e. you should check if you don't reference memory that's out of scope.
(the same holds true for dynamically allocated memory).



[edited by - Raab314159 on March 9, 2003 3:53:18 PM]

This topic is closed to new replies.

Advertisement