2012年7月7日 星期六

opengl(3)


GL_REPLACE(使用测试条件中的设定值来代替当前模板值),
GL_INCR(增加1,但如果已经是最大值,则保持不变),
GL_INCR_WRAP(增加1,但如果已经是最大值,则从零重新开始),
GL_DECR(减少1,但如果已经是零,则保持不变),
GL_DECR_WRAP(减少1,但如果已经是零,则重新设置为最大值),
GL_INVERT(按位取反)。



// All drawing commands fail the stencil test, and are not
// drawn, but increment the value in the stencil buffer. 
//這個例子中,在畫的時候才會去比較stencil buffer,才會增加
glStencilFunc(GL_NEVER, 0x0, 0x0);
glStencilOp(GL_INCR, GL_INCR, GL_INCR);



// Spiral pattern will create stencil pattern 
// Draw the spiral pattern with white lines. We 
// make the lines white to demonstrate that the
// stencil function prevents them from being drawn
glColor3f(1.0f, 1.0f, 1.0f); 
glBegin(GL_LINE_STRIP);
for(dAngle = 0; dAngle < 400.0; dAngle += 0.1){
glVertex2d(dRadius * cos(dAngle), dRadius * sin(dAngle)); 
//畫的時候比較stencil buffer,依上面所設always fail加一,所以最後變成所有畫線的部份是一
dRadius *= 1.002;
}

glEnd();





沒有留言:

張貼留言