我正在尝试将森林中的一堆树木反射到附近的湖中。我按照所有标准步骤使用模板缓冲区绘制反射。但是“水”似乎不允许看到下面的物体。这是我的功能:draw_sea()
- 绘制反映的计划drawFigTree(fig_tree)
- 绘制下面的树木。问题出在哪里?
void draw_mirror()
{
glEnable(GL_STENCIL_TEST);
//glColorMask(0, 0, 0, 0);
glDisable(GL_DEPTH_TEST);
glStencilFunc(GL_ALWAYS, 1, 0xFFFFFFFF);
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
glDisable(GL_LIGHTING);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
draw_sea();
glDisable(GL_BLEND);
glEnable(GL_LIGHTING);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glEnable(GL_DEPTH_TEST);
glStencilFunc(GL_EQUAL, 1, 0xFFFFFFFF);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
glPushMatrix();
glTranslatef(0.0, SEA_LEVEL, 0.0);
glEnable(GL_CLIP_PLANE0);
glClipPlane(GL_CLIP_PLANE0, clip_plane0 );
glPopMatrix();
glPushMatrix();
glTranslatef(-25.0, 2*(-1), 0.0);
glScalef(1.0, -1.0, 1.0);
drawFigTree(fig_tree);
glPopMatrix();
glDisable(GL_CLIP_PLANE0);
glDisable(GL_STENCIL_TEST);
}