On 10/01/2012 04:56, skeezix wrote:
> Hey all,
>
> I've just today discovered kivy; looks absolutely fantastic and thank
> you to all contributors! (Looking to use it cross platform, including
> Android.)
Thanks!
>
> I've done some basic Hello World type stuff and gotten it to work
> under Linux and Android (using Livy Launcher from the marketplace).
>
> Goal: I'm looking at doing some basic OpenGL though, and I'm a little
> confused about how best to approach this. Kivy for the UI and then
> opengl wrapped vby Kivy to do 3d graphics, so more than the basic
> Rectangle/Point/Line/etc API provides.
>
> Any insight? Any samples? And worries about coliding with Kivys
> internal gl pipeline?
You'll will collide at some point. Best would be you to contribute on
Kivy to add 3D functionalities on our core graphics.
With our pipeline / approach, we know exactly what we need to draw every
frame. And then, optimization are far easier to do, like we can easily
remove or merge different mesh, clipping, etc. I mean in theory, not
everything we got in mind is done, as for today, we only remove
duplicate / unused gl call.
Also, if a graphics instruction is changed, we'll know, and update /
recompile only the changed part.
Anyway, we have a Callback() graphics instruction to escape of this
behavior. When the canvas will draw its instructions, the Callback()
instruction will call your python function. When you're done, it will
restore the previous state to be able to continue its pipeline drawing.
This part is not heavily tested, only used for doing a Panda 3D
integration in Kivy. Since OpenGL ES 2 don't have push/pop for all gl
state, we must manually handle it. Right now, it's only partial (check
the code to know really what we are doing.)
Example:
class CustomWidget(Widget):
def __init__(self, **kwargs):
super(CustomWidget, self).__init__(**kwargs)
with self.canvas:
Callback(self.draw)
# since we don't know if we need to redraw something, we
# must explicitly ask to the canvas to redraw itself
Clock.schedule_interval(self.ask_update, 1/60.)
def draw(self):
# put your gl stuff here for every frame
pass
def ask_update(self, *largs):
self.canvas.ask_update()
> Some random questions ..
> - As Kivy uses opengl for its existing primitives .. is this related
> to PyGL or any other projects, or all home grown? I see there is some
> link to pygame, but I've never looked into pygame too much (usually do
> all my game code in C++ and really wanting to go python :)
It's hand made, partially auto generated from GL.h. We have 2 wrapper,
one in Cython (close to C) + another in Python (using Cython). Only the
Python is available for the user.
(check kivy.graphics.opengl)
> - do we write opengl (for desktop) or opengl-es (for mobiles) or both
> (spaghetti code), or is there some adaptor layer? (like QT does, I
> suspect.) The docs suggest targeting GLES 2 always but some desktops
> are OpenGL and not GLES.. or more likely, all GL drivers support GLES
> on desktop in practice these days? I thought I saw some fixed pipeline
> GL references inthere like glBegin, or maybe it was glFinish.. sorry,
> had twins awhile ago, I'm foggyheaded ;)
We don't have adaptor layout. We recommend to stay on the GLES API,
since using it is compatible for Desktop (not the inverse). (Only 2
functions are not the same, otherwise, all is ok)
> - any risk of colliding with Kivys internal widget pipeline? ie: If I
> call the Rectangle or Bezier routines or whatever, and then write some
> rotating cubes or whatever, and then some more Rectangles, am I asking
> for trouble?
Answered before :)
> My goal is Kivy for cross platform and building a UI with Kivy->opengl
> for game surface stuff; showing space ships flying around and all
> that.
>
> Fully doable, or am I in for a world of hurt? It sure looks doable and
> fun :)
Not a world of hurt. We just have no example yet, and we lack of good 3D
support.
> (Is Kivy stable, or new and 'still funky'? I've been down that road a
> few times over the years where some project seems very stable, but
> after months of work you really find its falling apart, and you've
> lost all this time. Kivy does look pretty stable though, as it seems
> to work on Windows, Linux and Android.. very slick :)
We consider it as stable. Our previous unstable version was named
"pymt": http://pymt.eu/. We renamed it, stabilize, and make it
professionnal. (and we made professionnal product with it, some of them
are on the gallery http://kivy.org/#gallery :)
>
> All this aside -- thank you for everyone working on this system! It
> looks great :)
>
> jeff
Thanks for your interest,
Mathieu
# You'll will collide at some point. Best would be you to contribute on Kivy to
# add 3D functionalities on our core graphics.
I agree that would be best, but (sorry, always a but ;) we just
had twins awhile ago and with the amount of sleep I get, you really don't
want me in the frameworks itself. (And I already am a core firmware hacker
on a device, thats enough meddling for now ;)
But if I do get anything useful, I will for sure send it
upstream. It would be great to have some 3d mesh or model primitives, 3d
model loaders, texture translation and all that. I see an SVG loader so I
might just work on a 2d prototype first, we'll see (I've got some svg as
well as procedural 3d generation stuff, as I've not decided which
direction to go yet.) Simple retro (ie: simplified since I stink at
opengl) look anyway, so maybe I'd get lucky and not collide with Kivy's
pipeline.
(I'm very early on .. I keep switching roads, having fiddled with
native client for various plkatforms, or Qt or PyQt or PySide, or HTML5,
or hybrid native webkit with HTML5 from server and fancy GL on top at
client since WebGL is unusable still, etc. Now is a very painful time to
be a developer in that respect.. deciding your platform and frameworks :/)
But Kivy looks _fun_, and thats really what its about; python +
kivy .. awesome ;)
Any plans for iOS? (probably long term, given how painful Apple
has been with app store and interpreters.)
I'll see about porting Kivy to the Open Pandora handheld when I
get a moment.
# With our pipeline / approach, we know exactly what we need to draw every
# frame. And then, optimization are far easier to do, like we can easily remove
# or merge different mesh, clipping, etc. I mean in theory, not everything we
# got in mind is done, as for today, we only remove duplicate / unused gl call.
# Also, if a graphics instruction is changed, we'll know, and update / recompile
# only the changed part.
Very clever :)
# Anyway, we have a Callback() graphics instruction to escape of this behavior.
# When the canvas will draw its instructions, the Callback() instruction will
# call your python function. When you're done, it will restore the previous
# state to be able to continue its pipeline drawing.
# This part is not heavily tested, only used for doing a Panda 3D integration in
# Kivy. Since OpenGL ES 2 don't have push/pop for all gl state, we must manually
# handle it. Right now, it's only partial (check the code to know really what we
# are doing.)
Panda 3d?
You mean Kivy for UI/framework, then call into Panda 3d API to
render some 3d models and such?
Does that work? Any sample python or project urls?
I'm very curious to see somethign like that :)
# It's hand made, partially auto generated from GL.h. We have 2 wrapper, one in
# Cython (close to C) + another in Python (using Cython). Only the Python is
# available for the user.
# (check kivy.graphics.opengl)
okay; I've got some PyGL code around, thought maybe I'd luck into
using it.. but its all GL desktop (not GLES) anyway, so I should rework
it.
Thanks for your help,
jeff
--
If everyone would put barbecue sauce on their food, there would be no war.
http://github.com/kivy/kivy-ios
We are waiting the end of the contest to help best people of releasing
their app on the app store, for validating the IOS port.
> Panda 3d?
>
> You mean Kivy for UI/framework, then call into Panda 3d API to
> render some 3d models and such?
>
Yes, exactly
> Does that work? Any sample python or project urls?
Yes, http://txzone.net/files/contrib/panda3d/
Normally, i got a project this year that i'll continue and release a
proper kivy extension with panda3d.