用纹理贴图模拟反射,NeHe23课球面映射相关

 开启自动纹理坐标功能 
glEnable(GL_TEXTURE_GEN_S)
glEnable(GL_TEXTURE_GEN_T)


 自动生成纹理坐标 
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP)
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP)

 gl1.1的三个GEN_MODE 
GL_SPHERE_MAP
GL_OBJECT_LINER
GL_EYE_LINER

* gl后续版本还有更多MODE 


 申请一个二次对象 
GLUquadricObj *quadratic
quadratic=gluNewQuadric();

 

 设置二次对象的法线 
gluQuadricNormals(quadratic, GLU_SMOOTH);

 

 设置二次对象纹理功能开启 
gluQuadricTexture(quadratic, GL_TRUE);

 生成具体的二次对象cylinder/sphere 
gluCylinder(quadratic, 1.0f,1.0f,3.0f,32,32)
gluSphere(quadratic,1.3f,32,32);

你可能感兴趣的:(用纹理贴图模拟反射,NeHe23课球面映射相关)