/* Public domain */ struct sg_view; #define SG_TEXTURE_PROGS_MAX 64 #define SG_TEXTURE_SURFACES_MAX 1024 typedef struct sg_texture_surface { Uint flags; #define SG_TEXTURE_SURFACE_NODUP 0x01 /* Surface is not a copy */ #define SG_TEXTURE_SURFACE_SUPPRESS 0x02 /* Disabled */ #define SG_TEXTURE_SURFACE_SAVED (SG_TEXTURE_SURFACE_SUPPRESS) AG_Surface *su; /* Source surface */ AG_Rect rSrc; /* Source rectangle */ AG_Rect rDst; /* Destination rectangle */ AG_TAILQ_ENTRY(sg_texture_surface) surfaces; } SG_TextureSurface; typedef struct sg_texture_program { Uint flags; #define SG_TEXTURE_PROGRAM_SUPPRESS 0x01 /* Disabled */ #define SG_TEXTURE_PROGRAM_SAVED (SG_TEXTURE_PROGRAM_SUPPRESS) char progName[AG_OBJECT_NAME_MAX]; /* Program name */ SG_Program *prog; /* Resolved program */ AG_TAILQ_ENTRY(sg_texture_program) programs; } SG_TextureProgram; typedef struct sg_texture { struct ag_object _inherit; Uint flags; #define SG_TEXTURE_NOLIGHT 0x01 /* Disable lighting for this material */ #define SG_TEXTURE_SAVED (SG_TEXTURE_NOLIGHT) Uint w, h; /* Pixel dimensions */ /* For fixed lighting model */ M_Color emissive; /* Light emitted by surface (Ke) */ M_Color ambient; /* Ambient reflectance (Ka) */ M_Color diffuse; /* Diffuse reflectance (Kd) */ M_Color specular; /* Specular reflectance (Ks) */ M_Real shininess; /* Specular exponent */ AG_TAILQ_HEAD_(sg_texture_program) progs; /* Fragment shaders */ Uint nProgs; AG_Surface *surface; /* Rendered surface */ Uint nSurfaces; AG_TAILQ_HEAD_(sg_texture_surface) surfaces; /* Input surface(s) */ AG_TAILQ_HEAD_(sg_view_texture) vtex; /* Active hardware textures */ } SG_Texture; __BEGIN_DECLS extern AG_ObjectClass sgTextureClass; SG_Texture *SG_TextureNew(void *, const char *); int SG_TextureCompile(SG_Texture *); void SG_TextureBind(SG_Texture *, struct sg_view *); void SG_TextureUnbind(SG_Texture *, struct sg_view *); SG_TextureProgram *SG_TextureAddProgram(SG_Texture *, SG_Program *); void SG_TextureDelProgram(SG_Texture *, SG_TextureProgram *); SG_TextureSurface *SG_TextureAddSurface(SG_Texture *, const AG_Surface *); SG_TextureSurface *SG_TextureAddSurfaceNODUP(SG_Texture *, AG_Surface *); void SG_TextureDelSurface(SG_Texture *, SG_TextureSurface *); __END_DECLS