Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Pyglet example that uses GLSL and programmable pipeline
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  14 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
mv  
View profile  
 More options Sep 25 2012, 7:19 am
From: mv <mkven...@gmail.com>
Date: Tue, 25 Sep 2012 04:19:38 -0700 (PDT)
Local: Tues, Sep 25 2012 7:19 am
Subject: Pyglet example that uses GLSL and programmable pipeline

Hello,

I am looking for a Pyglet example that uses GLSL and the programmable
pipeline.

I looked at the Pyglet documentation, but am unable to figure out how to
define my own vertex list, and then link that with say, a "attribute vec4
pos" variable in the vertex shader.

The examples I have seen use vertex lists, but still use the now deprecated
fixed function pipeline.

I'd appreciate any help with this.

Regards


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Adam Griffiths  
View profile  
 More options Sep 25 2012, 11:33 pm
From: Adam Griffiths <adam.lw.griffi...@gmail.com>
Date: Tue, 25 Sep 2012 20:33:39 -0700 (PDT)
Local: Tues, Sep 25 2012 11:33 pm
Subject: Re: Pyglet example that uses GLSL and programmable pipeline

I've been working on getting the Core profile working under Pyglet.

My framework, PyGLy (very simple, flexible, stays out of your way) includes
a number of examples.

The simplest one is here:

https://github.com/adamlwgriffiths/PyGLy/blob/master/examples/core/si...

Uses the scene graph to render a series of cubes.

This uses the core profile.

I also _had_ some example code that was using shaders in the legacy profile
(fixed function pipeline + shaders), but have not committed this.

Using shaders in legacy is essentially the same as normal rendering.

The only thing I had to look out for was assigning attributes to vertices.

You need to link the shader, then query for the attribute index, then use
that as the "XgX" format specifier for the vertex_list (assuming you're
using piglet's vertex list object).

I talked about this here:

https://groups.google.com/forum/?fromgroups=#!topic/pyglet-users/Eony...

Hope that helps =)

Cheers,

Adam


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Adam Griffiths  
View profile  
 More options Sep 25 2012, 11:40 pm
From: Adam Griffiths <adam.lw.griffi...@gmail.com>
Date: Tue, 25 Sep 2012 20:40:02 -0700 (PDT)
Local: Tues, Sep 25 2012 11:40 pm
Subject: Re: Pyglet example that uses GLSL and programmable pipeline

I just read your post a bit more thoroughly, sorry, in a rush today.

Pyglet's code uses legacy calls. If you're using Core profile only with no
compatibility, you'll need to do your own vertex arrays.
I'm running on OS-X and I'm unable to mix legacy and core.

I've got an example that uses Core VBO and VAO calls.
It includes everything needed to render the cube, apart from the matrices
themselves which are in simple.py I posted earlier.
https://github.com/adamlwgriffiths/PyGLy/blob/master/examples/core/cu...

This file also uses vertex attributes to specify colour:
https://github.com/adamlwgriffiths/PyGLy/blob/master/examples/core/co...

I'm currently looking into either writing my own classes to use in PyGLy,
or updating pyglet to enable core profile usage in these key classes
(texture, label, vertex_list).

Take a gander around my PyGLy repository.

I've also got a GLSL shader I'm working on atm (it works, just want to
clean up the API) that does hardware animation / interpolation of MD2 mesh
formats (yes, old, but simple).
https://github.com/adamlwgriffiths/Razorback/blob/master/razorback/md...

This should give you enough info.

The code is long, but its clear and I don't remove any boiler plate.
So the code you want to look at is:
pygly/shader.py
examples/application.py
examples/core/application.py
examples/core/simple/main.py
examples/core/cube.py
examples/core/colour_cube.py

Cheers,
Adam


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Adam Griffiths  
View profile  
 More options Sep 25 2012, 11:42 pm
From: Adam Griffiths <adam.lw.griffi...@gmail.com>
Date: Tue, 25 Sep 2012 20:42:45 -0700 (PDT)
Local: Tues, Sep 25 2012 11:42 pm
Subject: Re: Pyglet example that uses GLSL and programmable pipeline

To sum up (sorry, 3 emails).

If you want core profile, the only thing you can use pyglet for is events
and the window itself.
You need to provide the rest.

However, like I said before. I'm either going to provide my own classes in
pygly, or work on pyglet to add this functionality.

Adam


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mv  
View profile  
 More options Sep 29 2012, 11:21 pm
From: mv <mkven...@gmail.com>
Date: Sat, 29 Sep 2012 20:21:32 -0700 (PDT)
Local: Sat, Sep 29 2012 11:21 pm
Subject: Re: Pyglet example that uses GLSL and programmable pipeline

Thanks, Adam.

I'll check out the links your provided.

Prior to seeing this post, I was able to make my code (that uses my own
vertex/fragment shaders and vertex attributes) work with something like
this:

        # position


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Adam Griffiths  
View profile  
 More options Sep 30 2012, 11:46 am
From: Adam Griffiths <adam.lw.griffi...@gmail.com>
Date: Sun, 30 Sep 2012 08:46:37 -0700 (PDT)
Local: Sun, Sep 30 2012 11:46 am
Subject: Re: Pyglet example that uses GLSL and programmable pipeline

Ah thanks for that information.
I hadn't tried the vertex_list class without the 'v' type and just assumed
it would always call some legacy code.

Cheers,
Adam


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mv  
View profile  
 More options Sep 30 2012, 10:42 pm
From: mv <mkven...@gmail.com>
Date: Sun, 30 Sep 2012 19:42:56 -0700 (PDT)
Local: Sun, Sep 30 2012 10:42 pm
Subject: Re: Pyglet example that uses GLSL and programmable pipeline

On Sunday, September 30, 2012 9:16:37 PM UTC+5:30, Adam Griffiths wrote:

> Ah thanks for that information.
> I hadn't tried the vertex_list class without the 'v' type and just assumed
> it would always call some legacy code.

> Cheers,
> Adam

Hi Adam,

Unfortunately, you can't update the generic attributes in Pyglet vertex
lists :

http://www.pyglet.org/doc/programming_guide/vertex_lists.html

I am relatively new to Python, but not to OpenGL. I wish there was an
OpenGL Python binding where I didn't have to deal with all these layers of
code. I just need OpenGL access - don't need anything else. Do you know if
PyOpenGL is still being maintained? I was unable to make it work on my
Macbook.

Thanks

Mahesh


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Richard Jones  
View profile  
 More options Sep 30 2012, 11:11 pm
From: Richard Jones <r1chardj0...@gmail.com>
Date: Mon, 1 Oct 2012 13:11:10 +1000
Local: Sun, Sep 30 2012 11:11 pm
Subject: Re: Pyglet example that uses GLSL and programmable pipeline
On 1 October 2012 12:42, mv <mkven...@gmail.com> wrote:

> I am relatively new to Python, but not to OpenGL. I wish there was an OpenGL
> Python binding where I didn't have to deal with all these layers of code.

PyOpenGL has a much nicer interface. pyglet's never had a goal of
duplicating that.

> I just need OpenGL access - don't need anything else. Do you know if PyOpenGL
> is still being maintained? I was unable to make it work on my Macbook.

The last beta for PyOpenGL was uploaded to PyPI just over a month ago.

     Richard


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mv  
View profile  
 More options Sep 30 2012, 11:55 pm
From: mv <mkven...@gmail.com>
Date: Sun, 30 Sep 2012 20:55:35 -0700 (PDT)
Local: Sun, Sep 30 2012 11:55 pm
Subject: Re: Pyglet example that uses GLSL and programmable pipeline

> > I just need OpenGL access - don't need anything else. Do you know if
> PyOpenGL
> > is still being maintained? I was unable to make it work on my Macbook.

> The last beta for PyOpenGL was uploaded to PyPI just over a month ago.

Thanks - I'll check it out.

Mahesh


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Adam Griffiths  
View profile  
 More options Oct 18 2012, 12:01 pm
From: Adam Griffiths <adam.lw.griffi...@gmail.com>
Date: Thu, 18 Oct 2012 09:01:23 -0700 (PDT)
Local: Thurs, Oct 18 2012 12:01 pm
Subject: Re: Pyglet example that uses GLSL and programmable pipeline

You still have full access to all the normal OpenGL calls.
I'm not using pyglet for anything but events and windowing at the moment.

Just do an:
from pyglet.gl import *

and BAM, all the normal gl* funcs are available.

Check this file for an example of rendering a cube.
https://github.com/adamlwgriffiths/PyGLy/blob/master/pygly/examples/c...

Only requires 2x 4x4 matrices (numpy arrays) to render.

This is used by this example:
https://github.com/adamlwgriffiths/PyGLy/blob/master/pygly/examples/c...

That being said, I've been reading that PyOpenGL has a number of
optimisations, such as Cython support built in.
Migration is trivial though because you can just import pyopengl's gl
commands and it should work from within Pyglet.
I haven't tried this myself, but it's what I've read.

Cheers,
Adam


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Richard Jones  
View profile  
 More options Oct 18 2012, 7:08 pm
From: Richard Jones <r1chardj0...@gmail.com>
Date: Fri, 19 Oct 2012 10:08:12 +1100
Local: Thurs, Oct 18 2012 7:08 pm
Subject: Re: Pyglet example that uses GLSL and programmable pipeline
On 19 October 2012 03:01, Adam Griffiths <adam.lw.griffi...@gmail.com> wrote:

> That being said, I've been reading that PyOpenGL has a number of
> optimisations, such as Cython support built in.

PyOpenGL does have an optional accelerator, but the main reason for
using it is the significantly nicer API. There's no need to sully your
application code with ctypes incantations! :-)

Having said that; if you're sticking to relatively simple OpenGL calls
then the small ctypes overhead is probably a reasonable tradeoff to
not needing the additional dependency.

     Richard


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tristam MacDonald  
View profile  
 More options Oct 18 2012, 7:22 pm
From: Tristam MacDonald <swiftco...@gmail.com>
Date: Thu, 18 Oct 2012 19:22:14 -0400
Local: Thurs, Oct 18 2012 7:22 pm
Subject: Re: Pyglet example that uses GLSL and programmable pipeline

On Thu, Oct 18, 2012 at 7:08 PM, Richard Jones <r1chardj0...@gmail.com>wrote:

> On 19 October 2012 03:01, Adam Griffiths <adam.lw.griffi...@gmail.com>
> wrote:
> > That being said, I've been reading that PyOpenGL has a number of
> > optimisations, such as Cython support built in.

> PyOpenGL does have an optional accelerator, but the main reason for
> using it is the significantly nicer API. There's no need to sully your
> application code with ctypes incantations! :-)

Unless you are using PyPy (like me!), in which case PyOpenGL also uses
ctypes exclusively...

--
Tristam MacDonald
Software Development Engineer, Amazon.com
http://swiftcoder.wordpress.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Richard Jones  
View profile  
 More options Oct 18 2012, 7:25 pm
From: Richard Jones <r1chardj0...@gmail.com>
Date: Fri, 19 Oct 2012 10:25:32 +1100
Local: Thurs, Oct 18 2012 7:25 pm
Subject: Re: Pyglet example that uses GLSL and programmable pipeline
On 19 October 2012 10:22, Tristam MacDonald <swiftco...@gmail.com> wrote:

> On Thu, Oct 18, 2012 at 7:08 PM, Richard Jones <r1chardj0...@gmail.com>
> wrote:
>> PyOpenGL does have an optional accelerator, but the main reason for
>> using it is the significantly nicer API. There's no need to sully your
>> application code with ctypes incantations! :-)

> Unless you are using PyPy (like me!), in which case PyOpenGL also uses
> ctypes exclusively...

But my point is that you as an application coder don't need to use
ctypes in *your* code.

    Richard


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tristam MacDonald  
View profile  
 More options Oct 18 2012, 7:28 pm
From: Tristam MacDonald <swiftco...@gmail.com>
Date: Thu, 18 Oct 2012 19:28:41 -0400
Local: Thurs, Oct 18 2012 7:28 pm
Subject: Re: Pyglet example that uses GLSL and programmable pipeline

On Thu, Oct 18, 2012 at 7:25 PM, Richard Jones <r1chardj0...@gmail.com>wrote:

> > Unless you are using PyPy (like me!), in which case PyOpenGL also uses
> > ctypes exclusively...

> But my point is that you as an application coder don't need to use
> ctypes in *your* code.

As far as I can tell, you do, because PyPy doesn't seem to support any of
the other methods to provide PyOpenGL with array data (i.e. NumPy).

--
Tristam MacDonald
Software Development Engineer, Amazon.com
http://swiftcoder.wordpress.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »