Skip to content

Commit d1fe840

Browse files
committed
Fixed bug with stencil in deeply nested containers
- Fixed bug with stencil in deeply nested containers - Changed version numbers for bugfix release 1.6.1a1
1 parent e55d22b commit d1fe840

File tree

2 files changed

+33
-31
lines changed

2 files changed

+33
-31
lines changed

peng3d/gui/container.py

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -102,29 +102,29 @@ def draw(self):
102102
103103
Note that this leaves the OpenGL state set to 2d drawing and may modify the stencil settings and buffer.
104104
"""
105-
106-
# Stencil setup
107-
glEnable(GL_STENCIL_TEST)
108-
#mask = pyglet.image.get_buffer_manager().get_buffer_mask()
109-
#glSetAttribute(GL_STENCIL_SIZE,8)
110-
111-
# Set up the stencil for this container
112-
glStencilFunc(GL_ALWAYS,1,0xFF)
113-
glStencilOp(GL_KEEP,GL_KEEP,GL_REPLACE)
114-
glStencilMask(0xFF)
115-
glClear(GL_STENCIL_BUFFER_BIT)
116-
117-
# Practically hides most drawing operations, should be redundant since the quad is fully transparent
118-
glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE)
119-
glDepthMask(GL_FALSE)
120-
121-
self.stencil_vlist.draw(GL_QUADS)
122-
123-
# Reset to proper state and set up the stencil func/mask
124-
glStencilFunc(GL_EQUAL,1,0xFF)
125-
glStencilMask(0x00)
126-
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE)
127-
glDepthMask(GL_TRUE)
105+
if not isinstance(self.submenu,Container):
106+
# Stencil setup
107+
glEnable(GL_STENCIL_TEST)
108+
#mask = pyglet.image.get_buffer_manager().get_buffer_mask()
109+
#glSetAttribute(GL_STENCIL_SIZE,8)
110+
111+
# Set up the stencil for this container
112+
glStencilFunc(GL_ALWAYS,1,0xFF)
113+
glStencilOp(GL_KEEP,GL_KEEP,GL_REPLACE)
114+
glStencilMask(0xFF)
115+
glClear(GL_STENCIL_BUFFER_BIT)
116+
117+
# Practically hides most drawing operations, should be redundant since the quad is fully transparent
118+
glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE)
119+
glDepthMask(GL_FALSE)
120+
121+
self.stencil_vlist.draw(GL_QUADS)
122+
123+
# Reset to proper state and set up the stencil func/mask
124+
glStencilFunc(GL_EQUAL,1,0xFF)
125+
glStencilMask(0x00)
126+
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE)
127+
glDepthMask(GL_TRUE)
128128

129129
# Stenciled code
130130
self.window.set2d()
@@ -141,16 +141,18 @@ def draw(self):
141141
else:
142142
raise TypeError("Unknown background type")
143143
self.window.set2d() # In case the bg layer was in 3d
144-
glStencilFunc(GL_EQUAL,1,0xFF)
145-
glStencilMask(0x00)
144+
if not isinstance(self.submenu,Container):
145+
glStencilFunc(GL_EQUAL,1,0xFF)
146+
glStencilMask(0x00)
146147
self.batch2d.draw()
147148
for widget in self.widgets.values():
148149
widget.draw()
149150

150-
# Stencil teardown
151-
glDisable(GL_STENCIL_TEST)
152-
# Make sure to disable the stencil test first, or the stencil buffer will only clear areas that are allowed to by glStencilFunc
153-
glClear(GL_STENCIL_BUFFER_BIT)
151+
if not isinstance(self.submenu,Container):
152+
# Stencil teardown
153+
glDisable(GL_STENCIL_TEST)
154+
# Make sure to disable the stencil test first, or the stencil buffer will only clear areas that are allowed to by glStencilFunc
155+
glClear(GL_STENCIL_BUFFER_BIT)
154156

155157
def redraw(self):
156158
"""

peng3d/version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
__all__ = ["VERSION","RELEASE"]
2626

27-
VERSION = "1.6.0a1"
27+
VERSION = "1.6.1a1"
2828
"""
2929
Full version number of format ``MAJOR.MINOR.BUGFIX(a|b|pre)SUBRELEASE`` where major is increased only on very major feature changes.
3030
Minor is changed if a new feature is introduced or an API change is made, while bugfix only changes if an important fix for a bug needs to be provided before the next release.
@@ -38,7 +38,7 @@
3838
3939
"""
4040

41-
RELEASE = "1.6.0"
41+
RELEASE = "1.6.1"
4242
"""
4343
Same as :py:data:`VERSION` but without the subrelease.
4444

0 commit comments

Comments
 (0)