zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    发邮件(asp.net2.0)(转)
    教师节祝福短信
    量子学习及思考13人机交互很快将面临交互模式的进化2 人工智能
    MongoDB(1) 简单配置
    CreateCompatibleDC
    设置环境变量的作用
    vs2008中调用matlab生成的dll
    resolve the maado15.dll
    错误3:系统找不到指定的路径
    C++关键字volatile
  • 原文地址:https://www.cnblogs.com/europelee/p/3388671.html
Copyright © 2011-2022 走看看