#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>

typedef void* PtexTextureHandle;
typedef void* PtexFilterHandle;

typedef enum {
    PTEX_FILTER_POINT = 0,
    PTEX_FILTER_BILINEAR = 1,
    PTEX_FILTER_BOX = 2,
    PTEX_FILTER_GAUSSIAN = 3,
    PTEX_FILTER_BICUBIC = 4,
    PTEX_FILTER_BSPLINE = 5,
    PTEX_FILTER_CATMULLROM = 6,
    PTEX_FILTER_MITCHELL = 7
} PtexFilterType;

typedef struct {
    PtexFilterType filter;
    int32_t lerp;
    float sharpness;
    int32_t noedgeblend;
} PtexFilterOptions;

PtexTextureHandle ptex_texture_open(const char* filename, char** error_str);
void ptex_filter_release(PtexFilterHandle filter);
int32_t ptex_texture_num_channels(PtexTextureHandle texture);
PtexFilterHandle ptex_filter_create(PtexTextureHandle texture, const PtexFilterOptions* opts);


void ptex_filter_eval(
    PtexFilterHandle filter,
    float* result,
    int32_t first_channel,
    int32_t num_channels,
    int32_t face_id,
    float u, float v,
    float dudx, float dvdx,
    float dudy, float dvdy
);
void ptex_filter_release(PtexFilterHandle filter);


#ifdef __cplusplus
}
#endif
