On 02/16/2016 03:52 PM, Benjamin Moran wrote:
> 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.

>From a Python3 point of view, requiring bytes for textual data is a step
backwards. (And it is text - it has an encoding even if it's ASCII, it's
lines-oriented, there are no \0 bytes, etc.)

Since OpenGL 4.2, the official shader encoding is UTF-8, and before that
it was, I believe, ASCII which is a subset of UTF-8. So I think that if
unicode is passed in, it should be decoded with UTF-8 before passing it
to OpenGL.


> 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)
> 
> withshader_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/
>         
> <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://leovt.wordpress.com/2015/10/04/render-to-texture-with-python-3-and-pyglet/>
>         https://github.com/leovt/leovt/blob/master/framebuffer.py
>         <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]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> Visit this group at https://groups.google.com/group/pyglet-users.
> For more options, visit https://groups.google.com/d/optout.

-- 
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.

Reply via email to