Re: [pygame] extending mask module?

2008-12-02 Thread René Dudfield
brilliant :)

On Wed, Dec 3, 2008 at 2:54 PM, Michael George <[EMAIL PROTECTED]> wrote:
> Yep :)  I heeded your advice.
>
> --Mike
>
> René Dudfield wrote:
>>
>> ps.  are there tests and docs for the new function too?
>>
>>
>> On Wed, Dec 3, 2008 at 2:51 PM, Michael George <[EMAIL PROTECTED]>
>> wrote:
>>
>>>
>>> Nirav Patel wrote:
>>>

 I've still got checking in convolution on my to do list.  I've been
 busy with school, but winter break is coming up soon.


>>>
>>> Sorry, I didn't mean to be a pest.  I thought it had been lost in the
>>> shuffle :)
>>>
>>>
>>> --Mike
>>>
>>>
>
>


Re: [pygame] extending mask module?

2008-12-02 Thread Michael George

Yep :)  I heeded your advice.

--Mike

René Dudfield wrote:

ps.  are there tests and docs for the new function too?


On Wed, Dec 3, 2008 at 2:51 PM, Michael George <[EMAIL PROTECTED]> wrote:
  

Nirav Patel wrote:


I've still got checking in convolution on my to do list.  I've been
busy with school, but winter break is coming up soon.

  

Sorry, I didn't mean to be a pest.  I thought it had been lost in the
shuffle :)


--Mike






Re: [pygame] extending mask module?

2008-12-02 Thread Michael George

Nirav Patel wrote:


The mask module is kind of strange because the Python additions were
all after the fact.  bitmask.c and bitmask.h were/are a separate C
library that is just included in Pygame.  That explains the exported
functions in bitmask.  I'm not clear on exactly what you wanted to do,
but it seems that the PyMaskObject and PyMask_Type definitions should
be in pygame.h instead of mask.c.  Then it would just be a matter of
including pygame.h and bitmask.h in what you are writing.

  
I think it's slightly more complicated than that, because I think I need 
to use the CObject api to share the PyMask_Type with the other 
extension.  However, I'm working on moving that stuff into mask.h, and 
I'll submit a patch when I get it working.


--Mike


Re: [pygame] extending mask module?

2008-12-02 Thread René Dudfield
ps.  are there tests and docs for the new function too?


On Wed, Dec 3, 2008 at 2:51 PM, Michael George <[EMAIL PROTECTED]> wrote:
> Nirav Patel wrote:
>>
>> I've still got checking in convolution on my to do list.  I've been
>> busy with school, but winter break is coming up soon.
>>
>
> Sorry, I didn't mean to be a pest.  I thought it had been lost in the
> shuffle :)
>
>
> --Mike
>


Re: [pygame] extending mask module?

2008-12-02 Thread Michael George

Nirav Patel wrote:

I've still got checking in convolution on my to do list.  I've been
busy with school, but winter break is coming up soon.
  
Sorry, I didn't mean to be a pest.  I thought it had been lost in the 
shuffle :)



--Mike


Re: [pygame] extending mask module?

2008-12-02 Thread Michael George
The part I was and am still a bit confused about is name clashes.  If I 
understand correctly, python extension modules are supposed to only 
export the initmodule method in order to avoid name clashes, which is 
why the docs say everything should be static.  But if bitmask is linked 
in to the module, then won't it's functions be exported?  If not, then 
is it possible for me to call them, or do I need to link bitmask into my 
code as well?  And how is bitmask different than SDL in terms of how 
it's linked, if at all?


Sorry, I feel like I'm saying a bunch of nonsense, but I'm having a hard 
time making sense of all this dynamic linking stuff.


What I'm doing now is adding a CObject to the mask module for the 
PyMask_Type, and then compiling my code against bitmask.h (which I'm 
leaving as-is) and mask.h (which looks like some of the other header 
files, and exports a C API with a bunch of #defines).  So I'm assuming 
I'll need to use CObjects to get at stuff in mask.c (the Type in 
particular), but I can link directly to the stuff in bitmask.


On an unrelated note, I'm looking at font.h as an example for exporting 
the api, and I was wondering in the import_pygame_font why the code does 
a memcpy instead of just changing the PyFONT_C_API pointer.  Isn't there 
a danger of the memcpy stomping on something else, since it's copying 3 
things into a 1-element array?


--Mike

Lenard Lindstrom wrote:

Hi Michael,

bitmask.c is statically linked to mask.c as an object file. On Windows 
the distutils package ensures only the initmask function is exported 
as an entry point into the mask.pyd DLL. Unix dynamic libraries may be 
more liberal as to what is exported, but Python will only directly 
call the module initialization function, so no problem.


Setup.in controls extension builds. This is like a make file. Each 
extension module, like mask, has its own line, or dependency entry. A 
new C module can be added to an extension module by adding its source 
file to an extension module entry. Be sure to run config.py afterward 
to build the Setup file used by setup.py.


Lenard

Michael George wrote:


Greetings,


[snip]



I'd be happy to spend some time and submit a patch, but I'm not quite 
sure how it should work.  Should mask.c access the bitmask.c 
functions through the exported function table?  Should mask.c just 
#include bitmask.c?  Any thoughts?


[from another post in this thread]
>
>  Understanding the build system(s) is a bit daunting.


--Mike







Re: [pygame] extending mask module?

2008-12-02 Thread Nirav Patel
I've still got checking in convolution on my to do list.  I've been
busy with school, but winter break is coming up soon.

The mask module is kind of strange because the Python additions were
all after the fact.  bitmask.c and bitmask.h were/are a separate C
library that is just included in Pygame.  That explains the exported
functions in bitmask.  I'm not clear on exactly what you wanted to do,
but it seems that the PyMaskObject and PyMask_Type definitions should
be in pygame.h instead of mask.c.  Then it would just be a matter of
including pygame.h and bitmask.h in what you are writing.

On Tue, Dec 2, 2008 at 9:32 PM, Michael George <[EMAIL PROTECTED]> wrote:
> One of them is the convolution code that I actually posted a while back but
> hasn't been checked in.
>
> Another is a method to find the closest position to a given one with the
> corresponding bit unset.  That seems much less generally useful.
>
> I'm also working on some more complicated code to support drag and drop of
> stretched rope-like objects.  Those are likely to be very special purpose,
> and rather complicated.  I think they'll need to be in C to be fast enough
> for me though.
>
> Is the only problem with non-static methods name clashes?  Because I'm not
> sure what the difference is between, for example, the functions in SDL which
> are visible, and the functions in bitmask.c.  If that's the case, then I can
> just expose the PyMask_AsBitmap and PyMask_Type through a C Object, and link
> my code against bitmask.  Understanding the build system(s) is a bit
> daunting.
>
> --Mike
>
> René Dudfield wrote:
>>
>> Hi,
>>
>> Maybe submit your extensions for inclusion?  That might be the
>> easiest.  What extensions are they?
>>
>> It'd be nice for any fix ups to mask... it's got a few issues.
>> However making a C API for it is not a priority at the moment...
>> Marcus has done some work on it for pgreloaded (see a branch in svn).
>>
>> http://www.seul.org/viewcvs/viewcvs.cgi/branches/pgreloaded/src/mask/?root=PyGame
>>
>> If you'd like to submit changes for making a C API similar to how it's
>> done in pygame for other modules, that'd be cool too.
>>
>> An issue with making functions static is that then they can have
>> issues being multi threaded if they release the python GIL.
>>
>> ... so I think it'd be best to submit your extensions into pygame I
>> think.  Since there's no real C API at the moment.  Then we can make
>> sure your extensions are in pyreloaded too.
>>
>>
>>
>> cheers,
>>
>>
>> On Wed, Dec 3, 2008 at 12:36 PM, Michael George <[EMAIL PROTECTED]>
>> wrote:
>>
>>>
>>> Greetings,
>>>
>>> I have some extensions to the mask module for my game, and I'm trying to
>>> figure out how to build/package them.  For the sake of getting it working
>>> I've just hacked them into the pygame source and been building a custom
>>> pygame, but obviously that's not a good solution.
>>>
>>> However as I'm trying to tease it out of there I'm coming across some
>>> confusion.  It looks to me like the mask module violates the "everything
>>> static except initmodule" rule, because the functions in bitmask.c are
>>> exported, and AFAICT bitmask.c is linked into the mask module.
>>>
>>> Part of the reason this is a problem is because the mask module doesn't
>>> seem
>>> to export any kind of C API like the other modules do.  It would be
>>> useful
>>> to me if the bitmask_* functions were exported.
>>>
>>> I'd be happy to spend some time and submit a patch, but I'm not quite
>>> sure
>>> how it should work.  Should mask.c access the bitmask.c functions through
>>> the exported function table?  Should mask.c just #include bitmask.c?  Any
>>> thoughts?
>>>
>>> --Mike
>>>
>>>
>
>


Re: [pygame] extending mask module?

2008-12-02 Thread Lenard Lindstrom

Hi Michael,

bitmask.c is statically linked to mask.c as an object file. On Windows 
the distutils package ensures only the initmask function is exported as 
an entry point into the mask.pyd DLL. Unix dynamic libraries may be more 
liberal as to what is exported, but Python will only directly call the 
module initialization function, so no problem.


Setup.in controls extension builds. This is like a make file. Each 
extension module, like mask, has its own line, or dependency entry. A 
new C module can be added to an extension module by adding its source 
file to an extension module entry. Be sure to run config.py afterward to 
build the Setup file used by setup.py.


Lenard

Michael George wrote:


Greetings,


[snip]



I'd be happy to spend some time and submit a patch, but I'm not quite 
sure how it should work.  Should mask.c access the bitmask.c functions 
through the exported function table?  Should mask.c just #include 
bitmask.c?  Any thoughts?


[from another post in this thread]
>
>  Understanding the build system(s) is a bit daunting.


--Mike



--
Lenard Lindstrom
<[EMAIL PROTECTED]>



Re: [pygame] extending mask module?

2008-12-02 Thread Michael George
One of them is the convolution code that I actually posted a while back 
but hasn't been checked in.


Another is a method to find the closest position to a given one with the 
corresponding bit unset.  That seems much less generally useful.


I'm also working on some more complicated code to support drag and drop 
of stretched rope-like objects.  Those are likely to be very special 
purpose, and rather complicated.  I think they'll need to be in C to be 
fast enough for me though.


Is the only problem with non-static methods name clashes?  Because I'm 
not sure what the difference is between, for example, the functions in 
SDL which are visible, and the functions in bitmask.c.  If that's the 
case, then I can just expose the PyMask_AsBitmap and PyMask_Type through 
a C Object, and link my code against bitmask.  Understanding the build 
system(s) is a bit daunting.


--Mike

René Dudfield wrote:

Hi,

Maybe submit your extensions for inclusion?  That might be the
easiest.  What extensions are they?

It'd be nice for any fix ups to mask... it's got a few issues.
However making a C API for it is not a priority at the moment...
Marcus has done some work on it for pgreloaded (see a branch in svn).
http://www.seul.org/viewcvs/viewcvs.cgi/branches/pgreloaded/src/mask/?root=PyGame

If you'd like to submit changes for making a C API similar to how it's
done in pygame for other modules, that'd be cool too.

An issue with making functions static is that then they can have
issues being multi threaded if they release the python GIL.

... so I think it'd be best to submit your extensions into pygame I
think.  Since there's no real C API at the moment.  Then we can make
sure your extensions are in pyreloaded too.



cheers,


On Wed, Dec 3, 2008 at 12:36 PM, Michael George <[EMAIL PROTECTED]> wrote:
  

Greetings,

I have some extensions to the mask module for my game, and I'm trying to
figure out how to build/package them.  For the sake of getting it working
I've just hacked them into the pygame source and been building a custom
pygame, but obviously that's not a good solution.

However as I'm trying to tease it out of there I'm coming across some
confusion.  It looks to me like the mask module violates the "everything
static except initmodule" rule, because the functions in bitmask.c are
exported, and AFAICT bitmask.c is linked into the mask module.

Part of the reason this is a problem is because the mask module doesn't seem
to export any kind of C API like the other modules do.  It would be useful
to me if the bitmask_* functions were exported.

I'd be happy to spend some time and submit a patch, but I'm not quite sure
how it should work.  Should mask.c access the bitmask.c functions through
the exported function table?  Should mask.c just #include bitmask.c?  Any
thoughts?

--Mike






Re: [pygame] Clock.tick() freeze.

2008-12-02 Thread René Dudfield
hi,

I'd suggest trying out a newer pygame... there were a few 64bit fixes
made since 1.7.1

cu,



On Tue, Dec 2, 2008 at 9:40 PM, Peter Gebauer
<[EMAIL PROTECTED]> wrote:
> Hi!
>
> I've tried googling, but came up with nothing. I'm using the Debian testing
> (AMD64) version of pygame (1.7.1release-4.2), sometimes when Clock.tick() is
> called the entire Python process will hang, only SIGKILL will actually stop
> it. Anybody recognize this bug? Is it fixed in later versions?
>
> /Peter
>
>


Re: [pygame] extending mask module?

2008-12-02 Thread René Dudfield
Hi,

Maybe submit your extensions for inclusion?  That might be the
easiest.  What extensions are they?

It'd be nice for any fix ups to mask... it's got a few issues.
However making a C API for it is not a priority at the moment...
Marcus has done some work on it for pgreloaded (see a branch in svn).
http://www.seul.org/viewcvs/viewcvs.cgi/branches/pgreloaded/src/mask/?root=PyGame

If you'd like to submit changes for making a C API similar to how it's
done in pygame for other modules, that'd be cool too.

An issue with making functions static is that then they can have
issues being multi threaded if they release the python GIL.

... so I think it'd be best to submit your extensions into pygame I
think.  Since there's no real C API at the moment.  Then we can make
sure your extensions are in pyreloaded too.



cheers,


On Wed, Dec 3, 2008 at 12:36 PM, Michael George <[EMAIL PROTECTED]> wrote:
> Greetings,
>
> I have some extensions to the mask module for my game, and I'm trying to
> figure out how to build/package them.  For the sake of getting it working
> I've just hacked them into the pygame source and been building a custom
> pygame, but obviously that's not a good solution.
>
> However as I'm trying to tease it out of there I'm coming across some
> confusion.  It looks to me like the mask module violates the "everything
> static except initmodule" rule, because the functions in bitmask.c are
> exported, and AFAICT bitmask.c is linked into the mask module.
>
> Part of the reason this is a problem is because the mask module doesn't seem
> to export any kind of C API like the other modules do.  It would be useful
> to me if the bitmask_* functions were exported.
>
> I'd be happy to spend some time and submit a patch, but I'm not quite sure
> how it should work.  Should mask.c access the bitmask.c functions through
> the exported function table?  Should mask.c just #include bitmask.c?  Any
> thoughts?
>
> --Mike
>


[pygame] extending mask module?

2008-12-02 Thread Michael George

Greetings,

I have some extensions to the mask module for my game, and I'm trying to 
figure out how to build/package them.  For the sake of getting it 
working I've just hacked them into the pygame source and been building a 
custom pygame, but obviously that's not a good solution.


However as I'm trying to tease it out of there I'm coming across some 
confusion.  It looks to me like the mask module violates the "everything 
static except initmodule" rule, because the functions in bitmask.c are 
exported, and AFAICT bitmask.c is linked into the mask module.


Part of the reason this is a problem is because the mask module doesn't 
seem to export any kind of C API like the other modules do.  It would be 
useful to me if the bitmask_* functions were exported.


I'd be happy to spend some time and submit a patch, but I'm not quite 
sure how it should work.  Should mask.c access the bitmask.c functions 
through the exported function table?  Should mask.c just #include 
bitmask.c?  Any thoughts?


--Mike


RE: [pygame] Getting input from command line

2008-12-02 Thread Fiona Burrows

> The msvcrt module has Windows console I/O routines, including kbhit() 
> (Section 36.2.2 in the Python 2.5 docs). I don't know of any platform 
> independent console routines in Python.
> 
> -- 
> Lenard Lindstrom
> <[EMAIL PROTECTED]>



Yeah it's a shame.

For all who replied. Thanks a lot!
However, I have just rethought how my program works and decided on a slightly 
less user friendly, but more cross platform solution using raw_input(). It 
seems to work pretty well on initial tests.

Thanks,
Fiona
<>

Re: [pygame] Getting input from command line

2008-12-02 Thread Lenard Lindstrom

Fiona Burrows wrote:



Michael wrote:

On Monday 01 December 2008 12:57:15 Fiona Burrows wrote:
  

I know this isn't directly related to PyGame but I figured there were
worse places to ask a question like this



This page is your friend:

http://openbookproject.net/py4fun/lode/lode.html#auto2

In fact the entire site is quite fun...

   http://openbookproject.net/py4fun/

... but with a name like that it would be.

Specifically this file shows you what you need to do:
http://openbookproject.net//py4fun/lode/ttyLinux.py

Specifically you have to change the console mode to spit out characters at
a time, you can then play with them and when your program exits change it
back again.


Michael.
  
That looks extremely useful, thank you! Unfortunately it's Unix-like 
only. (At least that's what the Python docs say about termios.)
Is there a Windows alternative that you know of? I could just check 
what the OS is and use the specific routines for the platform.


Thanks!
Fiona
--
*Sputnik Internet **¤
* Web & Graphic Design, Marketing & Illustration
30 King Street
Manchester
M2 6AZ

Tel 0870 742 5959
E-mail: [EMAIL PROTECTED] 
Web: http://www.sputnikinternet.com 
**

The msvcrt module has Windows console I/O routines, including kbhit() 
(Section 36.2.2 in the Python 2.5 docs). I don't know of any platform 
independent console routines in Python.


--
Lenard Lindstrom
<[EMAIL PROTECTED]>



Re: [pygame] Getting input from command line

2008-12-02 Thread LuNan Sheng
Maybe this package would be helpful:

http://effbot.org/downloads/#console


[pygame] Clock.tick() freeze.

2008-12-02 Thread Peter Gebauer
Hi!

I've tried googling, but came up with nothing. I'm using the Debian testing 
(AMD64) version of pygame (1.7.1release-4.2), sometimes when Clock.tick() is 
called the entire Python process will hang, only SIGKILL will actually stop 
it. Anybody recognize this bug? Is it fixed in later versions?

/Peter



Re: [pygame] Getting input from command line

2008-12-02 Thread Fiona Burrows



Michael wrote:

On Monday 01 December 2008 12:57:15 Fiona Burrows wrote:
  

I know this isn't directly related to PyGame but I figured there were
worse places to ask a question like this



This page is your friend:

http://openbookproject.net/py4fun/lode/lode.html#auto2

In fact the entire site is quite fun...

   http://openbookproject.net/py4fun/

... but with a name like that it would be.

Specifically this file shows you what you need to do:
http://openbookproject.net//py4fun/lode/ttyLinux.py

Specifically you have to change the console mode to spit out characters at
a time, you can then play with them and when your program exits change it
back again.


Michael.
  
That looks extremely useful, thank you! Unfortunately it's Unix-like 
only. (At least that's what the Python docs say about termios.)
Is there a Windows alternative that you know of? I could just check what 
the OS is and use the specific routines for the platform.


Thanks!
Fiona
--
*Sputnik Internet **¤
* Web & Graphic Design, Marketing & Illustration
30 King Street
Manchester
M2 6AZ

Tel 0870 742 5959
E-mail: [EMAIL PROTECTED] 
Web: http://www.sputnikinternet.com 
**