ridiculous ptr problem
this is the code, i got it to work, but i don''t understand why i had to add extra twists:
int CalculateTriangleNormals(_EGroup*group,_ESegment*seg)
{
code here accessing seg with seg->vertexcount;
}
int UpdateTriangleDisplay(_EGroup*group,_ESegment*seg)
{
CalculateTriangleNormals(group,seg);
}
int main() //oversimplified
{
//group and seg ptrs already exist, valid
UpdateTriangleDisplay(group,seg);
}
this gives me an error because when it accesses the seg->vertexcount member it gets 4378165838 or something. however, if i use _EGroup**group in the UpdateTriDisplay function and pass *group to CalcTrinormals, it works, gives me say 2 or 3, as it should. I don''t recall this happening before, so please enlighten me, why?
Thanks in advance, Alex.
Well, how are you declaring group and seg?
int main() //oversimplified
{
//group and seg ptrs already exist, valid
UpdateTriangleDisplay(group,seg);
}
If they are pointers, then this looks fine, but if they are static variables, then you need to reference them with the & operator:
int main() //oversimplified
{
//group and seg ptrs already exist, valid
UpdateTriangleDisplay(&group,&seg);
}
Jim
int main() //oversimplified
{
//group and seg ptrs already exist, valid
UpdateTriangleDisplay(group,seg);
}
If they are pointers, then this looks fine, but if they are static variables, then you need to reference them with the & operator:
int main() //oversimplified
{
//group and seg ptrs already exist, valid
UpdateTriangleDisplay(&group,&seg);
}
Jim
Jim Adams, Author"Programming Role-Playing Games with DirectX""Advanced Animation with DirectX""Programming Role-Playing Games with DirectX, 2nd Edition"
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement