Re: My idea to encourage people to use Python and make more games with it
@pauliyobo, that wasn't exactly helpful at all.
@Amit, here is how you use FMOD in Python using ctypes:
# initialize the system object
fmod=ctypes.CDLL("fmod64.dll")
system=ctypes.c_void_p()
# all functions return an FMOD_RESULT. So we save that to a variable
# there are helpers for this, we'll do that in a moment
res = fmod.FMOD_System_Create(ctypes.byref(system))
if res!=0:
# some error occurred.
# our system object is now created, but not initialized. Initialize it with 4093 maximum voices, no flags, and no extra driver data. res=fmod.FMOD_System_Init(system, 4093, 0, None) if res!=0: # some error occurred. # Now we can wrap the error checking in an FMOD callback # This takes a bit of ctypes magic though # declare the FMOD_ERRORCALLBACK_INFO structure class FMOD_ERRORCALLBACK_INFO (ctypes.Structure): pass # declare its fields FMOD_ERRORCALLBACK_INFO._fields_=[ ("result", ctypes.c_int), ("instancetype", ctypes.c_void_p), ("instance", ctypes.c_void_p), ("functionname", ctypes.c_char_p), ("functionparams", ctypes.c_char_p) ] # declare the callback ErrorCallback = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_int, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p) def SystemErrorCallback(system, type, commanddata1, commanddata2, userdata): if type==0x00000080: # error callback info=ctypes.cast(commanddata1, FMOD_ERRORCALLBACK_INFO) if info.result!=0: # error occurred, handle it here callback=ErrorCallback(SystemErrorCallback) res=fmod.FMOD_System_SetCallback(system, ctypes.byref(callback), 0x00000080) if res!=0: # an error occurred setting the callback and it wasn't set
That's generally how you use it. It looks really complicated (and I haven't tested the error callback code above yet), but it gets much easier after a while. Declaring enumerations also isn't very hard with the Aenum package. The difficulty is declaring float* arrays ahead-of-time.
-- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector