[vtkusers] (no subject)

刘卓 polinzhuo at 163.com
Mon Dec 18 22:02:20 EST 2006


Hi all:

         I’m working for an arithmetic, in which depth buffer must be
masked and an object is rendered on stencil buffer at the same time.

I have overloaded the function vtkOpenGLActor:: Render(vtkRenderer *ren,
vtkMapper *mapper) like codes below. But after running the function, the
content of depth buffer is clear by 1(there are some values which is not 1
in depth buffer ). Why? And how to mask depth buffer correctly?

void vtkMyActor::SetDepthMask(bool bmask)

{

         this->m_bDepthMask = bmask;

}

bool vtkMyActor::GetDepthMask()

{

         return this->m_bDepthMask;

}

 

// Actual actor render method.

void vtkMyActor::Render(vtkRenderer *ren, vtkMapper *mapper)

{

//  float opacity;

//

//  // get opacity

//  opacity = this->GetProperty()->GetOpacity();

//  if (opacity == 1.0)

//    {

//    glDepthMask (GL_TRUE);

//    }

//  else

//    {

//    // add this check here for GL_SELECT mode

//    // If we are not picking, then don't write to the zbuffer

//    // because we probably haven't sorted the polygons. If we

//    // are picking, then translucency doesn't matter - we want to

//    // pick the thing closest to us.

//    GLint param[1];

//    glGetIntegerv(GL_RENDER_MODE, param);

//    if(param[0] == GL_SELECT )

//      {

//      glDepthMask(GL_TRUE);

//      }

//    else

//      {

//      glDepthMask (GL_FALSE);

//      }

//    }

         if(!m_bDepthMask)

               glDepthMask (GL_FALSE);

 

  // build transformation 

  if (!this->IsIdentity)

    {

    double *mat = this->GetMatrix()->Element[0];

    double mat2[16];

    mat2[0] = mat[0];

    mat2[1] = mat[4];

    mat2[2] = mat[8];

    mat2[3] = mat[12];

    mat2[4] = mat[1];

    mat2[5] = mat[5];

    mat2[6] = mat[9];

    mat2[7] = mat[13];

    mat2[8] = mat[2];

    mat2[9] = mat[6];

    mat2[10] = mat[10];

    mat2[11] = mat[14];

    mat2[12] = mat[3];

    mat2[13] = mat[7];

    mat2[14] = mat[11];

    mat2[15] = mat[15];

    

    // insert model transformation 

    glMatrixMode( GL_MODELVIEW );

    glPushMatrix();

    glMultMatrixd(mat2);

    }

  

  // send a render to the mapper; update pipeline

  mapper->Render(ren,this);

 

  // pop transformation matrix

  if (!this->IsIdentity)

    {

    glMatrixMode( GL_MODELVIEW );

    glPopMatrix();

    }

  

//  if (opacity != 1.0)

//    {

//    glDepthMask (GL_TRUE);

//    }

       if(!m_bDepthMask)

               glDepthMask (GL_TRUE);

 

}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20061219/fb7eb83b/attachment.htm>


More information about the vtkusers mailing list