Advertisement

Strange, annoying problem!

Started by March 10, 2003 09:05 AM
10 comments, last by James Trotter 21 years, 11 months ago
There is a problem that is bothering me, and it is extremely strange! When I run my program in debug mode it works fine, and there are no errors. But if not it just returns an error after I''ve initialized the arrays I use to render vertices, and the log stops halfway through, and is not complete! here is the log, if you wish to see it: The complete log, from running in debug mode:
  
Logging system started.
Creating OpenGL Window.
	Windowclass Registered.
	Finding Suitable Pixelformat.
	Pixelformat Found.
	Pixelformat Set.
	Rendering Context Successfully Created.
	Rendering Context Successfully Activated.
Window Successfully Created!

Setting up OpenGL
	Initializing extensions
		Compiled Vertex Arrays supported.
	Extensions initialized.
	Initializing fonts.
	Loading data/tex/font.tga as a texture.
	Image successfully loaded as texture.
	Fonts initialized.
	Initializing DirectInput.
		DirectInput device created.
		Mouse device created.
		Data format set for the mouse device.
		cooperative level set for the mouse device.
		Mouse device aqcuired.
		Keyboard device created.
		Data format set for the keyboard device.
		cooperative level set for the keyboard device.
		Mouse device aqcuired.
	DirectInput initialized.
	Loading world from Data/worlds/World.txt.
	Loading Data/tex/stone.tga as a texture.
	Image successfully loaded as texture.
	Loading Data/tex/grass2.tga as a texture.
	Image successfully loaded as texture.
	Loading a Heightmap.
		Loading the HeightMap from Data/maps/map1.raw
		HeightMap loaded from file.
		Computing normals for HeightMap.
		Normals generated.
		Creating Lightmap.
		Lightmap generated.
		Rescaling normals.
		Normals were rescaled.
		Generating texture for terrain.
		scaling texture for terrain.
		terrain texture generated.
	Heightmap loaded.
	Initializing terrainpatch.
	Loading Data/tex/sky/sky.tga as a texture.
	Image successfully loaded as texture.
OpenGL initialized.

Entering main loop.
Exiting main loop.

Shutting Down...
	Device Context Successfully Released
	Window Class Unregistered.
Window Successfully Killed!

Destroying fonts.
Fonts succesfully destroyed
Shutting down DirectInput.
	Keyboard unaqcuired.
	Keyboard released.
	Mouse unaqcuired.
	Mouse released.
	DirectInput device released.
DirectInput shut down.
Log succesfully shut down.
  
And here is the incomplete log:
  

Logging system started.
Creating OpenGL Window.
	Windowclass Registered.
	Finding Suitable Pixelformat.
	Pixelformat Found.
	Pixelformat Set.
	Rendering Context Successfully Created.
	Rendering Context Successfully Activated.
Window Successfully Created!

Setting up OpenGL
	Initializing extensions
		Compiled Vertex Arrays supported.
	Extensions initialized.
	Initializing fonts.
	Loading data/tex/font.tga as a texture.
	Image successfully loaded as texture.
	Fonts initialized.
	Initializing DirectInput.
		DirectInput device created.
		Mouse device created.
		Data format set for the mouse device.
		cooperative level set for the mouse device.
		Mouse device aqcuired.
		Keyboard device created.
		Data format set for the keyboard device.
		cooperative level set for the keyboard device.
		Mouse device aqcuired.
	DirectInput initialized.
	Loading world from Data/worlds/World.txt.
	Loading Data/tex/stone.tga as a texture.
	Image successfully loaded as texture.
	Loading Data/tex/grass2.tga as a texture.
	Image successfully loaded as texture.
	Loading a Heightmap.
		Loading the HeightMap from Data/maps/map1.raw
		HeightMap loaded from file.
		Computing normals for HeightMap.
		Normals generated.
		Creating Lightmap.
		Lightmap generated.
		Rescaling normals.
		Normals were rescaled.
		Generating texture for terrain.
		scaling texture for terrain.
		terrain texture generated.
	Heightmap loaded.
	Initializing terrainpatch.
  
"Initializing terrainpatch." is where the arrays get initialized.
0. What is ''debug mode''?
1. Source please...
2. Check:
Loading Data/tex/sky/sky.tga as a texture.
3. Check for:
#ifdef _DEBUG
..
#endif
4. How do you know there was an error? Assertion? Acces violation? Errro message (your own)?



PM


times change


Excuse my poor english!
PM Times change... Excuse my poor english!
Advertisement
I''m sorry, perhaps I didn''t explain enough.
I''m using VC++ 6.0, and when I hit the F5-button it runs the program in ''debug'' mode, and I can pause the program at anytime, or single-step, etc. But when I run the .EXE, it doesn''t work properly. And I''m 100% sure that all the files are in the right folders, and things like that!

I know it''s an error because the program exits and leaves a message box saying "The program has generated errors and will be closed by Windows..."

Ok, I''m putting the entire source out on the net, so that you can look at it. Because I''m not sure what part of the code the problem is at. here is the source

Please try to run this on your machine, and tell me the results!

Oh.. btw, I checked out the part where it loads Data/tex/sky/sky.tga and, it seems if i comment out the parts where it writes to the log, it doesn''t crash there, but it crashes the next time it writes to the log! Strange...

At first I thought it might be a problem with memory, but i don''t think it is...
James,

Found the problem. The memory error is that, this line:


        char mapfile[18], texturefile[18]; // Temporary variables      



Problem is you are loading a path name of more than 18 characters for texturefile, as mapfile is exactly 18.

i.e. - mapfile: "Data/maps/map1.raw"
i.e. - texturefile: "Data/tex/grass2.tga"

Don't forget the null character for mapfile making it 19 characters long.


Changing mapfile[18] and texturefile[18] to
mapfile[50], texturefile[50] solves that problem.

I then removed the comments of your loading the sky image, (which btw you were still calling RenderSkyBox(); in your DrawGLScene function) and it worked fine up until the function call of: World.Render();


There is an issue with that, and fortunitly I can't debug your whole terrain file and fix it up for you, however good luck with fixing it up. If you need anymore help feel free to ask.


~David


Edit: Silly source tags ...

[edited by - Zern on March 10, 2003 2:19:46 PM]
Thanks, zern!! I really appreciate your help!

But those weren''t the real problems that were keeping me from executing the .exe, but I believe they might have been small issues. But can you try to run it by just pressing the F5 button in Visual Studio, to run it in debug mode to see if it runs?
Advertisement
[EDIT : Nevermind what i wrote earlier]

I found out the problem!!
One of the arrays in the TerrainPatch::init() function was to small. I feel so very, very stupid right now. =) hehe...

But it was exceedingly strange that it would be able to run in debug mode!

Anyway, I will update the source tommorow, I'm sorry I don't have time now.

[edited by - James Trotter on March 10, 2003 4:16:52 PM]
are you running your exe directly from \release\ directory ?
if you are move you exe file to same directory where you sources are...
Happy you fixed it


and yes, I was running it in Visual Studio(.net) in debug release and upon exiting that function where texturefile is declared (sorry can''t for the life of me remember and currently on a computer downstairs, source is upstairs), it would complain about the heap I believe around texturefile was corrupt (i.e. the 19 chars into the 18 char name, and upon changing it to texturefil[50] worked fine).
The new and working source is up now =), go fetch if you want to see.

This topic is closed to new replies.

Advertisement