[osg-users] how to set width and Stipple of a osgText::BoundingBox?

Lv Qing donlvqing at msn.com
Tue Oct 27 09:48:24 PDT 2015


Thx!Robert!

    The situation is,we  have modified the text.cpp to create some other styles rather than boundingbox.

    Like a BoundingLine,one end to one of the corner of a BoundingBox,the other end linked to a osg::Node.

   So if a text have a BoundingLine and a BoundingBox,I just want draw the BoundingBox as normal,but draw the BoundingLine with LineStipple .So I think one osg::StateSet may not solve this problem.

  I am not quiet  familiar with the openGL programming since I use osg at first.I search the web found people use this code to set
Linewidth and Stipple

glLineWidth (2.0); 
glLineStipple (1, 0x0F0F); 

And I look into text.cpp,found lots of code like use openGL directly,such as :

 //glClear(GL_STENCIL_BUFFER_BIT);

 // enable stencil buffer
    glEnable(GL_STENCIL_TEST);

    // write a one to the stencil buffer everywhere we are about to draw
    glStencilFunc(GL_ALWAYS, 1, 1);

    // write only to the stencil buffer if we pass the depth test
    glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);

    // Disable writing to the color buffer so we only write to the stencil 
    // buffer and the depth buffer
    glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);

    // make sure the depth buffer is enabled
//    glEnable(GL_DEPTH_TEST);
//    glDepthMask(GL_TRUE);
//    glDepthFunc(GL_LESS);

    // Arrrgh! Why does the code only seem to work correctly if I call this?
    glDepthMask(GL_FALSE);



 So I think use the openGL code to draw different style may be the qucik way.




... 

Thank you!

Cheers,
Lv

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=65462#65462








More information about the osg-users mailing list