Shader viewer - without .kv file

16 views
Skip to first unread message

Charly DELAROCHE

unread,
Aug 5, 2020, 6:24:14 AM8/5/20
to Kivy users support
Hey,

I just started using kivy and it's awesome! 
I've been trying to modify the shader editor example. I wanted to get rid of the .kv interface file and do everything programatically. My goal was just to run a shader and visualize it. However, I failed to do so. I can see the shader updating every frame, but nothing is displayed. 
I tried to make my code as small as possible. Could you help me on this?

Thanks!


shader-kivy.py

Elliot Garbus

unread,
Aug 5, 2020, 11:45:15 AM8/5/20
to kivy-...@googlegroups.com

You need to add the widgets that are created in the kv file.

Or better yet, embrace and learn kv.  It is very powerful – and part of what makes kivy very productive.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/3dd6fd1d-8d8f-4a54-aaff-8ead0e879664o%40googlegroups.com.

 

Charly DELAROCHE

unread,
Aug 5, 2020, 12:49:51 PM8/5/20
to Kivy users support
I tried to mimic what the .kv is doing in the example code. Also to truly understand what the .kv is doing I think you should be able to reproduce it programatically, which I'm not able too.

Could you take a quick look at my code example and tell me what is wrong with it?

Thanks,
Charly


Le mercredi 5 août 2020 17:45:15 UTC+2, Elliot Garbus a écrit :

You need to add the widgets that are created in the kv file.

Or better yet, embrace and learn kv.  It is very powerful – and part of what makes kivy very productive.

 

 

From: Charly DELAROCHE
Sent: Wednesday, August 5, 2020 3:24 AM
To: Kivy users support
Subject: [kivy-users] Shader viewer - without .kv file

 

Hey,

 

I just started using kivy and it's awesome! 

I've been trying to modify the shader editor example. I wanted to get rid of the .kv interface file and do everything programatically. My goal was just to run a shader and visualize it. However, I failed to do so. I can see the shader updating every frame, but nothing is displayed. 

I tried to make my code as small as possible. Could you help me on this?

 

Thanks!

 

 

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.

Elliot Garbus

unread,
Aug 5, 2020, 1:07:26 PM8/5/20
to kivy-...@googlegroups.com

Take a look at the kv file, copied below.  Notice in ShaderEditor (what you have called ShaderRoot), there are nested BoxLayouts with widgets… I don’t see any of this in your python code.   Additionally the shader viewer sets the canvas color to white.  I don’t see the canvas of the ShaderViewer being set.

See: https://kivy.org/doc/stable/api-kivy.uix.widget.html?highlight=canvas#basic-drawing

 

<ShaderEditor>:
    viewer: viewer

   
BoxLayout:
       
BoxLayout:
           
orientation: 'vertical'
           
size_hint_x: None
           
width: 350

           
Label:
               
text: 'Fragment Shader'
               
size_hint_y: None
               
height: self.texture_size[1] + 10
           
CodeInput:
               
text: root.fs
                lexer: GLShaderLexer()
               
on_text: root.fs = args[1]

           
Label:
               
text: 'Vertex Shader'
               
size_hint_y: None
               
height: self.texture_size[1] + 10
           
CodeInput:
               
text: root.vs
                lexer: GLShaderLexer()
               
on_text: root.vs = args[1]

        ShaderViewer:
            
id: viewer
           
canvas:
               
Color:
                   
rgb: 1, 1, 1
               
Rectangle:
                   
size: self.size
                    pos
: self.pos
                    source
: root.source

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/ca3dbbe1-7516-4442-b6bb-883a88d5b663o%40googlegroups.com.

 

Reply all
Reply to author
Forward
0 new messages