/* This file was automatically generated.  Do not edit! */
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include "cute_png.h"
#include "sokol_gfx.h"
#include "gb_math.h"
typedef struct RayHitInfo RayHitInfo;
typedef gbVec3 Vector3;
struct RayHitInfo {
  bool hit;
  float distance;
  Vector3 position;
  Vector3 normal;
  Vector3 triangle[3];
};
typedef struct Ray Ray;
struct Ray {
  Vector3 position;
  Vector3 direction;
};
typedef struct Model Model;
typedef gbMat4 mat4;
typedef struct Mesh Mesh;
typedef enum {
  ZFORMAT,
  VFORMAT
}vertexFormat;
struct Mesh {
  int vertexCount;
  int triangleCount;
  int vertexStart;
  int vertexRange;
  int components;
  bool indexed;
  vertexFormat format;
  sg_bindings bind;
  uint32_t* map;
  float *vertices;
  uint8_t *colors;
  int8_t *uvs;
};
typedef struct Material Material;
typedef struct Shader Shader;
typedef struct Texture Texture;
struct Texture {
    sg_image img;
    unsigned int id;        // OpenGL texture id
    int width;              // Texture base width
    int height;             // Texture base height
    int mipmaps;            // Mipmap levels, 1 by default
    int format;             // Data format (PixelFormat type)
};
struct Shader {
  sg_shader_desc desc;
  sg_shader program;
  const char* name;
  bool dirty;
  Texture samplers;
  sg_range vs_uniforms;
  sg_range fs_uniforms;
};
typedef struct MaterialMap MaterialMap;
typedef Texture Texture2D;
typedef struct Color Color;
struct Color {
    unsigned char r;
    unsigned char g;
    unsigned char b;
    unsigned char a;
};
struct MaterialMap {
  Texture2D texture;
  Color color;
  float value;
};
struct Material {
  Shader shader;
  MaterialMap *maps;
  float params[4];
};
typedef struct BoneInfo BoneInfo;
struct BoneInfo {
    char name[32];          // Bone name
    int parent;             // Bone parent
};
typedef struct Transform Transform;
typedef gbVec4 Quaternion;
struct Transform {
    Vector3 translation;   
    Quaternion rotation;   
    Vector3 scale;         
};
struct Model {
  mat4 transform;
  int meshCount;
  int materialCount;
  Mesh *meshes;
  Material *materials;
  int *meshMaterial;
  int boneCount;
  BoneInfo *bones;
  Transform *bindPose;
};
RayHitInfo GetCollisionRayModel(Ray ray,Model model);
RayHitInfo GetCollisionRayMesh(Ray ray,Mesh *mesh);
RayHitInfo GetCollisionRayTriangle(Ray ray,Vector3 p1,Vector3 p2,Vector3 p3);
Vector3 Vector3Scale(Vector3 v,float scalar);
Vector3 Vector3Normalize(Vector3 v);
float Vector3DotProduct(Vector3 v1,Vector3 v2);
Vector3 Vector3CrossProduct(Vector3 v1,Vector3 v2);
Vector3 Vector3Subtract(Vector3 v1,Vector3 v2);
Vector3 Vector3Add(Vector3 v1,Vector3 v2);
typedef struct BoundingBox BoundingBox;
struct BoundingBox {
  Vector3 min;
  Vector3 max;
};
bool CheckCollisionRayBox(Ray ray,BoundingBox box);
bool gfx_setVertices(Mesh *mesh,void *vertices,int start,int last,bool separate,bool append,bool mapped,bool updated);
bool gfx_drawMesh(Mesh *mesh,mat4 *mvp);
void gfx_setMeshCullMode(sg_cull_mode mode);
void gfx_setWireframe(bool set);
int gfx_updatePipeline(Mesh *mesh);
void gfx_applyPipeline();
typedef struct gfx_state_t gfx_state_t;
typedef struct gfx_pipe_t gfx_pipe_t;
struct gfx_pipe_t {
  int id;
  sg_pipeline pipe;
  sg_pipeline_desc desc;
};
typedef gbVec4 vec4;
typedef struct gfx_stack_t gfx_stack_t;
struct gfx_stack_t {
  int mode;
  bool wireframe;
  vec4 color;
  int blendMode;
  int canvas;
  int shader;
  mat4 transform;
};
struct gfx_state_t {
  Shader* shader;

  gfx_pipe_t pipes[255];
  sg_pipeline_desc pipeNext; 
  int pipeCurrent; 

  sg_filter defaultFilter;
  sg_cull_mode meshCullMode;
  sg_compare_func depthMode;
  int blendMode;
  int alphaMode;
  
  bool depthWrite;
  bool wireframe;
  bool inPass;

  int currentVertexFormat;
  int passesPassed;
  int textureMemoryUsage;
  int meshMemoryUsage;
  int meshCount;
  int renderTextureCount;
  int textureCount;
  int frameBufferCounter;
  int pushed;
  int currentFontSize;
  int lineWidth;
  int pipelineCount;
  int pipelineSwitches;
  
  mat4 transform;
  vec4 scissor;

  gfx_stack_t stack[64];
  // int textureSizes[1024];
  // int meshSizes[1024];
  // tempDepthTextures = {}
  // renderTextures = {}
};
gfx_state_t *gfx_setupState();
extern sg_sampler defsmp;
extern sg_image deftex;
typedef struct Image Image;
struct Image {
    void *data;             // Image raw data
    int width;              // Image base width
    int height;             // Image base height
    int mipmaps;            // Mipmap levels, 1 by default
    int format;             // Data format (PixelFormat type)
};
Texture2D texFromData(Image image);
sg_image texFromMem(void *ptr,size_t size);
Image imgFromMem(void *ptr,size_t size);
void setCompressionPNG(int n);
void update_image(sg_image image,Image data);
uint32_t createRGBA(unsigned char *buffer);
int GetPixelDataSize(int width,int height,int format);
void SetPixelColor(void *dstPtr,Color color,int format);
Color GetPixelColor(void *srcPtr,int format);
typedef enum {
    PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha)
    PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA,    // 8*2 bpp (2 channels)
    PIXELFORMAT_UNCOMPRESSED_R5G6B5,        // 16 bpp
    PIXELFORMAT_UNCOMPRESSED_R8G8B8,        // 24 bpp
    PIXELFORMAT_UNCOMPRESSED_R5G5B5A1,      // 16 bpp (1 bit alpha)
    PIXELFORMAT_UNCOMPRESSED_R4G4B4A4,      // 16 bpp (4 bit alpha)
    PIXELFORMAT_UNCOMPRESSED_R8G8B8A8,      // 32 bpp
    PIXELFORMAT_UNCOMPRESSED_R32,           // 32 bpp (1 channel - float)
    PIXELFORMAT_UNCOMPRESSED_R32G32B32,     // 32*3 bpp (3 channels - float)
    PIXELFORMAT_UNCOMPRESSED_R32G32B32A32,  // 32*4 bpp (4 channels - float)
    PIXELFORMAT_COMPRESSED_DXT1_RGB,        // 4 bpp (no alpha)
    PIXELFORMAT_COMPRESSED_DXT1_RGBA,       // 4 bpp (1 bit alpha)
    PIXELFORMAT_COMPRESSED_DXT3_RGBA,       // 8 bpp
    PIXELFORMAT_COMPRESSED_DXT5_RGBA,       // 8 bpp
    PIXELFORMAT_COMPRESSED_ETC1_RGB,        // 4 bpp
    PIXELFORMAT_COMPRESSED_ETC2_RGB,        // 4 bpp
    PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA,   // 8 bpp
    PIXELFORMAT_COMPRESSED_PVRT_RGB,        // 4 bpp
    PIXELFORMAT_COMPRESSED_PVRT_RGBA,       // 4 bpp
    PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA,   // 8 bpp
    PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA    // 2 bpp
}PixelFormat;
typedef struct RenderTexture RenderTexture;
struct RenderTexture {
    unsigned int id;        // OpenGL framebuffer object id
    Texture color;        // Color buffer attachment texture
    Texture depth;          // Depth buffer attachment texture
};
typedef RenderTexture RenderTexture2D;
typedef uint8_t u8;
typedef struct { 
  float x,  y,  z, w;
  float u,  v;
  float r,  g,  b, a;
  float nx, ny, nz;
  u8 bi1,bi2,bi3,bi4;
  u8 bw1,bw2,bw3,bw4;
}a_vert;
typedef struct { 
  float x,  y,  z, w;
  float u,  v;
  float r,  g,  b, a;
  float nx, ny, nz;
}m_vert;
typedef struct vertexFormat_t vertexFormat_t;
typedef struct vertexComponent_t vertexComponent_t;
typedef enum {
  FLOAT,
  BYTE,
  HALF
}vertexFormatTypes;
struct vertexComponent_t {
  sg_vertex_format format;
  vertexFormatTypes type;
  int count;
};
struct vertexFormat_t {
  struct vertexComponent_t components[8];
  int comp;
  int stride;
  bool split;
};
typedef gbVec4 Vector4;
typedef gbVec3 vec3;
typedef gbVec2 Vector2;
typedef gbVec2 vec2;
typedef uintptr_t umm;
typedef uint16_t u16;
typedef uint32_t u32;
#define INTERFACE 0
