tobspr / LUI

Lightweight User Interface for Panda3D
MIT License
84 stars 24 forks source link

Integrating with RenderPipeline #36

Closed rcarjan closed 7 years ago

rcarjan commented 7 years ago

Hello, I am looking for a GUI library to use with Panda3D / RenderPipeline, and at the moment LUI looks the most promising. (especially since it is already integrated with Panda3D). The issue I am having is that I cannot seem to get both RenderPipeline and LUI to work together. I have made a simple Panda application using RP, and then added a very simple piece of code to add a LUIButton on top of it, such as it is done in 01_MinimalExample.py. The application runs fine, however the button doesn't show. Is there anything I need to do to make it work inside a 3D application, or am I doing anything wrong?

Here is how my code looks like:

##########
skip imports
##########

class Application(ShowBase):
    '''
        Initialize and setup the application
    '''
    def __init__(self):
        # Load configuration file - Window size, title, fullscreen, etc
        self.loadConfig()
        # Define the key bindings
        self.defineKeys()
        # Init the RenderPipeline
        self.initRenderPipeline()
        # Setup the environment
        self.initEnvironment()
        # Setup the physics
        self.initPhysics()
        # Setup the player actor
        self.initPlayer()
        # Setup the camera
        self.initCamera()
        # Setup the lighting
        self.initLighting()
        # Setup mouse click handler
        self.initMouseHandler()

        taskMgr.add(self.updateCamera, "updateCameraTask")

        #GUI
        # Construct a new LUIRegion
        region = LUIRegion.make("LUI", base.win)
        # Construct a new InputHandler to catch and process events
        handler = LUIInputHandler()
        base.mouseWatcher.attach_new_node(handler)
        region.set_input_handler(handler)
        # Load the default LUI skin
        skin = LUIDefaultSkin()
        skin.load()
        # LUI is initialized now, so we can start adding elements, for example:
        button = LUIButton(parent=region.root, text="Hello world!", top=30, left=30)
        #GUI

        # self.cTrav.showCollisions(render)

# Run the application
Application().run()
tobspr commented 7 years ago

Hm, it might be the display region is hidden by the render pipeline. Can you try region.set_sort(10000) ?

rcarjan commented 7 years ago

Huh. It's working. Thanks alot! I really need to study the demos more thoroughly.

tobspr commented 7 years ago

Okay, great, easier than I thought!