Skip to content

Commit 69e8b4e

Browse files
committed
showbase: make render2d available to GUI items without ShowBase
1 parent eb3b45e commit 69e8b4e

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

direct/src/showbase/ShowBase.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,8 @@ def destroy(self):
544544
del ShowBaseGlobal.base
545545

546546
self.aspect2d.node().removeAllChildren()
547+
self.render2d.node().removeAllChildren()
548+
self.aspect2d.reparent_to(self.render2d)
547549

548550
# [gjeon] restore sticky key settings
549551
if self.config.GetBool('disable-sticky-keys', 0):
@@ -1108,8 +1110,12 @@ def setupRender2d(self):
11081110
2-d objects and gui elements that are superimposed over the
11091111
3-d geometry in the window.
11101112
"""
1113+
# We've already created aspect2d in ShowBaseGlobal, for the
1114+
# benefit of creating DirectGui elements before ShowBase.
1115+
from . import ShowBaseGlobal
1116+
11111117
## This is the root of the 2-D scene graph.
1112-
self.render2d = NodePath('render2d')
1118+
self.render2d = ShowBaseGlobal.render2d
11131119

11141120
# Set up some overrides to turn off certain properties which
11151121
# we probably won't need for 2-d objects.
@@ -1140,7 +1146,6 @@ def setupRender2d(self):
11401146
## aspect2d, which scales things back to the right aspect
11411147
## ratio along the X axis (Z is still from -1 to 1)
11421148
self.aspect2d = ShowBaseGlobal.aspect2d
1143-
self.aspect2d.reparentTo(self.render2d)
11441149

11451150
aspectRatio = self.getAspectRatio()
11461151
self.aspect2d.setScale(1.0 / aspectRatio, 1.0, 1.0)

direct/src/showbase/ShowBaseGlobal.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
pandaSystem = PandaSystem.getGlobalPtr()
2727

2828
# This is defined here so GUI elements can be instantiated before ShowBase.
29-
aspect2d = NodePath(PGTop("aspect2d"))
29+
render2d = NodePath("render2d")
30+
aspect2d = render2d.attachNewNode(PGTop("aspect2d"))
3031
hidden = NodePath("hidden")
3132

3233
# Set direct notify categories now that we have config

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy