Re: [pygame] GLSL in Pygame on a Mac

2006-12-17 Thread Brandon N

Thanks, that seems to be the solution.

Interestingly, perhaps this is a Python feature that I am unaware of  
but this seems strange to me:


 import ctypes
 ctypes.util.find_library
Traceback (most recent call last):
  File stdin, line 1, in ?
AttributeError: 'module' object has no attribute 'util'
 from ctypes.util import find_library


Is there something unique about the util module in ctypes?

Thanks again!

Cheers,
  Brandon

On Dec 16, 2006, at 10:54 PM, Alex Holkner wrote:


Brandon N wrote:


Hello,
  I recently came across the GLSL example at: http:// 
www.pygame.org/ wiki/GLSLExample


  This would appear to meet my needs for using GLSL from within   
pygame, but I cannot seem to get it working. First, as I am not   
really familiar with the Python wrapper of OpenGL, is that  
example  Mac friendly? If so, is there a reason why it would fail  
on my  machine when I have OpenGL installed?


My exception (which just shows that neither loading method is  
working):

OSError: dlopen(libGL.so, 6): image not found

at file root
  in shader_test.py at line 14
function LoadLibrary
  in __init__.py at line 395
function __init__
  in __init__.py at line 312

I am not really certain where to go with this, so thanks for any   
assistance!


The example is Linux-centric, trying to load libGL.so.  On Mac, the  
functions are in the OpenGL.framework.  Replace the line  `gl =  
cdll.LoadLibrary('libGL.so')` with


import ctypes.util
path = ctypes.util.find_library('OpenGL')# finds the  
absolute path to the framework

gl = cdll.LoadLibrary(path)

Cheers
Alex.




Re: [pygame] GLSL in Pygame on a Mac

2006-12-17 Thread Alex Holkner

Brandon N wrote:


Thanks, that seems to be the solution.

Interestingly, perhaps this is a Python feature that I am unaware of  
but this seems strange to me:


 import ctypes
 ctypes.util.find_library
Traceback (most recent call last):
  File stdin, line 1, in ?
AttributeError: 'module' object has no attribute 'util'
 from ctypes.util import find_library


Is there something unique about the util module in ctypes?

No, this is normal for Python -- you must import a module to use it (not 
just its package).  Pygame actually does a trick with its sub-modules, 
which is probably what's causing the confusion.  For example, you can do


   import pygame
   pygame.display.something(...)

This works because in pygame/__init__.py is something along the lines of:

   import pygame.display

which brings display into the module namespace.  Most packages I know 
of don't do this trick -- you must import the packages you want explicitly.


Cheers
Alex.



Re: [pygame] GLSL in Pygame on a Mac

2006-12-17 Thread Brandon N
Interesting, I believe I have had this expressed to me before though  
it clearly has not sunken in.


Thanks for the clarification.

Cheers,
  Brandon

On Dec 17, 2006, at 8:55 AM, Alex Holkner wrote:


Brandon N wrote:


Thanks, that seems to be the solution.

Interestingly, perhaps this is a Python feature that I am unaware  
of  but this seems strange to me:


 import ctypes
 ctypes.util.find_library
Traceback (most recent call last):
  File stdin, line 1, in ?
AttributeError: 'module' object has no attribute 'util'
 from ctypes.util import find_library


Is there something unique about the util module in ctypes?

No, this is normal for Python -- you must import a module to use it  
(not just its package).  Pygame actually does a trick with its sub- 
modules, which is probably what's causing the confusion.  For  
example, you can do


   import pygame
   pygame.display.something(...)

This works because in pygame/__init__.py is something along the  
lines of:


   import pygame.display

which brings display into the module namespace.  Most packages I  
know of don't do this trick -- you must import the packages you  
want explicitly.


Cheers
Alex.





[pygame] GLSL in Pygame on a Mac

2006-12-16 Thread Brandon N

Hello,
  I recently came across the GLSL example at: http://www.pygame.org/ 
wiki/GLSLExample


  This would appear to meet my needs for using GLSL from within  
pygame, but I cannot seem to get it working. First, as I am not  
really familiar with the Python wrapper of OpenGL, is that example  
Mac friendly? If so, is there a reason why it would fail on my  
machine when I have OpenGL installed?


My exception (which just shows that neither loading method is working):
OSError: dlopen(libGL.so, 6): image not found

at file root
  in shader_test.py at line 14
function LoadLibrary
  in __init__.py at line 395
function __init__
  in __init__.py at line 312

I am not really certain where to go with this, so thanks for any  
assistance!


Cheers,
 Brandon


Re: [pygame] GLSL in Pygame on a Mac

2006-12-16 Thread Alex Holkner

Brandon N wrote:


Hello,
  I recently came across the GLSL example at: http://www.pygame.org/ 
wiki/GLSLExample


  This would appear to meet my needs for using GLSL from within  
pygame, but I cannot seem to get it working. First, as I am not  
really familiar with the Python wrapper of OpenGL, is that example  
Mac friendly? If so, is there a reason why it would fail on my  
machine when I have OpenGL installed?


My exception (which just shows that neither loading method is working):
OSError: dlopen(libGL.so, 6): image not found

at file root
  in shader_test.py at line 14
function LoadLibrary
  in __init__.py at line 395
function __init__
  in __init__.py at line 312

I am not really certain where to go with this, so thanks for any  
assistance!


The example is Linux-centric, trying to load libGL.so.  On Mac, the 
functions are in the OpenGL.framework.  Replace the line  `gl = 
cdll.LoadLibrary('libGL.so')` with


import ctypes.util
path = ctypes.util.find_library('OpenGL')# finds the absolute 
path to the framework

gl = cdll.LoadLibrary(path)

Cheers
Alex.