<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<font size="+1">Hey Luca,<br>
<br>
I forgot one important thing in my review:<br>
When you manipulate global OpenGL states you need to set them back
to what they were before after painting - in the
ruler-drawing-case you change the glBlendFunc, but also
glLineWidth without restoring them - drawGuides () could look
something like this (with added only on output with pointer
option):<br>
<br>
void<br>
ShowmouseScreen::drawGuides (const GLMatrix &transform)<br>
{<br>
unsigned short *color = optionGetGuideColor ();<br>
const int x = mMousePos.x ();<br>
const int y = mMousePos.y ();<br>
const float xf = (float)x;<br>
const float yf = (float)y;<br>
const int thickness = optionGetGuideThickness
();<br>
const float r =
(float)optionGetGuideEmptyRadius ();<br>
<br>
CompRect workArea;<br>
const bool restrictGuidesToOutputWithPointer =
optionGetRestrictGuidesToOutputWithPointer ();<br>
<br>
if (restrictGuidesToOutputWithPointer)<br>
workArea = screen->getWorkareaForOutput
(screen->outputDeviceForPoint (x, y));<br>
else<br>
workArea = CompRect (0, 0, screen->width (),
screen->height ());<br>
<br>
const int workAreaX = workArea.x ();<br>
const int workAreaY = workArea.y ();<br>
const int workAreaWidth = workArea.width ();<br>
const int workAreaHeight = workArea.height ();<br>
const int workAreaXPlusWidth = workAreaX + workAreaWidth;<br>
const int workAreaYPlusHeight = workAreaY + workAreaHeight;<br>
<br>
/* If the thickness is zero we don't have to draw, but we
should<br>
* still mark the region where the guides should be as damaged
--<br>
* this is useful when thickness has just been changed.<br>
*/<br>
if (thickness > 0)<br>
{<br>
glLineWidth ((GLfloat)thickness);<br>
<br>
GLboolean glBlendEnabled = glIsEnabled (GL_BLEND);<br>
<br>
/* we push in any case as we are going to change the blend
function */<br>
#ifndef USE_GLES<br>
glPushAttrib (GL_COLOR_BUFFER_BIT | GL_LINE_BIT);<br>
#endif<br>
<br>
if (!glBlendEnabled)<br>
glEnable (GL_BLEND);<br>
<br>
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);<br>
<br>
if (restrictGuidesToOutputWithPointer)<br>
{<br>
if (yf - r >= (GLfloat)workAreaY)<br>
drawLine (transform, xf, (GLfloat)workAreaY, xf, yf - r,
color);<br>
<br>
if (yf + r <= (GLfloat)workAreaYPlusHeight)<br>
drawLine (transform, xf, yf + r, xf,
(GLfloat)workAreaYPlusHeight, color);<br>
<br>
if (xf - r >= (GLfloat)workAreaX)<br>
drawLine (transform, (GLfloat)workAreaX, yf, xf - r, yf,
color);<br>
<br>
if (xf + r <= (GLfloat)workAreaXPlusWidth)<br>
drawLine (transform, xf + r, yf,
(GLfloat)workAreaXPlusWidth, yf, color);<br>
}<br>
else<br>
{<br>
drawLine (transform, xf, (GLfloat)workAreaY, xf, yf - r,
color);<br>
drawLine (transform, xf, yf + r, xf,
(GLfloat)workAreaYPlusHeight, color);<br>
drawLine (transform, (GLfloat)workAreaX, yf, xf - r, yf,
color);<br>
drawLine (transform, xf + r, yf,
(GLfloat)workAreaXPlusWidth, yf, color);<br>
}<br>
<br>
/* we changed the blend function in any way here */<br>
#ifndef USE_GLES<br>
glPopAttrib (); // restore line width and
glBlendFunc/GL_BLEND<br>
#else<br>
if (!glBlendEnabled)<br>
glDisable (GL_BLEND);<br>
<br>
glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);<br>
glLineWidth (1.0f);<br>
#endif<br>
}<br>
<br>
cScreen->damageRegion (CompRegion (workAreaX, y - thickness
/ 2 - 1,<br>
workAreaXPlusWidth, thickness + 1));<br>
cScreen->damageRegion (CompRegion (x - thickness / 2 - 1,
workAreaY,<br>
thickness + 1, workAreaYPlusHeight));<br>
}<br>
<br>
Maybe this saves you some work.<br>
<br>
Greetinx,<br>
MC Return<br>
</font>
</body>
</html>