c. I have a question to read the language notebook data

Asked 2 years ago, Updated 2 years ago, 104 views

I'm asking you a question because there's something I'm not familiar with while reading the data in the notepad. In the notepad, the number of vertices and (x,y,z) coordinates of vertices, the number of faces and the number of vertices of that face?They are saved. In the picture above, 10113 is the number of vertices and the real numbers below are the coordinates of vertices. In addition, in the picture starting from 20222, 2022 is the number of noodles, and the number below it is the number of vertices.

What I'm going to do is openGL takes in the information that's stored in this notebook and reads it, puts it into the three-dimensional sphere-making source that I've written, and transforms it into something like an object. From the results of the execution, it seems that it appears up to the collarbone below the head and neck of a person.

So we first used the file input/output function to read the coordinates of the vertices in this notebook.

void main(int argc, char** argv)
{
    double *fv;
    int numOfVertex;

    int i;
    FILE *f;

    f = fopen("head_new.txt", "r"); // Open Stream
    fscanf(f, "%d \n", &numOfVertex); // Read the number of vertices
    fv = (double*)malloc(sizeof(double)*numOfVertex); // Assign as dynamic as number of vertices 10113

    For (i = 0; i<numOfVertex; i++) // Read coordinates of vertices
        fscanf(f, "%lf", &fv[i]);

    fclose(f); // Close stream

    printf("%d \n", numOfVertex); // Number of vertices output
    for (i = 0; i < numOfVertex; i+=3) // vertex output
    {
        printf("%-20lf", fv[i]);
        printf("%-20lf", fv[i + 1]);
        printf("%-20lf \n", fv[i + 2]);
    }

}

Source read to the apex of the source above. I haven't got the noodles and numbers yet

But when you do it, you have a problem. If you read all the data after the output goes down, The console window automatically turns off. I don't even have time to make sure the data is read properly.

If you click the console window with your mouse while you're running it and reading the data, it stops reading the data. Of course, we didn't read all the data, but we can see that it was successful.

When you print it out from a normal c code, the phrase "Press any key to exit" is usually printed at the end, but this is just reading the data without doing so and then it ends on its own.To check whether the data was read through or read properly, the data should be read through and the console window should remain intact, but it's embarrassing that the pick is turned off.

I don't know what the problem is. It's not a big deal, but I'd appreciate your help

c opengl

2022-09-22 19:02

1 Answers

I think you're using a visual studio

https://blog.bsk.im/2013/10/24/visual-studio-console-remained/

Or

http://marinelifeirony.tistory.com/62

Please refer to it~

There seems to be nothing wrong with the code.


2022-09-22 19:02

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.