From 32342161fc00f7ad84394aff1aef05150b23dc07 Mon Sep 17 00:00:00 2001 From: David Vierra Date: Sat, 24 Oct 2015 15:43:56 -1000 Subject: [PATCH] Replace GL.GL_LINES with glPolygonMode(..., GL.GL_LINE) glPolygonMode is affected by polygon offset, GL.GL_LINES is not --- src/mcedit2/editortools/select.py | 6 ++++-- src/mcedit2/rendering/selection.py | 13 +++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/mcedit2/editortools/select.py b/src/mcedit2/editortools/select.py index b0ddca3..c221ecc 100644 --- a/src/mcedit2/editortools/select.py +++ b/src/mcedit2/editortools/select.py @@ -299,14 +299,16 @@ class SelectionCursorRenderNode(rendernode.RenderNode): alpha = 0.3 box = BoundingBox(point, (1, 1, 1)) - with gl.glPushAttrib(GL.GL_DEPTH_BUFFER_BIT | GL.GL_ENABLE_BIT): + with gl.glPushAttrib(GL.GL_DEPTH_BUFFER_BIT | GL.GL_ENABLE_BIT | GL.GL_POLYGON_BIT): GL.glDepthMask(False) GL.glEnable(GL.GL_BLEND) GL.glPolygonOffset(DepthOffset.SelectionCursor, DepthOffset.SelectionCursor) # Wire box GL.glColor(1., 1., 1., alpha) - cubes.drawBox(box, cubeType=GL.GL_LINES) + GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE) + + cubes.drawBox(box) # Highlighted face GL.glColor(r, g, b, alpha) diff --git a/src/mcedit2/rendering/selection.py b/src/mcedit2/rendering/selection.py index a197722..2e58430 100644 --- a/src/mcedit2/rendering/selection.py +++ b/src/mcedit2/rendering/selection.py @@ -271,22 +271,27 @@ class SelectionBoxRenderNode(rendernode.RenderNode): with gl.glPushAttrib(GL.GL_DEPTH_BUFFER_BIT | GL.GL_ENABLE_BIT | GL.GL_POLYGON_BIT): GL.glDepthMask(False) GL.glEnable(GL.GL_BLEND) + GL.glEnable(GL.GL_POLYGON_OFFSET_LINE) GL.glPolygonOffset(self.sceneNode.depth, self.sceneNode.depth) + GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE) + if self.sceneNode.filled: # Filled box GL.glColor(r, g, b, alpha) cubes.drawBox(box) if self.sceneNode.wire: - # Wire box, thinner behind terrain + # Wire box, in front of terrain r, g, b, alpha = self.sceneNode.wireColor GL.glColor(r, g, b, alpha) - GL.glLineWidth(2.0) - cubes.drawBox(box, cubeType=GL.GL_LINES) + GL.glLineWidth(3.0) + cubes.drawBox(box) + # Wire box, behind terrain, thinner GL.glDisable(GL.GL_DEPTH_TEST) + GL.glColor(r, g, b, alpha * 0.5) GL.glLineWidth(1.0) - cubes.drawBox(box, cubeType=GL.GL_LINES) + cubes.drawBox(box) class SelectionBoxNode(scenenode.Node): RenderNodeClass = SelectionBoxRenderNode