It seems like there is a lot of demand for this!
I think there are a lot of small implementation details to think about, to
make it easy for users. For example:
- Dealing with the Window.on_resize behavior if shaders are used.
- Should checking be done on OpenGL context versions before compiling a
shader? Maybe check against the the shader source's "#version" string if it
exists?
- Debug: should the shader class have it's own debug flag, or rely on
the pyglet OpenGL debug flag? Does it make sense to have it's own as GLSL
is it's own thing?
- Needs to be Python2.7/3 compatible. This should only require a few
small things, such as confirming the shader source is a byte string.
My current code has bind and unbind methods, but also has __enter__ and
__exit__ methods which just call bind and unbind. I like using it with a
"with" context:
shader_program = Program(vertex_source, fragment_source)
with shader_program:
do_stuff()
On Tuesday, February 16, 2016 at 11:16:20 PM UTC+9, Paulo Martins wrote:
>
> x2 I love the idea.
>
> terça-feira, 16 de Fevereiro de 2016 às 00:53:46 UTC, Benjamin Moran
> escreveu:
>>
>> Hi guys,
>>
>> How would everyone feel about adding a simple shader Class to the
>> graphics module? There have been a few go-to examples out there, such as
>> Tristan McDonald's popular one here:
>> https://swiftcoder.wordpress.com/2008/12/19/simple-glsl-wrapper-for-pyglet/
>> And Leonhard Vogt's framebuffer code that includes shaders here:
>>
>> https://leovt.wordpress.com/2015/10/04/render-to-texture-with-python-3-and-pyglet/
>> https://github.com/leovt/leovt/blob/master/framebuffer.py
>>
>> The reason I would like to see it included is because of the ctypes magic
>> being a bit of a blocker for new users. A simple class could handle this
>> for the users, and allow them to easily try more modern contexts with
>> pyglet.
>>
>> If I wrote this code, would it be accepted? I'm thinking a simple class,
>> plus basic example code. (Speaking of which, many of those examples need to
>> be updated!)
>>
>> -Ben
>>
>>
--
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.