在meshLab的3D场景中绘制2D透明信息面板

具体的方法是将投影方式切换为平行投影,然后进行2D绘制,最后将其映射到二维屏幕之上。

注:2D透明场景信息面板即为下图3D绘图区下方紫色透明区域

核心代码如下:

void GLArea::displayInfo()
{
	// Enter in 2D screen Mode again
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	glOrtho(-1,1,-1,1,-1,1);
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();
	glPushAttrib(GL_ENABLE_BIT);
	glDisable(GL_DEPTH_TEST);
	glDisable(GL_LIGHTING);
	glDisable(GL_TEXTURE_2D);
	glEnable(GL_BLEND);

	glBlendFunc(GL_ONE,GL_SRC_ALPHA);
        // set display info pane color
    	glColor(logAreaColor);

        //  barHeight is the height of pane
	glBegin(GL_QUADS);
    glVertex2f(-1.f,barHeight);     glVertex2f(-1.f,-1.f);
    glVertex2f( 1.f,-1.f);          glVertex2f( 1.f,barHeight);
	glEnd();
        // Render text is dismiss

	// Closing 2D
	glPopAttrib();
	glPopMatrix(); // restore modelview
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);

}
----------------

希望对你有用!  Good Luck.

原文地址:https://www.cnblogs.com/kekec/p/2092623.html