• Create Account

## Bubblegum Engine error

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

16 replies to this topic

### #1Cskiwi  Members

100
Like
0Likes
Like

Posted 21 December 2011 - 05:50 PM

Hi,

i recently started to build an engine in order to learn more how i should program a game(engine) next year when I need to make a game for school.
now I only have had lessons in basic C++ with an 2D engine from school, which I can use as reference for making this one,
and had like 2 lessons in the win32 environment the rest of the time i was just messing around with it.

now it's just a basic Direct2D engine, but the plans are there for switching to Dx when I get this one up and running.
so if there is stuff not very clear why I did it, feel free to say it that I can look in to it, and if needed

## First Problem [SOLVED]

Spoiler

Greetings Glenn.

#### Attached Files

"We tend to forget that happiness doesn't come as a result of getting something we don't have, but rather of recognizing and appreciating what we do have"

### #2SiCrane  Moderators

11523
Like
0Likes
Like

Posted 21 December 2011 - 06:16 PM

It would probably help if you mentioned what error you are getting.

### #3Cskiwi  Members

100
Like
0Likes
Like

Posted 21 December 2011 - 06:19 PM

It would probably help if you mentioned what error you are getting.

^^ Forgot that one xD
added tot the main question, thanks for telling me.

"We tend to forget that happiness doesn't come as a result of getting something we don't have, but rather of recognizing and appreciating what we do have"

### #4SiCrane  Moderators

11523
Like
1Likes
Like

Posted 21 December 2011 - 06:21 PM

The linker can't find definitions for your AGame constructor and destructor. It looks like you didn't give them function bodies.

### #5Cskiwi  Members

100
Like
0Likes
Like

Posted 21 December 2011 - 06:26 PM

Wel that was easy fixed
Thanks!

"We tend to forget that happiness doesn't come as a result of getting something we don't have, but rather of recognizing and appreciating what we do have"

### #6Cskiwi  Members

100
Like
0Likes
Like

Posted 22 December 2011 - 05:21 AM

having next problem when i close my window:
Unhandled exception at 0x00ce1968 in Bubblegum.exe: 0xC0000005: Access violation reading location 0xfeeefeee.
break goes to the following code:
MainEngine::~MainEngine(){
if (m_AbstractGamePtr != NULL){
delete m_AbstractGamePtr; // here goes the break to
m_AbstractGamePtr = NULL;
}
}

Full code:
Spoiler

All other code can be found in first topic

"We tend to forget that happiness doesn't come as a result of getting something we don't have, but rather of recognizing and appreciating what we do have"

### #7L. Spiro  Members

24826
Like
-1Likes
Like

Posted 22 December 2011 - 05:41 AM

You have not initialized some variable or another, and it was initialized by the debug-mode compiler to 0xFEEEFEEE. Following your failure to initialize it, you then read from it.

If the debugger says it is m_AbstractGamePtr, then you never set m_AbstractGamePtr to NULL.
If your constructor has “m_AbstractGamePtr(0)” (which should be NULL instead of 0 for clarity) then the only logical conclusion is that:
#1: Your constructor is never called.
#2: At some point you assign 0xFEEEFEEE to m_AbstractGamePtr after it was originally assigned NULL. In a call to SetGame() no doubt.

If m_AbstractGamePtr points to memory it did not allocate, it should not be responsible for the deletion of that memory.

L. Spiro

### #8Cskiwi  Members

100
Like
0Likes
Like

Posted 22 December 2011 - 05:48 AM

You have not initialized some variable or another, and it was initialized by the debug-mode compiler to 0xFEEEFEEE. Following your failure to initialize it, you then read from it.

If the debugger says it is m_AbstractGamePtr, then you never set m_AbstractGamePtr to NULL.
If your constructor has “m_AbstractGamePtr(0)” (which should be NULL instead of 0 for clarity) then the only logical conclusion is that:
#1: Your constructor is never called.
#2: At some point you assign 0xFEEEFEEE to m_AbstractGamePtr after it was originally assigned NULL.

L. Spiro

Ok, I checked your both points, the constructor is triggerd in GameWinMain.cpp
so it should excists
and I searched my hole project for another SetGame() and none found.

and m_abstractGamePtr is still an empty class. just added some functions, but that's it

"We tend to forget that happiness doesn't come as a result of getting something we don't have, but rather of recognizing and appreciating what we do have"

### #9L. Spiro  Members

24826
Like
0Likes
Like

Posted 22 December 2011 - 06:01 AM

The point is, what value is being given to SetGame()?

L. Spiro

### #10Cskiwi  Members

100
Like
0Likes
Like

Posted 22 December 2011 - 06:03 AM

The point is, what value is being given to SetGame()?

L. Spiro

MainEngine engine;
AGame *gamePtr = new FirstGame();

engine.SetGame(gamePtr);
if (SUCCEEDED(engine.Initialize()))
{
engine.ProgramLoop();
}
delete gamePtr;

"We tend to forget that happiness doesn't come as a result of getting something we don't have, but rather of recognizing and appreciating what we do have"

### #11turbello  Members

115
Like
0Likes
Like

Posted 22 December 2011 - 06:16 AM

Something is not going to work.

Your Initialize() method is returning an integer. 'SUCCEEDED' don't check that.
You can do this:
if( engine.Initialize() ) // this automatically gives a 0 == true
{
engine.ProgramLoop();
}
Or you can do this:
HRESULT Initialize()
{
HRESULT hr;

// Initialize the engine

return hr;
}

### #12Cskiwi  Members

100
Like
0Likes
Like

Posted 22 December 2011 - 06:31 AM

Something is not going to work.

Your Initialize() method is returning an integer. 'SUCCEEDED' don't check that.
You can do this:

if( engine.Initialize() ) // this automatically gives a 0 == true
{
engine.ProgramLoop();
}
Or you can do this:
HRESULT Initialize()
{
HRESULT hr;

// Initialize the engine

return hr;
}

Got some questions with that.
as you could see i did try { } catch { }
so if it wasn't succesfull it would go to quitwithError(), witch will exit the programm, so if it returns a value it must be a succsessfull creation.

and I tried adding the HRESULT, but it say's that is wasn't initialized
But i wouldn't know what value to put in the hr.

"We tend to forget that happiness doesn't come as a result of getting something we don't have, but rather of recognizing and appreciating what we do have"

### #13turbello  Members

115
Like
1Likes
Like

Posted 22 December 2011 - 06:47 AM

If you use try - catch and exit when it fails, you don't need to return anything. You don't need to check if the initialization was succeeded because if it wasn't you would already have exited the application.

If you want to keep that try - catch, don't return anything because the return is useless.

If you want to use the HRESULT, here is an example of using it:

HRESULT hr;
hr = RegisterClass( &wndClass );  // this should work <img src='http://public.gamedev.net/public/style_emoticons/<#EMO_DIR#>/tongue.gif' class='bbc_emoticon' alt=':P' />
return hr;
The value that will be put into hr depends: HRESULT values

### #14Cskiwi  Members

100
Like
0Likes
Like

Posted 22 December 2011 - 06:53 AM

If you use try - catch and exit when it fails, you don't need to return anything. You don't need to check if the initialization was succeeded because if it wasn't you would already have exited the application.

If you want to keep that try - catch, don't return anything because the return is useless.

If you want to use the HRESULT, here is an example of using it:

HRESULT hr;
hr = RegisterClass( &wndClass );  // this should work <img src='http://public.gamedev.net/public/style_emoticons/<#EMO_DIR#>/tongue.gif' class='bbc_emoticon' alt=':P' />
return hr;
The value that will be put into hr depends: HRESULT values

Thanks,
but i still have my error: here

"We tend to forget that happiness doesn't come as a result of getting something we don't have, but rather of recognizing and appreciating what we do have"

### #15Jansic  Members

251
Like
1Likes
Like

Posted 22 December 2011 - 06:56 AM

0xFEEEFEEE is the fill MSVC uses when something is freed. i.e. it's trying to delete something that has already been deleted.

A quick glance at the code shows the AGame pointer is deleted both outside the class (in main) and in the destructor for the MainEngine class - which is probably the issue...

Jans.

### #16turbello  Members

115
Like
1Likes
Like

Posted 22 December 2011 - 06:57 AM

I can see you are deleting the object in the destructor of the MainEngine. And thereafter you delete the same object again at the end of the WinMain..

### #17Cskiwi  Members

100
Like
0Likes
Like

Posted 22 December 2011 - 06:58 AM

0xFEEEFEEE is the fill MSVC uses when something is freed. i.e. it's trying to delete something that has already been deleted.

A quick glance at the code shows the AGame pointer is deleted both outside the class (in main) and in the destructor for the MainEngine class - which is probably the issue...

Jans.

Hmm now you say it, the m_abstractGamePtr is just a pointer not a new object, so I didn't have to delete it, thx!

"We tend to forget that happiness doesn't come as a result of getting something we don't have, but rather of recognizing and appreciating what we do have"

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.