void baiscobj::ShowTree(float x,float z,float h,float s,int cactus)//树
{ glEnable(GL_BLEND); // 开启混合
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_ALPHA_TEST); // 开启ALPHA测试
glAlphaFunc(GL_GREATER, 0); // 片断的ALPHA大于0时,才会被绘制
float mat[16];// get the modelview matrix
glGetFloatv(GL_MODELVIEW_MATRIX, mat); // 得到这个,主要是想用公告板技术来使树总是面向正面
vector3_t X(mat[0], mat[4], mat[8]);// get the right and up vectors
vector3_t Z(mat[1], mat[5], mat[9]);
glBindTexture(GL_TEXTURE_2D, g_cactus[cactus]);
vector3_t pos(x,0.0,-z);
pos.y = GetHeight(x, -z) + h + s;
glBegin(GL_QUADS);
glTexCoord2f(0.0,0.0);glVertex3fv((pos+(X+Z)*-h).v);//左下点
glTexCoord2f(1.0,0.0);glVertex3fv((pos+(X-Z)* h).v);//右下点
glTexCoord2f(1.0,1.0);glVertex3fv((pos+(X+Z)* h).v);//右上点
glTexCoord2f(0.0,1.0);glVertex3fv((pos+(Z-X)* h).v);//左上点
glEnd();
glDisable(GL_ALPHA);
glDisable(GL_BLEND);
}这是整个函数