import ctypes
import os
import platform
import sdl2

native = ctypes.cdll.LoadLibrary(
    os.path.dirname(os.path.realpath(__file__)) + '/helpers.' +
    ('dylib' if platform.system() == 'Darwin' else 'so'))

native.render_tensor.argtypes = [
    ctypes.c_void_p, ctypes.c_int, ctypes.c_int, ctypes.c_int
]
native.render_tensor.restype = ctypes.POINTER(sdl2.surface.SDL_Surface)
render_tensor = native.render_tensor

native.equirectangular.argtypes = [
    ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int
]
equirectangular = native.equirectangular

native.colourize_heightmap.argtypes = [
    ctypes.POINTER(ctypes.c_double),
    ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int
]
colourize_heightmap = native.colourize_heightmap

native.landmass_steradians.argtypes = [
    ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int, ctypes.c_int,
    ctypes.c_int
]
native.landmass_steradians.restype = ctypes.c_double
landmass_steradians = native.landmass_steradians