Archived

This topic is now archived and is closed to further replies.

Dark_Streak

Wierdest thing I've ever, ever, ever seen.

Recommended Posts

Dark_Streak    122
Ok, I will come straight out with it and admit that, yes, I am a beginner OpenGL programmer. So the reason behind my problem will naturally be something stupidly blatantly obvious, so please but my out my misery and tell me what I'm doing wrong. I am getting the strangest results ever, check this out: I am drawing a triangle from these vertices - CVector3 trivertices[3] = {CVector3(-4.0f,2,0.8),CVector3(4,0,0.8),CVector3(-4.0f,0,0.8)}; The triangle is drawn incorrectly. It ignores the x vertice, in other words if I change the x vertice values, the triangle's x vertice is still drawn in the same wrong place. Okay, now heres the wierd part. If I define a variable called test in front of the above line of code, my triangle, using the trivertices variable is drawn correctly!!!!! So my code will look something like this: CVector3 test[3] = {CVector3(0,0,0),CVector3(0,0,0),CVector3(0,0,0)}; CVector3 trivertices[3] = {CVector3(-4.0f,2,0.8),CVector3(4,0,0.8),CVector3(-4.0f,0,0.8)}; And get this, if I change the name of the test variable to something else, it doesnt work! Yes, thats right, if I call it Bob or something, my triangle is drawn wrong. So I change the name back to 'test', and it works!!!! AAAAAGH WHAT THE F***?!?!?!?!?!?! How, why is this happening?? It makes absolutely no sense. What the hell is going on? Do you realise how long it took me to work out that naming a variable 'test' would have an affect on something not even related. I am having a break down please help Im sorry, should I have posted this in the beginners section? I only posted it here in opengl because It's such a wierd problem I thought it may be opengl specific. If any one does know whats going on with this wierd test variable, please please reply. [edited by - Dark_Streak on May 2, 2002 8:03:02 PM]

Share this post


Link to post
Share on other sites
zedzeek    528
sounds very much like a bogus memory problem
can u post the whole (compilable) code (if its not to long)

http://uk.geocities.com/sloppyturds/gotterdammerung.html

Share this post


Link to post
Share on other sites
Dwarf with Axe    277
Well the same thing happened to me; But it was when I replaced the text in a comment field (even weirder!)


What I did was delete the .obj files and any other file that the compiler created and then rebuilt the whole thing.


~Dwarf

Share this post


Link to post
Share on other sites
DC_Tsunami    122
Out of curiosity, what compiler do you use? I use BCC55 and it gives me problems like that sometimes. A couple times I''ve been able to avert a bogus crash by adding some code to write out to a file (?). It also occasionally picks up STL errors when I don''t use STL, but just trying it again usually fixes this.

My advice to you is after you''ve done those assignments, do write to a file or something to see what the values in them actually are. This will let you know if your constructors are storing the values wrong or whatever. You might also try breaking the declaration into a bunch of different lines, comment them, and uncomment one at a time to see where it goes awry. If that still doesn''t work, change your code and do it a different way. Failing that, get a new compiler!

Share this post


Link to post
Share on other sites
Siebharinn    122
quote:

What I did was delete the .obj files and any other file that the compiler created and then rebuilt the whole thing.



It''s a good idea to do full rebuild occasionally. I do it right before I sync back with the source control. Keeps crusty incremental linking from biting you in the butt.

Take care,
Bill

Share this post


Link to post
Share on other sites
Cold_Steel    835
I''ve had similar problems in VC++. It happened when I copy and pasted the folder a project was in. The new project didn''t work right. The debug version would crash because I was accessing an empty queue, even though I checked to see if it was empty the line before, and in the debugger, it told be it wasn''t empty! I ended up deleting the project and adding the source files to a new one. I did this immediately after the compiler told me '';'' at the end of if(1), pretty flaky if you ask me.

Share this post


Link to post
Share on other sites
zin    110
Yes I get similar bizzare behaviour on vc++, a full rebuild usually cures it, it looks like a header gets out of sync w/ a file.

Sometimes I have to delete everything in Debug & Release folder, and maybe my last exe fiel to get it to work.

zin

zintel.com - 3d graphics & more or less

Share this post


Link to post
Share on other sites