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 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).
On Tuesday, September 25, 2012 9:19:39 PM UTC+10, mv wrote:
> 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 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'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).
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
> 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).
> On Tuesday, September 25, 2012 9:19:39 PM UTC+10, mv wrote:
>> 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.
On Wednesday, September 26, 2012 1:40:02 PM UTC+10, Adam Griffiths wrote:
> 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'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).
> 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
> On Wednesday, September 26, 2012 1:33:39 PM UTC+10, Adam Griffiths wrote:
>> 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.
>> 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).
>> On Tuesday, September 25, 2012 9:19:39 PM UTC+10, mv wrote:
>>> 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.
On Sunday, September 30, 2012 1:21:32 PM UTC+10, mv wrote:
> 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:
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 :
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.
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.
> > 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.
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.
On Monday, October 1, 2012 12:42:56 PM UTC+10, mv wrote:
> 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 :
> 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.
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.
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...
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.