Unhandled Exception: PGui

I’m trying to create a main menu for my game but when I try to run the compiled code, it gives me:

Unhandled exception at 0x77bb15ee in TicTacToeCube.exe: 0xC0000005: Access violation reading location 0x00000064.

Here is the code:

void MainMenu::ShowMenu() {
	aspect2d = win_ptr->get_aspect_2d();

	PT(Texture) Button_ReadyTex = TexturePool::load_texture("Button_Ready.png");
	PT(Texture) Button_RolloverTex = TexturePool::load_texture("Button_Rollover.png");
	PT(Texture) Button_PressedTex = TexturePool::load_texture("Button_Pressed.png");
	PT(Texture) Button_InactiveTex = TexturePool::load_texture("Button_Inactive.png");

	// NewGameBtn
	NewGameBtn = new PGButton("NewGame");
	NewGameBtn->setup("New Game");

	NewGameBtn_Style = NewGameBtn->get_frame_style(0);
	NewGameBtn_Style.set_type(PGFrameStyle::T_flat);

	NewGameBtn_Style.set_texture(Button_ReadyTex);
	NewGameBtn->set_frame_style(0, NewGameBtn_Style);

	NewGameBtn_Style.set_texture(Button_RolloverTex);
	NewGameBtn->set_frame_style(1, NewGameBtn_Style);

	NewGameBtn_Style.set_texture(Button_PressedTex);
	NewGameBtn->set_frame_style(2, NewGameBtn_Style);

	NewGameBtn_Style.set_texture(Button_InactiveTex);
	NewGameBtn->set_frame_style(3, NewGameBtn_Style);
	
	NewGameBtn_Np = aspect2d.attach_new_node(NewGameBtn);
	NewGameBtn_Np.set_scale(1.0);
}

It breaks at this line:

NewGameBtn = new PGButton("NewGame");

Btw, here are the definitions for everything that is used in the code above:

NodePath aspect2d;
WindowFramework *win_ptr;

PT(PGButton) NewGameBtn;
NodePath NewGameBtn_Np;
PGFrameStyle NewGameBtn_Style;

I’m using VS 2008 Pro x64 on Win7 Pro x64 with Panda3D 1.7.2

Thanks for any help you can provide.

My first suspicion is that you didn’t remove NDEBUG from the project specifications.

David

How would I go about doing that?

Also, why would it effect the output if I’m compiling it as a Release?

Try this thread for another person’s take on the discovery.

NDEBUG is defined by default in a Release build. However, for correct compilation, it must not be, because the Panda build provided here did not have it defined when it was built, and its presence changes the size of some key low-level structures.

Find the setting in your project properties and remove it.

David

I don’t see anything defined in the Preprocessor definitions (except for _MBCS which is inherited by the parent solution).

I tried using #undef NDEBUG but it didn’t seem to work either.

Here, I uploaded the files to my dropbox: http://dl.dropbox.com/u/27637302/TicTacToeCube.zip I have the parameters for the location of Panda3D hardcoded into the Project Settings (C/C++ > General, Linker > General & Input, and Tools > Options > Projects & Solutions > VC++ Directories)

I don’t have a Windows machine handy, sorry, but if you give me a few days I can look into it eventually. I assure you it’s there somewhere, though.

David

Thanks, I’ll keep trying different things too.

Well, I am able to reproduce the problem with your project file–it crashes for me too-but I can’t find anything wrong with the project settings. Quite vexing.

Maybe this thread has some good advice for you?

David