Kivy not rendering

118 views
Skip to first unread message

Dan Kolle

unread,
Jun 1, 2015, 1:38:54 PM6/1/15
to kivy-...@googlegroups.com
Hello everybody,

I have Kivy set up but it is not rendering anything. I use some customized code but the frame buffer is rendered correctly. I checked this with some hard-coded rectangles.

When I debug my application with gDEBugger GL, I can also see that between binding my frame buffer and unbinding it again, nothing happens except for some matrices being set.

I load a KV file and also implement my own build function to add widgets.

To inject my own frame buffer, I use the following class:


This translates into the following OpenGL code:

  • The first three lines belong to bind().
  • Then comes RenderContext.draw().
  • The last three lines belong to unbind() show my debug rectangle which is visible.


So far I had no success, even forcing GI_NEEDS_UPDATE to be set does not change anything. Same for dispatching on_draw and on_flip manually.

It would be great if someone could point me in the right direction why RenderContext.draw does not seem to generate any output.

Thanks
Dan

Dan Kolle

unread,
Jun 1, 2015, 6:41:55 PM6/1/15
to kivy-...@googlegroups.com
This is the log output Kivy gives me:

[0:37:53]  [Debug]    Builder: call_fn <kivy.graphics.vertex_instructions.Rectangle object at 0x000000EC1F657948>, key=size, value=<code object <module> at 0x000000EC1F052700, file "data\style.kv", line 27>, 'self.texture_size'
[0:37:53]  [Debug]    Builder: call_fn => value=[52, 15]
[0:37:53]  [Debug]    Builder: call_fn <kivy.graphics.vertex_instructions.Rectangle object at 0x000000EC1F657948>, key=texture, value=<code object <module> at 0x000000EC1F052B80, file "data\style.kv", line 26>, 'self.texture'
[0:37:53]  [Debug]    Builder: call_fn => value=<Texture hash=1014134061616 id=0 size=(52, 15) colorfmt='rgba' bufferfmt='ubyte' source=None observers=1>
[0:37:53]  [Debug]    Builder: call_fn <kivy.graphics.vertex_instructions.BorderImage object at 0x000000EC1F625640>, key=texture, value=<code object <module> at 0x000000EC1F1D6D00, file "app_logo.kv", line 10>, 'self.texture'
[0:37:53]  [Debug]    Builder: call_fn => value=<Texture hash=1014134061336 id=2 size=(250, 250) colorfmt='rgb' bufferfmt='ubyte' source='False|kivy.jpg|0|0' observers=0>
[0:37:53]  [Debug]    Builder: call_fn <kivy.graphics.vertex_instructions.Rectangle object at 0x000000EC1F6577A8>, key=texture, value=<code object <module> at 0x000000EC1F063400, file "data\style.kv", line 111>, 'self.texture'
[0:37:53]  [Debug]    Builder: call_fn => value=<Texture hash=1014134061336 id=2 size=(250, 250) colorfmt='rgb' bufferfmt='ubyte' source='False|kivy.jpg|0|0' observers=0>
[0:37:53]  [Debug]    Builder: call_fn <kivy.graphics.vertex_instructions.BorderImage object at 0x000000EC1F625640>, key=size, value=<code object <module> at 0x000000EC1F1E2C40, file "app_logo.kv", line 11>, 'self.texture_size'
[0:37:53]  [Debug]    Builder: call_fn => value=[250, 250]
[0:37:53]  [Debug]    Builder: call_fn <kivy.graphics.vertex_instructions.Rectangle object at 0x000000EC1F6577A8>, key=pos, value=<code object <module> at 0x000000EC1F063F40, file "data\style.kv", line 113>, 'self.center_x - self.norm_image_size[0] / 2., self.center_y - self.norm_image_size[1] / 2.'
[0:37:54]  [Debug]    Builder: call_fn => value=(0.0, 0.0)
[0:37:54]  [Debug]    Builder: call_fn <kivy.graphics.vertex_instructions.Rectangle object at 0x000000EC1F6577A8>, key=size, value=<code object <module> at 0x000000EC1F0634C0, file "data\style.kv", line 112>, 'self.norm_image_size'
[0:37:54]  [Debug]    Builder: call_fn => value=(100, 100.0)
[0:37:54]  [Debug]    Builder: call_fn <kivy.graphics.vertex_instructions.BorderImage object at 0x000000EC1F625C28>, key=pos, value=<code object <module> at 0x000000EC1F0524C0, file "data\style.kv", line 20>, 'self.pos'
[0:37:54]  [Debug]    Builder: call_fn => value=[100, 100]
[0:37:54]  [Debug]    Builder: call_fn <kivy.graphics.vertex_instructions.Rectangle object at 0x000000EC1F657948>, key=pos, value=<code object <module> at 0x000000EC1F052100, file "data\style.kv", line 28>, 'int(self.center_x - self.texture_size[0] / 2.), int(self.center_y - self.texture_size[1] / 2.)'
[0:37:54]  [Debug]    Builder: call_fn => value=(124, 142)
[0:37:54]  [Debug]    Builder: call_fn <kivy.graphics.vertex_instructions.BorderImage object at 0x000000EC1F625C28>, key=source, value=<code object <module> at 0x000000EC1F052C40, file "data\style.kv", line 22>, 'self.disabled_image if self.disabled else self.state_image'
[0:37:54]  [Debug]    Builder: call_fn => value='atlas://data/images/defaulttheme/button'
[0:37:54]  [Debug]    Atlas: Load <data\images\defaulttheme.atlas>
[0:37:54]  [Debug]    Atlas: Need to load 1 images
[0:37:54]  [Debug]    Atlas: Load <\data\images\defaulttheme-0.png>
[0:37:54]  [Debug]    MyImage: Load <data\images\defaulttheme-0.png>
[0:37:54]  [Debug]    Image: 'data\\images\\defaulttheme-0.png', populate to textures (1)

Alexander Taylor

unread,
Jun 2, 2015, 7:26:36 AM6/2/15
to kivy-...@googlegroups.com
I don't follow - do you mean that kivy itself is broken and doesn't render anything (e.g. all the examples don't work), or specifically that your RenderContext subclass doesn't work?

Dan Kolle

unread,
Jun 2, 2015, 3:10:46 PM6/2/15
to kivy-...@googlegroups.com
I am using a different "provider" than sdl2 so I need my own RenderContext. The rendering by itself seems to work but RenderContext.draw() does not generate any opengl instructions except for some matrices.

Right now I do not know why no OpenGL instructions are generated, the root object is set and compiled_children is generated as well. I use  the kv/app_logo example as a starting point.

Sadly cython is a bit tedious when debugging so I was hoping that someone could point out the place where it would set the projection matrices but then fail to continue to draw any children so I can continue debugging there.

The call to the draw aka apply methods looks fine to me:

> Creator.exe!__pyx_f_4kivy_8graphics_12instructions_16InstructionGroup_apply(__pyx_obj_4kivy_8graphics_12instructions_InstructionGroup * __pyx_v_self) Line 3763 C
  Creator.exe!__pyx_f_4kivy_8graphics_12instructions_6Canvas_apply(__pyx_obj_4kivy_8graphics_12instructions_Canvas * __pyx_v_self) Line 8870 C
  Creator.exe!__pyx_f_4kivy_8graphics_12instructions_13RenderContext_apply(__pyx_obj_4kivy_8graphics_12instructions_RenderContext * __pyx_v_self) Line 11641 C
  Creator.exe!__pyx_f_4kivy_8graphics_12instructions_6Canvas_draw(__pyx_obj_4kivy_8graphics_12instructions_Canvas * __pyx_v_self, int __pyx_skip_dispatch) Line 8709 C
  Creator.exe!__pyx_pf_4kivy_8graphics_12instructions_6Canvas_4draw(__pyx_obj_4kivy_8graphics_12instructions_Canvas * __pyx_v_self) Line 8747 C
  Creator.exe!__pyx_pw_4kivy_8graphics_12instructions_6Canvas_5draw(_object * __pyx_v_self, _object * unused) Line 8731 C

Dan Kolle

unread,
Jun 2, 2015, 4:13:17 PM6/2/15
to kivy-...@googlegroups.com
I noticed that the GI_NO_APPLY_ONCE is set.

I found this comment:

        # Also, flag ourself as GL_NO_APPLY_ONCE, to prevent to reapply all the
        # instructions when the compiler is leaving.

Can it be that no drawing happens at all and the matrix instructions I see are from the compiler?

Alexander Taylor

unread,
Jun 2, 2015, 7:07:21 PM6/2/15
to kivy-...@googlegroups.com
I don't understand - the RenderContext doesn't care if you are using sdl2 or not, it's an opengl abstraction that should work the same regardless of backend.

I don't know what's wrong though, anyway. Maybe you could post a working example demonstrating waht you're trying and the problem you have.

Dan Kolle

unread,
Jun 3, 2015, 5:39:11 AM6/3/15
to kivy-...@googlegroups.com
Good point. I took my render context out of the equation and render directly to OpenGL. So I end up with this now so nothing really changed which is good as expected.

About what I am trying to do. I have Python embedded in one of my applications and I want to use Kivy for the user interface.
I have Image, Window, Label and Text modified so it will work with the native framework of my application.

As far as I have debugged from C++ and Python side everything looks fine now but the draw call to Kivy does not render anything at all. As mentioned I use the app_logo example so I would expect at least some texture bindings to happen.

My tick function which I use to debug the drawing looks like this:

self._kivy._app_window.dispatch('on_draw')
self._kivy._app_window.dispatch('on_flip')

EventLoop.idle()

Currently I am not sure why nothing is drawn as everything should be set up as needed. Also the Kivy log does not show any errors. Only warning I get is related to wm_pen and wm_touch.

Here is the complete log I get from Kivy:
https://www.dropbox.com/s/0ioma8s2lhmhrim/kivy_log.txt?dl=0

Dan Kolle

unread,
Jun 3, 2015, 5:55:13 AM6/3/15
to kivy-...@googlegroups.com
Okay I found the problem. Because I do ticking on my own due to the nature of my application, I extended App.run so it passes a parameter "slave" to runTouchApp. I did not notice that this will still cause stop() to be called. Now the content is displayed as expected.

Dan Kolle

unread,
Jun 3, 2015, 6:03:27 AM6/3/15
to kivy-...@googlegroups.com
Thanks for your help. Your input pushed me in the right direction. :)
Reply all
Reply to author
Forward
0 new messages