Hey,
I am trying to read in the simple cube.obj file that is all over the internet. I am getting the cube to appear on the screen in 3D, but its being painted in all white. How do I get the cube to be painted the way its supposed to be? I also tried the f-16 from nate Robbins tutorial program with the mtl file and it’s also being painted white. Just not sure how to manage this, here is the code:
#include “glut.h”
#include <stdio.h>
#include <math.h>
#include “glm.h”
GLMmodel* pmodel = NULL;
GLfloat angle1 = 0.0;
void init(void)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-1, 1, -1, 1, 1, 7);
glClearColor (0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gluLookAt(0, 3, 3,
0.0, 0.0, 0,
0.0, 1.0, 0.);
pmodel = glmReadOBJ(“cube.obj”);
glmUnitize(pmodel);
glmFacetNormals(pmodel);
glmVertexNormals(pmodel, 90);
glmDraw(pmodel, GLM_SMOOTH);
glutSwapBuffers();
}
int main(int argc, char *argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glEnable(GL_DEPTH_TEST);
glutInitWindowPosition(100,100);
glutInitWindowSize(500,500);
glutCreateWindow(“Project 2”);
glutDisplayFunc(display);
init();
glutMainLoop();
return 0; / ANSI C requires main to return int. */
}