c++ - Text Clipping with Qt OpenGL -
i'm working qt5.1 , trying draw opengl stuff within qglwidget:
void widget::paintgl() { startclipping(10, height()-110,100,100); qglcolor(qt::red); glbegin(gl_quads); glvertex2d(0,0); glvertex2d(500,0); glvertex2d(500,500); glvertex2d(0,500); glend(); qglcolor(qt::green); this->rendertext(50, 50, "scissor test string"); endclipping(); } the quad gets clipped correctly text doesn't. tried 3 ways of implementing startclipping method: scissor test, setting viewport clipping area , stencil buffer. none of them worked , whole string drawn instead of beeing cut off @ edges of clipping area.
now question is: behavior bug of qt or there something, missed or possibility try??
after week of trying around, found simple way achieve, looking for. using qpainter , it's methods instead of qglwidget's rendertext() makes text clipping work:
qpainter *painter = new qpainter(); painter->begin(); painter->setclipping(true); painter->setclippath(...); // or painter->setcliprect(...); // or painter->setclipregion(...); painter->drawtext(...); painter->end();
Comments
Post a Comment