Re: Tristan McDonald's Shader.py

2020-04-22 Thread Nicky Mac
Wow! That fixed it!  (I had already changed 'basestring' missing from
Python 3  to 'str').
Huge thanks Greg.


Virus-free.
www.avg.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Wed, 22 Apr 2020 at 06:02, Greg Ewing 
wrote:

> On 22/04/20 12:31 am, Nicky Mac wrote:
> >  src = (c_char_p * count)(*strings)
> > TypeError: bytes or integer address expected instead of str instance
>
> It looks like this was designed for Python 2. You may
> need to encode the strings to bytes, e.g.
>
> src_bytes = [s.encode() for s in strings]
> src = (c_char_p * count)(*src_bytes)
>
> --
> Greg
>
> --
> 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 pyglet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pyglet-users/0db03378-8d12-8b58-9257-b146a536d0b9%40canterbury.ac.nz
> .
>


-- 
Nick "Mac" McElwaine

-- 
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 pyglet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyglet-users/CAKafoGDVT-eMD%3D9BLk8jK8GjEB%2B_UpC6%2BRdRk_viAdtyZj7uWQ%40mail.gmail.com.


Re: Tristan McDonald's Shader.py

2020-04-21 Thread Greg Ewing

On 22/04/20 12:31 am, Nicky Mac wrote:

 src = (c_char_p * count)(*strings)
TypeError: bytes or integer address expected instead of str instance


It looks like this was designed for Python 2. You may
need to encode the strings to bytes, e.g.

   src_bytes = [s.encode() for s in strings]
   src = (c_char_p * count)(*src_bytes)

--
Greg

--
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 pyglet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyglet-users/0db03378-8d12-8b58-9257-b146a536d0b9%40canterbury.ac.nz.


Re: Tristan McDonald's Shader.py

2020-04-21 Thread Nicky Mac
thanks Claudio,
I had already imported the ctypes but I still get:
src = (c_char_p * count)(*strings)
TypeError: bytes or integer address expected instead of str instance

and the next line of code looks awkward:
glShaderSource(shader, count, cast(pointer(src),
POINTER(POINTER(c_char))), None)

On 20/04/2020, claudio canepa  wrote:
> From a comment in the page:
>
> There’s a missing import in the shader module.
>
> File “/shader.py”, line 40, in createShader
> src = (c_char_p * count)(*strings)
> NameError: global name ‘c_char_p’ is not defined
>
> Resolved by adding
>
> from ctypes import *
>
> On Mon, Apr 20, 2020 at 12:22 PM Nicky Mac  wrote:
>
>>
>>
>> On Monday, April 20, 2020 at 10:25:59 AM UTC+1, Nicky Mac wrote:
>>>
>>> the splendid glsl  examples in pythonstuff.org  require the use of
>>> Tristan
>>> McDonald's  Shader.py
>>> obtainable from :
>>> https://swiftcoder.wordpress.com/2008/12/19/simple-glsl-wrapper-for-pyglet/
>>> 
>>>
>>>  but the code there is badly formatted and after unscrambling it I can't
>>> get it to run.
>>>  Is there somewhere else I can acquire this code?
>>>
>>
>> Ok I've now found it, but when used errors:
>>
>>   File "C:/Python/Python36/Dhruve and me/Pyglet\shader.py", line 40, in
>> createShader
>> src = (c_char_p * count)(*strings)
>> NameError: name 'c_char_p' is not defined
>>
>> --
>> 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 pyglet-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/pyglet-users/3c81c9be-9a13-4d10-8aae-32b34a0275ae%40googlegroups.com
>> 
>> .
>>
>
> --
> 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 pyglet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pyglet-users/CAP3BN9VAkymNHTqNBGxYWb-gob%3DGqgWLgZ%3DHQLp%3DKxFL5vUT%2Bg%40mail.gmail.com.
>


-- 
Nick "Mac" McElwaine

-- 
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 pyglet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyglet-users/CAKafoGCJtCkFSQUL0Z1o8popJfvYa-4r1rmCQuYMrJ_f3bxcrQ%40mail.gmail.com.