View Single Post
Posts: 252 | Thanked: 252 times | Joined on Nov 2009
#3
Originally Posted by viraptor View Post
It would be a big bug in libc if that really happened without any problems in the source code. Most probably, it's just a bad code. Do you have a small example of the fscanf call and a file on which it fails?
I was thinking it could have something to do with floating points on the N900, but I don't if that's an issue at all?

The relevant part of the code which does the reading is this:

Code:
while(fscanf(file, "%s", buf) != EOF) {
        switch(buf[0]) {
        case '#':				/* comment */
            /* eat up rest of line */
            fgets(buf, sizeof(buf), file);
            break;
        case 'v':				/* v, vn, vt */
            switch(buf[1]) {
            case '\0':			/* vertex */
                fscanf(file, "%f %f %f",
                       &vertices[3 * numvertices + X],
                       &vertices[3 * numvertices + Y],
                       &vertices[3 * numvertices + Z]);
                numvertices++;
                break;
// ...
And the file looks somewhat like this (with a bunch of more values):
Code:
v 0.956776 2.407918 1.846345
v -1.020031 2.407918 1.846345
v 1.097976 2.223070 1.697290
v -1.161232 2.223070 1.697290
v 1.203877 2.096724 1.467326
v -1.267132 2.096724 1.467326
v 0.762625 1.936465 1.582468
v -0.825880 1.936465 1.582468
v 0.762625 2.094863 1.789404
v -0.825880 2.094863 1.789404
v 0.762625 2.343815 1.892402
v -0.825880 2.343815 1.892402
v 0.586125 2.419122 1.916050
v -0.649380 2.419122 1.916050
v 0.427274 2.242678 1.819275
v -0.490529 2.242678 1.819275
The source code I'm using is this:

http://www.cs.jhu.edu/~subodh/457/code/gltutor/glm.h
http://www.cs.jhu.edu/~subodh/457/code/gltutor/glm.c

In addition I'm printing the values to the console using this loop:

Code:
    for(int i = 0; i < numvertices; i++) {
        qDebug() << "out" << vertices[i];
    }
As mentioned, all values are kept as in the file when running the application on my desktop, but not on my N900.