Opengl Polygonoffset

http://www.zeuscmd.com/tutorials/opengl/15-PolygonOffset.php

Introduction

Polygon Offset It is often quite useful to accentuate the edges of your objects by rendering your object once in fill mode and once in line mode. This often produces unsatisfactory results as the line may move into and out of the polygon. This effect is commonly known as stitching.

You may have also noticed in the past that when rendering two polygons that overlap each other, Z-fighting occurs and parts of each polygon are rendered.

The results of stitching and z-fighting can be seen in the figures below.

Stitching Effect Stitching Effect Stitching Effect Z-Fighting Effect

This tutorial expands on tutorial 13 and shows how you can overcome these effects by making use of polygon offsets.

-------------------------------------------------------------------my code:

if(this->glpickobj.pickFlag == 1)//pick face

{

glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_LIGHTING_BIT | GL_DEPTH_BUFFER_BIT );

glEnable(GL_POLYGON_OFFSET_FILL);

glDisable(GL_LIGHTING);

glDisable(GL_TEXTURE_2D);

//glEnable(GL_BLEND);

glDepthMask(GL_FALSE);

// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ;

glColor4f(1.0f,0.0,0.0,.3f);

//from http://www.zeuscmd.com/tutorials/opengl/15-PolygonOffset.php

//key!, A positive offset will push the object away from you whereas a negative offset will pull the //object towards you.

//when glPolygonOffset(1.0, 1); unseen selected red face!!!!

glPolygonOffset(-1.0, -1);

glPushMatrix();

for(int j=0;j<this->glpickobj.facePt.size();++j)

{

Facet * fpt = this->glpickobj.facePt[j];

HF_circulator h = fpt->facet_begin();

glBegin(GL_POLYGON);

do{

// glColor3f(color[0],color[1],color[2]);

Point& temp = h->vertex()->point();

glVertex3f(temp.x(),temp.y(),temp.z());

}

while(++h != fpt->facet_begin());

glEnd();

}

glPopMatrix();

glPopAttrib();

}//pick face

转载于:https://www.cnblogs.com/europelee/archive/2010/02/17/3388671.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值