@@ -544,6 +544,8 @@ def destroy(self):
544
544
del ShowBaseGlobal .base
545
545
546
546
self .aspect2d .node ().removeAllChildren ()
547
+ self .render2d .node ().removeAllChildren ()
548
+ self .aspect2d .reparent_to (self .render2d )
547
549
548
550
# [gjeon] restore sticky key settings
549
551
if self .config .GetBool ('disable-sticky-keys' , 0 ):
@@ -1108,8 +1110,12 @@ def setupRender2d(self):
1108
1110
2-d objects and gui elements that are superimposed over the
1109
1111
3-d geometry in the window.
1110
1112
"""
1113
+ # We've already created aspect2d in ShowBaseGlobal, for the
1114
+ # benefit of creating DirectGui elements before ShowBase.
1115
+ from . import ShowBaseGlobal
1116
+
1111
1117
## This is the root of the 2-D scene graph.
1112
- self .render2d = NodePath ( ' render2d' )
1118
+ self .render2d = ShowBaseGlobal . render2d
1113
1119
1114
1120
# Set up some overrides to turn off certain properties which
1115
1121
# we probably won't need for 2-d objects.
@@ -1140,7 +1146,6 @@ def setupRender2d(self):
1140
1146
## aspect2d, which scales things back to the right aspect
1141
1147
## ratio along the X axis (Z is still from -1 to 1)
1142
1148
self .aspect2d = ShowBaseGlobal .aspect2d
1143
- self .aspect2d .reparentTo (self .render2d )
1144
1149
1145
1150
aspectRatio = self .getAspectRatio ()
1146
1151
self .aspect2d .setScale (1.0 / aspectRatio , 1.0 , 1.0 )
0 commit comments