From 8890b59f09b084f4b6582f7d0a07e10760980d9f Mon Sep 17 00:00:00 2001 From: 0penBrain <48731257+0penBrain@users.noreply.github.com> Date: Wed, 17 Nov 2021 12:42:00 +0100 Subject: [PATCH] [Gui] Render corner cross labels as pixel maps so they are scalable --- src/Gui/View3DInventorViewer.cpp | 57 ++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 7 deletions(-) diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index bedc3c6d22..cde72dc3cb 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -3268,10 +3268,48 @@ void View3DInventorViewer::setViewing(SbBool enable) //**************************************************************************** -// Bitmap representations of an "X", a "Y" and a "Z" for the axis cross. -static GLubyte xbmp[] = { 0x11,0x11,0x0a,0x04,0x0a,0x11,0x11 }; -static GLubyte ybmp[] = { 0x04,0x04,0x04,0x04,0x0a,0x11,0x11 }; -static GLubyte zbmp[] = { 0x1f,0x10,0x08,0x04,0x02,0x01,0x1f }; +// Pixel map representations of an "X", a "Y" and a "Z" for the axis cross. +#define O {0,255} // black pixel +#define I {255,0} // transparent pixel + +static uchar xPM[9][7][2] = { + {I,I,I,I,I,I,I}, + {I,O,I,I,I,O,I}, + {I,O,I,I,I,O,I}, + {I,I,O,I,O,I,I}, + {I,I,I,O,I,I,I}, + {I,I,O,I,O,I,I}, + {I,O,I,I,I,O,I}, + {I,O,I,I,I,O,I}, + {I,I,I,I,I,I,I} +}; + +static uchar yPM[9][7][2] = { + {I,I,I,I,I,I,I}, + {I,I,I,O,I,I,I}, + {I,I,I,O,I,I,I}, + {I,I,I,O,I,I,I}, + {I,I,I,O,I,I,I}, + {I,I,O,I,O,I,I}, + {I,O,I,I,I,O,I}, + {I,O,I,I,I,O,I}, + {I,I,I,I,I,I,I} +}; + +static uchar zPM[9][7][2] = { + {I,I,I,I,I,I,I}, + {I,O,O,O,O,O,I}, + {I,O,I,I,I,I,I}, + {I,I,O,I,I,I,I}, + {I,I,I,O,I,I,I}, + {I,I,I,I,O,I,I}, + {I,I,I,I,I,O,I}, + {I,O,O,O,O,O,I}, + {I,I,I,I,I,I,I} +}; + +#undef O +#undef I void View3DInventorViewer::drawAxisCross(void) { @@ -3429,12 +3467,17 @@ void View3DInventorViewer::drawAxisCross(void) else glColor3fv(SbVec3f(0.0f, 0.0f, 0.0f).getValue()); + //glEnable(GL_ALPHA_TEST); + //glAlphaFunc(GL_GREATER, 0.5); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glPixelZoom((float)axiscrossSize/10, (float)axiscrossSize/10); glRasterPos2d(xpos[0], xpos[1]); - glBitmap(8, 7, 0, 0, 0, 0, xbmp); + glDrawPixels(7, 9, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, xPM); glRasterPos2d(ypos[0], ypos[1]); - glBitmap(8, 7, 0, 0, 0, 0, ybmp); + glDrawPixels(7, 9, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, yPM); glRasterPos2d(zpos[0], zpos[1]); - glBitmap(8, 7, 0, 0, 0, 0, zbmp); + glDrawPixels(7, 9, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, zPM); glPixelStorei(GL_UNPACK_ALIGNMENT, unpack); glPopMatrix();