Commits

Leonard Ritter committed de4ab83

added win32 support

Comments (0)

Files changed (2)

 *.avi
 *.glc
 *.mp4
+*.dll
 *.p3d
 debug.txt
 __pycache__
 
 from cffi import FFI
 import sys
+import os
 import traceback
 
 __all__ = [
 _ffi = FFI()
 _LIB = None
 
+IS_DARWIN = sys.platform == 'darwin'
+IS_WIN32 = sys.platform == 'win32'
+IS_LINUX = sys.platform == 'linux2'
+_THISDIR = os.path.abspath(os.path.dirname(__file__))  
+
 def load_lib(cdefs):
     global _LIB
     
-    #import time
-    #t = time.time()
+    global _LIB
     libname = 'openal'
+    if IS_WIN32:
+        local_dls = [
+            os.path.join(_THISDIR, 'soft_oal.dll'),
+            os.path.join(os.getcwd(), 'soft_oal.dll'), 
+        ]
+    elif IS_LINUX:
+        # use system library 
+        #local_dls = [os.path.join(_THISDIR, 'libSDL2.so')]
+        pass
+    elif IS_DARWIN:
+        local_dls = [os.path.join(_THISDIR, 'libopenal.dylib')]
+    else:
+        local_dls = []
+    
     _ffi.cdef(cdefs)
-    #print("AL cdefs loaded in {0}s".format(time.time() - t))
-    _LIB = _ffi.dlopen(libname)
-    return _LIB
+    
+    for dlpath in local_dls:
+        try:
+            _LIB = _ffi.dlopen(dlpath)
+            return _LIB
+        except OSError:
+            pass
+        except:
+            traceback.print_exc()
+    print("ERROR: unable to find openal library")
 
 def wrapstr(result):
     if result: