Well, this is my first post in this forum and I don’t speak English very well, so I’d like to apologize for any mistake I could make.
I’m doing my first program using OpenGL with C (it may end up as a videogame, but at the moment it’s only a model loader and viewer).
The program loads a model from an .OBJ extension file, which i found the easiest for loading. The problem is that the OBJ file contains normal data, but there isn’t always a normal for each vertex neighter a normal for each polygon/face. But each face contains data about which normal that face uses, so I add that normal to each of the face vertexs, and after loading all the faces, I divide the vertex normals by the quantity that have been added. So I end up with the vertex normals (or at least that is what I think).
The problem comes when I test my program. The models loads fine, but the smooth shading is not working properly (the best example is the cube), because when i rotate the scene, the shading in the cube changes a bit, on a weird way.
Here is my source code with the compiled .exe (I’m using AllegroGL too, because in the future i will use some Allegro functions with OpenGL)
I’m sorry if the source code is not documented yet, but I didn’t have time for that.
I hope someone can tell me by the way the program looks if there is a problem with the vertex normals, or with the light.
Thank you very much, and sorry for the inconvenients.
EDIT: to move around use the arrow keys and to rotate WASD keys.