Home General Chat
If you need urgent support, call 999 or go to your nearest A&E. To contact our Crisis Messenger (open 24/7) text THEMIX to 85258.
Options

OpenGL and C programming problem

Former MemberFormer Member Posts: 1,876,323 The Mix Honorary Guru
I know this is pretty geeky and prolly not likely to be resloved here ... but
I am progamming in opengl and reading co-ordinates from a file for triangles.

x[0] y[0] z[0] x[1] y[1] z[1] x[2] y[2] z[2]

the co-ordinates are positive and neagive floats.

I use

fscanf(pFile,"%f %f %f %f %f %f %f %f %f",&x[0],&y[0],&z[0],&x[1],&y[1],&z[1],&x[2],&y[2],&z[2]);

to read in the co-ordinates but when I printf the same variables the first two arent whats in the file.

The first line in the file is
0.882353 0.000000 2.088235 1.952941 -0.000000 1.795588 1.700000 0.000000 0.839706
but the program outputs
0.000000 0.839706 2.088235 1.952941 0.000000 1.795588 1.700000 0.000000 0.839706

(you should notice the x[0] = y[2] and y[0] = z[2])
This obviously plays havoc with my models! Could anyone help me out?

Comments

  • Options
    Former MemberFormer Member Posts: 1,876,323 The Mix Honorary Guru
    You'll get your answer here.

    www.codingforums.com
  • Options
    Former MemberFormer Member Posts: 1,876,323 The Mix Honorary Guru
    I know no one prolly cares but it was my declaration of the array. I forgot the declaration does not include 0 but the actual array starts from 0-(Number declared -1 )
Sign In or Register to comment.