Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / General Programming / My Code Crases Without A ** MessageBox() ** using Dev c++ & OpenGL Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
maxam

March 12, 2005, 10:46 PM

I am coding my own 3d engine and have reached loading 3ds models with textures, cameras, lights blah blah blah. After many trials and errors I finally have a working loader, almost. I get to taking out all the debug stuff and come across a issue in the vertex loader.

void MLoader::ReadVertices(tChunk *pPreviousChunk)
{
fread(&l_qty, sizeof (unsigned short), 1, m_FilePointer);
tempo->nov = l_qty;
tempo->v = new vertex[l_qty];

//MessageBox(NULL, "Loaded", "Notice",MB_OK);

for (int i=0;i < l_qty;i++)
{
fread(&tempo->v.obj.x, 1, sizeof(float), m_FilePointer); fread(&tempo->v.obj.z, 1, sizeof(float), m_FilePointer); fread(&tempo->v.obj.y, 1, sizeof(float), m_FilePointer); } pPreviousChunk->bytesRead += pPreviousChunk->length; } That message box you see is the only thing separating me from a fully working 0.01 and it is frustrating me. when its commented out my engine crashes and when its left in every things ok, a message box pops up and then scene appears, now i cant leave it in because it would do that to every object loaded. I am using dev c++ (latest version, i think) and opengl libraries any help would be appreciated. Blue3D 0.01 ------> http://www.geocities.com/maxamfate/v0.01.zip

 
juhnu

March 13, 2005, 01:43 AM

did you try to debug? debugger would tell you where the application crashed and probably the reason for it too. a good error handling (checking if fread() really is succesful) wouldn't hurt either..


juhani

 
Victor Widell

March 13, 2005, 10:17 AM

Something similar happened to me. A memset on the allocated array helped me...

 
maxam

March 13, 2005, 01:49 PM

Thanks to you both. I used the debugger which was helpfull to lead me to a array allocated for faces. A memset here and there and my engine loads without problems. This has been a huge help.

 
Erik Faye-Lund

March 18, 2005, 12:33 AM

well, the bug is still there, you just found a work-around. memsetting an array that is instantly overwritten shouldn't make any difference. this smell of stack corruption or some array overwrites, potentially in the previous called function. the bug will most likely come back and punch you in the face sooner or later; most likely at the worst timing possible ;)

dig up your debugger, add plenty of _CrtCheckMemory() calls etc, and kill the bug once and for all.

 
This thread contains 5 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.