omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    GLKit view fails

    Pythonista
    ctypes glkit objc
    2
    9
    6834
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Cethric
      Cethric last edited by

      I have been updating the OpenGLES library to use the GLKit math libraries so that there is no externally required dependencies and in doing so I have noticed an issue with physics.
      I have also seen another issue which isn't related to the math functions. When I create a GLKit GLKView it will work the first time however the second time it will fail.
      Updated project here.

      JonB 1 Reply Last reply Reply Quote 0
      • JonB
        JonB @Cethric last edited by

        @Cethric Can you post an example that shows the issues you mentioned?

        1 Reply Last reply Reply Quote 0
        • Cethric
          Cethric last edited by

          @JonB, run the main.py file in the root of the library. On first run, you will notice that the camera will drop below the 'ground' and (usually with id 51) in the physics view the camera y position looks like it 'jumps'. On the second run without restarting Pythonista GLKView is a black screen and fails to register the added buttons or render anything.

          1 Reply Last reply Reply Quote 0
          • JonB
            JonB last edited by

            I wonder if you are properly resetting everything. some of your modules rely, i think, on code getting executed during the import process, or depends on globals. But remember that modules might not get executed again when importing, yet globals get cleared..

            1 Reply Last reply Reply Quote 0
            • Cethric
              Cethric last edited by

              I will look into this and try resolving some of those issues.
              @JonB any ideas on why the physics component would be failing still?

              1 Reply Last reply Reply Quote 0
              • JonB
                JonB last edited by JonB

                Fwiw, i noticed that physicsworld.js does not get added to glviewv the second time around. I am not actually seeing where it gets added in the first place, but since a webview only runs when it is presented, this is likely the issue of the black screen.

                I have not delved deep enough to understand the physics problems.

                1 Reply Last reply Reply Quote 0
                • Cethric
                  Cethric last edited by

                  @JonB
                  Physics is handled under Util/Physics/__init__.py
                  The web view is loaded here

                  class CannonJS(object):
                      def __init__(self):
                          """
                          Handle object for most Physics related tasks
                          Attributes:
                              setup (bool): Are the libraries setup yet
                              objects (dict): This id of an object and the position and rotation of it
                              js (ui.WebView): A method to display infomation and handle the JSContext
                          """
                          self.setup = False
                          self.objects = {}
                          self.js = ui.WebView()
                          self.js.width = 800
                          self.js.height = 300
                          self.js.delegate = self
                          self.js.load_html(get_library('view.html'))
                          
                          while not self.setup:
                              pass
                  
                  

                  From line 55.
                  Then in main.py the physics world is loaded on lines 43 - 46

                  1 Reply Last reply Reply Quote 0
                  • JonB
                    JonB last edited by JonB

                    Print glviewv.subviews after the second run... no Webview is there. seems that the renderer.setup() never gets called. I suspect a problem with globals, but have not investigated further.

                    Also... are you "retaining" references to your delegate methods? omz had some examples where he stores them as attributes to ui, etc, (though a safer approach is to append them to a list, so they are not overwritten nedt time around). This is important when running multiple times, although i forget how the global clearing and module reloading logic works, whether site packages modules get deleted or not.

                    1 Reply Last reply Reply Quote 0
                    • Cethric
                      Cethric last edited by

                      I have updated the GitHub repo to represent the current work. I have more or less temporariely resolved the issue by calling reload(GLKit.view) in main.py how ever this is really only a temporary fix. I will look into some of the methods that omz uses to retain the globals/delegate methods.

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post
                      Powered by NodeBB Forums | Contributors