Replace GL.GL_LINES with glPolygonMode(..., GL.GL_LINE)

glPolygonMode is affected by polygon offset, GL.GL_LINES is not
This commit is contained in:
David Vierra 2015-10-24 15:43:56 -10:00
parent c2f128efe6
commit 32342161fc
2 changed files with 13 additions and 6 deletions

View File

@ -299,14 +299,16 @@ class SelectionCursorRenderNode(rendernode.RenderNode):
alpha = 0.3 alpha = 0.3
box = BoundingBox(point, (1, 1, 1)) 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.glDepthMask(False)
GL.glEnable(GL.GL_BLEND) GL.glEnable(GL.GL_BLEND)
GL.glPolygonOffset(DepthOffset.SelectionCursor, DepthOffset.SelectionCursor) GL.glPolygonOffset(DepthOffset.SelectionCursor, DepthOffset.SelectionCursor)
# Wire box # Wire box
GL.glColor(1., 1., 1., alpha) 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 # Highlighted face
GL.glColor(r, g, b, alpha) GL.glColor(r, g, b, alpha)

View File

@ -271,22 +271,27 @@ class SelectionBoxRenderNode(rendernode.RenderNode):
with gl.glPushAttrib(GL.GL_DEPTH_BUFFER_BIT | GL.GL_ENABLE_BIT | GL.GL_POLYGON_BIT): with gl.glPushAttrib(GL.GL_DEPTH_BUFFER_BIT | GL.GL_ENABLE_BIT | GL.GL_POLYGON_BIT):
GL.glDepthMask(False) GL.glDepthMask(False)
GL.glEnable(GL.GL_BLEND) GL.glEnable(GL.GL_BLEND)
GL.glEnable(GL.GL_POLYGON_OFFSET_LINE)
GL.glPolygonOffset(self.sceneNode.depth, self.sceneNode.depth) GL.glPolygonOffset(self.sceneNode.depth, self.sceneNode.depth)
GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE)
if self.sceneNode.filled: if self.sceneNode.filled:
# Filled box # Filled box
GL.glColor(r, g, b, alpha) GL.glColor(r, g, b, alpha)
cubes.drawBox(box) cubes.drawBox(box)
if self.sceneNode.wire: if self.sceneNode.wire:
# Wire box, thinner behind terrain # Wire box, in front of terrain
r, g, b, alpha = self.sceneNode.wireColor r, g, b, alpha = self.sceneNode.wireColor
GL.glColor(r, g, b, alpha) GL.glColor(r, g, b, alpha)
GL.glLineWidth(2.0) GL.glLineWidth(3.0)
cubes.drawBox(box, cubeType=GL.GL_LINES) cubes.drawBox(box)
# Wire box, behind terrain, thinner
GL.glDisable(GL.GL_DEPTH_TEST) GL.glDisable(GL.GL_DEPTH_TEST)
GL.glColor(r, g, b, alpha * 0.5)
GL.glLineWidth(1.0) GL.glLineWidth(1.0)
cubes.drawBox(box, cubeType=GL.GL_LINES) cubes.drawBox(box)
class SelectionBoxNode(scenenode.Node): class SelectionBoxNode(scenenode.Node):
RenderNodeClass = SelectionBoxRenderNode RenderNodeClass = SelectionBoxRenderNode