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/simple/main.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).
I talked about this here:
https://groups.google.com/forum/?fromgroups=#!topic/pyglet-users/Eonyq0tKR6s
Hope that helps =)
Cheers,
Adam
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
# position
self.posLoc = glGetAttribLocation(self.shader.handle, "pos")
pos_attrib_type = "%ig3f" % (self.posLoc)
# texcoord
self.texLoc = glGetAttribLocation(self.shader.handle, "tex")
tex_attrib_type = "%ig2f" % (self.texLoc)
# create vertex list
self.vertex_list = pyglet.graphics.vertex_list(
4,
(pos_attrib_type, (-0.5, -0.5, -1,
-0.5, 0.5, -1,
0.5, -0.5, -1,
0.5, 0.5, -1)),
(tex_attrib_type, (0, 0,
0, 1,
1, 0,
1, 1))
)
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
> 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.
On 19 October 2012 03:01, Adam Griffiths <adam.lw....@gmail.com> wrote:PyOpenGL does have an optional accelerator, but the main reason for
> That being said, I've been reading that PyOpenGL has a number of
> optimisations, such as Cython support built in.
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 usesBut my point is that you as an application coder don't need to use
> ctypes exclusively...
ctypes in *your* code.