1
Does anyone know if there are any restrictions on using fscanf
in projects that use GLUT (Opengl)? I’m trying to do something simple... read a cloud of dots (x, y, z) from a text file, but the fscanf
does not get the values correctly... The same code in a console application in code::Blocks works correctly.
Does anyone have any suggestions of what they might have done wrong?
Code:
#include <windows.h>
#ifdef __APPLE__
#else
#include <GL/glut.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <conio.h>
int main()
{
int i;
int v1x;
int vetor[9]; // 3 points
FILE *occluded_triangles;
occluded_triangles = fopen("occluded_triangles.txt", "rt");
for(i = 0; i < 9; i++)
{
fscanf(occluded_triangles, "%d", &v1x);
vetor[i] = v1x;
}
for(i = 0; i < 9; i++)
{
printf("%d\n", vetor[i]);
}
system("pause");
return 0;
}
I was having a similar problem, and the problem was with the codebloks. I was passing a game I developed in conio2 for openGL, I was using the project configured to work with GLUT in codebloks, until I needed to open a file was all ok. The solution I found was to include the necessary links to use GLUT and thus work without project in codebloks, it worked. I suspected it was some m*** that I was doing, but the same code ran outside the project and did not run inside the project.
– Kauê Gomes