Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / A buffer overrun has occurred

Author
Message
manu
16
Years of Service
User Offline
Joined: 7th Jun 2008
Location:
Posted: 14th Jun 2008 17:41
This code

works, but gives me:

\"A buffer overrun has occurred in 3D Objects.exe which has corrupted the program\'s internal state.\"

on exit. Could someone enlighten me please?
tobi453
19
Years of Service
User Offline
Joined: 28th Apr 2005
Location:
Posted: 14th Jun 2008 17:57
Quote: "float fCameraPosX = dbCameraPositionX (1);"


Are you sure you created a second camera?

FINAL VERSION RELEASED!!!!
manu
16
Years of Service
User Offline
Joined: 7th Jun 2008
Location:
Posted: 14th Jun 2008 18:01
not at all. I never created any camera. But it works that way. Changed it to 0, still working but still with buffer overrun on exit.
tobi453
19
Years of Service
User Offline
Joined: 28th Apr 2005
Location:
Posted: 14th Jun 2008 18:05
Try to replace this
Quote: "sprintf(buffer, \"x:%f, y:%f, z:%f\",fCameraPosX,fCameraPosY,fCameraPosZ);"

by this:
Quote: "sprintf(buffer, "x:%f, y:%f, z:%f",fCameraPosX,fCameraPosY,fCameraPosZ);"


FINAL VERSION RELEASED!!!!
manu
16
Years of Service
User Offline
Joined: 7th Jun 2008
Location:
Posted: 14th Jun 2008 18:46
oh i dont know where those backslashes come from. Must be copy paste...
I dont have these.
I think it got something to do with the
char buffer[800]
tobi453
19
Years of Service
User Offline
Joined: 28th Apr 2005
Location:
Posted: 14th Jun 2008 19:26
Could you post the whole source code?

FINAL VERSION RELEASED!!!!
manu
16
Years of Service
User Offline
Joined: 7th Jun 2008
Location:
Posted: 14th Jun 2008 22:28 Edited at: 14th Jun 2008 22:36
It is just a modified tutorial: "3D Objects" with a different model and the code I showed before.



And it is definitely the "buffer". When I comment the 3 occurrences out I dont get the overflow.
The strange thing is, that I get it on exit. Not when I write in the buffer.
tobi453
19
Years of Service
User Offline
Joined: 28th Apr 2005
Location:
Posted: 14th Jun 2008 22:45
I tested your code with dgdk objects (boxes) and discovered no problems.

I think it is a problem with your models.

FINAL VERSION RELEASED!!!!
manu
16
Years of Service
User Offline
Joined: 7th Jun 2008
Location:
Posted: 14th Jun 2008 22:52 Edited at: 14th Jun 2008 23:00
??????? when I use the provided Colonel-X.X model I get no error. But when I use my model and comment out the buffer:


I get no error either? I dont get it.


Edit: you where right it was my model. I had exported it from blender with lights and it didnt show up. Without light it loads and I dont get the buffer overrun. But I hope you see that nothing pointed to that. Why does this manifest only when I try to print the camera position on screen? Makes no sense to me.
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 16th Jun 2008 03:13 Edited at: 16th Jun 2008 03:18
It is likely a case of your camera position having a float value that is illegal (NaN). Certainly, it cannot be the size of the buffer...800 bytes is enormous for string purposes used to output text.

There is a safe alternative to sprintf....sprintf_s in this case. The only difference is that it takes a paramter that is the size of the buffer:
sprintf_s(buffer, 800, "x:%i, y:%i, z:%i",fCameraPosX,fCameraPosY,fCameraPosZ);

Probably it is better to only ask for camera positions for actual cameras that have been created and positioned by your code. (You get camera 0 by default, but...you should position it yourself before called a function to get the position, perhaps.

From Microsoft:
manu
16
Years of Service
User Offline
Joined: 7th Jun 2008
Location:
Posted: 16th Jun 2008 14:13
jinzai,
dbPositionCamera ( 0, 50, -80 );
was allready in the code...

Login to post a reply

Server time is: 2024-11-20 13:41:25
Your offset time is: 2024-11-20 13:41:25