讀入3D模型
#include <GL/glut.h>
#include "glm.h"
#include "glm.h"
GLMmodel* myrobot;
void init(){
myrobot = glmReadOBJ("al.obj");
glmUnitize(myrobot);
glmFacetNormals(myrobot);
glmVertexNormals(myrobot, 90.0);
glmUnitize(myrobot);
glmFacetNormals(myrobot);
glmVertexNormals(myrobot, 90.0);
}
void mydisplay(void){
GLfloat light_pos[] = { 3.0, 0.0, -4.0, 0.0 };
void mydisplay(void){
GLfloat light_pos[] = { 3.0, 0.0, -4.0, 0.0 };
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLightfv(GL_LIGHT0, GL_POSITION, light_pos);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glmDraw(myrobot,GLM_SMOOTH | GLM_MATERIAL);
glDisable(GL_LIGHTING);
glDisable(GL_LIGHTING);
glFlush();
}
}
int main(int argc, char** argv){
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH);
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH);
glutCreateWindow("simple");
init();
glutDisplayFunc(mydisplay);
glutMainLoop();
}
init();
glutDisplayFunc(mydisplay);
glutMainLoop();
}
沒有留言:
張貼留言