# Path: pyoptix/enums.py
# class FilterMode:
#     nearest = RTfiltermode.RT_FILTER_NEAREST
#     linear = RTfiltermode.RT_FILTER_LINEAR
#     none = RTfiltermode.RT_FILTER_NONE
# 
# def convert_filtering_mode(string):
#     if isinstance(string, str) and string.lower() in FILTERING_STRING_TO_OPTIX_ENUM:
#         return FILTERING_STRING_TO_OPTIX_ENUM[string]
#     else:
#         return string
# 
# def convert_wrap_mode(string):
#     if isinstance(string, str) and string.lower() in WRAP_STRING_TO_OPTIX_ENUM:
#         return WRAP_STRING_TO_OPTIX_ENUM[string]
#     else:
#         return string
# 
# def convert_read_mode(string):
#     if isinstance(string, str) and string.lower() in READ_STRING_TO_OPTIX_ENUM:
#         return READ_STRING_TO_OPTIX_ENUM[string]
#     else:
#         return string
# 
# def convert_indexing_mode(string):
#     if isinstance(string, str) and string.lower() in INDEXING_STRING_TO_OPTIX_ENUM:
#         return INDEXING_STRING_TO_OPTIX_ENUM[string]
#     else:
#         return string
# 
# Path: pyoptix/context.py
# def current_context():
#     return _context_stack[-1]
# 
# Path: pyoptix/mixins/bindless.py
# class BindlessMixin(object):
#     def __init__(self):
#         self._bindless = False
# 
#     @property
#     def bindless(self):
#         return self._bindless
# 
#     @bindless.setter
#     def bindless(self, value):
#         value = bool(value)
#         self._safe_native.auto_destroy = not value
#         self._bindless = value
# 
# Path: pyoptix/mixins/destroyable.py
# class DestroyableObject(object):
#     def __init__(self, native):
#         self._native = native
# 
#     @property
#     def _safe_native(self):
#         if not self._native.is_destroyed:
#             return self._native
#         else:
#             raise RuntimeError('Underlying OptiX object was destroyed before.')
# 
# Path: pyoptix/mixins/hascontext.py
# class HasContextMixin(object):
#     def __init__(self, context):
#         self._context_ref = weakref.ref(context)
# 
#     @property
#     def _safe_context(self):
#         ctx = self._context_ref()
#         if ctx is not None:
#             return ctx
#         else:
#             raise RuntimeError('Context of this object is no longer valid')


from pyoptix._driver import OPTIX_VERSION
from pyoptix.enums import FilterMode, convert_filtering_mode, convert_wrap_mode, convert_read_mode, \
    convert_indexing_mode
from pyoptix.context import current_context
from pyoptix.mixins.bindless import BindlessMixin
from pyoptix.mixins.destroyable import DestroyableObject
from pyoptix.mixins.hascontext import HasContextMixin


class TextureSampler(HasContextMixin, DestroyableObject, BindlessMixin):
    def __init__(self, buffer, wrap_mode=None, indexing_mode=None,
                 read_mode=None, filter_mode=None, max_anisotropy=1):
        HasContextMixin.__init__(self, current_context())
        DestroyableObject.__init__(self, self._safe_context._create_texture_sampler())

# Path: pyoptix/enums.py
# class FilterMode:
#     nearest = RTfiltermode.RT_FILTER_NEAREST
#     linear = RTfiltermode.RT_FILTER_LINEAR
#     none = RTfiltermode.RT_FILTER_NONE
# 
# def convert_filtering_mode(string):
#     if isinstance(string, str) and string.lower() in FILTERING_STRING_TO_OPTIX_ENUM:
#         return FILTERING_STRING_TO_OPTIX_ENUM[string]
#     else:
#         return string
# 
# def convert_wrap_mode(string):
#     if isinstance(string, str) and string.lower() in WRAP_STRING_TO_OPTIX_ENUM:
#         return WRAP_STRING_TO_OPTIX_ENUM[string]
#     else:
#         return string
# 
# def convert_read_mode(string):
#     if isinstance(string, str) and string.lower() in READ_STRING_TO_OPTIX_ENUM:
#         return READ_STRING_TO_OPTIX_ENUM[string]
#     else:
#         return string
# 
# def convert_indexing_mode(string):
#     if isinstance(string, str) and string.lower() in INDEXING_STRING_TO_OPTIX_ENUM:
#         return INDEXING_STRING_TO_OPTIX_ENUM[string]
#     else:
#         return string
# 
# Path: pyoptix/context.py
# def current_context():
#     return _context_stack[-1]
# 
# Path: pyoptix/mixins/bindless.py
# class BindlessMixin(object):
#     def __init__(self):
#         self._bindless = False
# 
#     @property
#     def bindless(self):
#         return self._bindless
# 
#     @bindless.setter
#     def bindless(self, value):
#         value = bool(value)
#         self._safe_native.auto_destroy = not value
#         self._bindless = value
# 
# Path: pyoptix/mixins/destroyable.py
# class DestroyableObject(object):
#     def __init__(self, native):
#         self._native = native
# 
#     @property
#     def _safe_native(self):
#         if not self._native.is_destroyed:
#             return self._native
#         else:
#             raise RuntimeError('Underlying OptiX object was destroyed before.')
# 
# Path: pyoptix/mixins/hascontext.py
# class HasContextMixin(object):
#     def __init__(self, context):
#         self._context_ref = weakref.ref(context)
# 
#     @property
#     def _safe_context(self):
#         ctx = self._context_ref()
#         if ctx is not None:
#             return ctx
#         else:
#             raise RuntimeError('Context of this object is no longer valid')


# Path: pyoptix/texture_sampler.py
from pyoptix._driver import OPTIX_VERSION
from pyoptix.enums import FilterMode, convert_filtering_mode, convert_wrap_mode, convert_read_mode, \
    convert_indexing_mode
from pyoptix.context import current_context
from pyoptix.mixins.bindless import BindlessMixin
from pyoptix.mixins.destroyable import DestroyableObject
from pyoptix.mixins.hascontext import HasContextMixin



class TextureSampler(HasContextMixin, DestroyableObject, BindlessMixin):
    def __init__(self, buffer, wrap_mode=None, indexing_mode=None,
                 read_mode=None, filter_mode=None, max_anisotropy=1):
        HasContextMixin.__init__(self, current_context())
        DestroyableObject.__init__(self, self._safe_context._create_texture_sampler())

        BindlessMixin.__init__(self)