Skip to main content
gamedev.net
🔒 Locked

Strange error

Started by clrscr May 26, 2002 at 2:37 PM 1 replies 150+ views
Original Post
clrscr
clrscr
I''m haveing the strangest error, here it is: Run-Time Check Failure #3 - The variable ''b'' is being used without being defined. And here the offending code
void modelcalcnorm(float *p1, float *p2, float *p3)
{
	float a[3];
	float b[3];
	float result[3];
	float length;
	a[0] = p1[0] - p2[0];
	a[1] = p1[1] - p2[1];
	a[2] = p1[2] - p2[2];

	b[0] = p1[0] - p3[0];
	b[0] = p1[0] - p3[1];
	b[0] = p1[0] - p3[2];

	result[0] = a[1] * b[2] - b[1] * a[2];
	result[1] = b[0] * a[2] - a[0] * b[2];
	result[2] = a[0] * b[1] - b[0] * a[1];

	length = (float)sqrt(result[0]*result[0]+result[1]*result[1]+result[2]*result[2]);
	glNormal3f(result[0]/length,result[1]/length,result[2]/length);
}
 
Now I dont understand how i can use a varible when its not defined, wouldnt that be a compile time error, and also, the varible is clearly defined. I''m at a lost. "The most likely way for the world to be destroyed, most experts agree, is by accident. That''s where we come in; we''re computer professionals. We cause accidents." -Nathaniel Borenstein
-----------------------------When men speak of the future, the Gods laugh.An apology for the devil: it must be remembered that we have heard one side of the case. God has written all the books.Samuel Butler (1835 - 1902)
Alimonster
Alimonster
You have 3 "b[0] = ..." lines - a typo?
clrscr
clrscr
yes, jeezs, I''ve been coding to long, cant be beleve I missed that,thanks alot

"The most likely way for the world to be destroyed, most experts agree, is by accident. That''s where we come in; we''re computer professionals. We cause accidents."
-Nathaniel Borenstein
-----------------------------When men speak of the future, the Gods laugh.An apology for the devil: it must be remembered that we have heard one side of the case. God has written all the books.Samuel Butler (1835 - 1902)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.