PDA

View Full Version : GLM beginning



Abhijith
09-07-2008, 03:12 PM
Hi..I am new to opengl and glut..

below is the piece of code to import and display an object titled f-16.obj...the code compiles and an empty window appears but the object doesnot load.Can u tell me what i am doing wrong.

Thanks..



int
main(int argc, char** argv)
{
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
GLMmodel* pmodel = NULL;
int models;

glutInitWindowSize(600, 600);
glutInit(&argc, argv);

glutCreateWindow("TeSt");
//glutReshapeFunc(reshape);
//glutDisplayFunc(display);
//printf("Here i Am!!!");
pmodel = glmReadOBJ("f-16.obj");
//if (!pmodel) exit(0);
glmUnitize(pmodel);
glmFacetNormals(pmodel);
glmVertexNormals(pmodel, 90.0);


glmDraw(pmodel, GLM_SMOOTH | GLM_MATERIAL);
glutMainLoop();
}

trinitrotoluene
09-08-2008, 08:44 PM
My guess is that your camera is not set to be able to view the model. What is the parameter of gluPerspective or glFrustum you give. Take care of znear and zfar. Do you use gluLookAt? Blank screen happen often when these parameter are incorrect.

Try to draw a simple geometry like a triangle around the origin and adjust your projection matrix and modelview matrix to be able to see it.

I don't use glut but to be able to view something you should at least use

glViewport and (gluPerspective or glFrustum or glOrtho, etc)
for setting the projection matrix

gluLookAt or (glTranslate,glRotate) to modify the modelview matrix but these are not obligatory.

Try to find tutorial for learning how to set the projection and the modelview matrix correctly.

hope it help.