LCOV - code coverage report
Current view: top level - engine/render - texture.h (source / functions) Coverage Total Hit
Test: Libprimis Test Coverage Lines: 6.7 % 15 1
Test Date: 2025-04-16 12:09:02 Functions: 16.7 % 6 1

            Line data    Source code
       1              : #ifndef TEXTURE_H_
       2              : #define TEXTURE_H_
       3              : 
       4              : extern int hwtexsize, hwcubetexsize, hwmaxaniso, maxtexsize, hwtexunits, hwvtexunits;
       5              : 
       6              : extern Texture *textureload(const char *name, int clamp = 0, bool mipit = true, bool msg = true);
       7              : extern bool floatformat(GLenum format);
       8              : extern void loadshaders();
       9              : extern void createtexture(int tnum, int w, int h, const void *pixels, int clamp, int filter, GLenum component = GL_RGB, GLenum target = GL_TEXTURE_2D, int pw = 0, int ph = 0, int pitch = 0, bool resize = true, GLenum format = GL_FALSE, bool swizzle = false);
      10              : extern void create3dtexture(int tnum, int w, int h, int d, const void *pixels, int clamp, int filter, GLenum component = GL_RGB, GLenum target = GL_TEXTURE_3D, bool swizzle = false);
      11              : extern bool reloadtexture(const char *name);
      12              : extern void clearslots();
      13              : extern void compacteditvslots();
      14              : extern void compactvslots(cube *c, int n = 8);
      15              : extern void compactvslot(int &index);
      16              : extern void compactvslot(VSlot &vs);
      17              : extern void reloadtextures();
      18              : extern void cleanuptextures();
      19              : extern bool settexture(const char *name, int clamp = 0);
      20              : 
      21              : //for imagedata manipulation
      22              : extern void scaletexture(const uchar * RESTRICT src, uint sw, uint sh, uint bpp, uint pitch, uchar * RESTRICT dst, uint dw, uint dh);
      23              : extern void reorienttexture(const uchar * RESTRICT src, int sw, int sh, int bpp, int stride, uchar * RESTRICT dst, bool flipx, bool flipy, bool swapxy);
      24              : extern GLenum texformat(int bpp);
      25              : 
      26              : struct Slot;
      27              : struct VSlot;
      28              : 
      29              : // management of texture slots
      30              : // each texture slot can have multiple texture frames, of which currently only the first is used
      31              : // additional frames can be used for various shaders
      32              : 
      33              : struct Texture
      34              : {
      35              :     enum
      36              :     {
      37              :         IMAGE      = 0,
      38              :         TYPE       = 0xFF,
      39              : 
      40              :         STUB       = 1<<8,
      41              :         TRANSIENT  = 1<<9,
      42              :         ALPHA      = 1<<11,
      43              :         MIRROR     = 1<<12
      44              :     };
      45              : 
      46              :     char *name;
      47              :     int type, w, h, xs, ys, bpp, clamp;
      48              :     bool mipmap, canreduce;
      49              :     GLuint id;
      50              :     uchar *alphamask;
      51              : 
      52            1 :     Texture() : alphamask(nullptr) {}
      53              :     const uchar * loadalphamask();
      54              :     float ratio() const;
      55              :     bool reload(); //if the texture does not have a valid GL texture, attempts to reload it
      56              : 
      57              : };
      58              : 
      59              : enum TextureLayers
      60              : {
      61              :     Tex_Diffuse = 0,
      62              :     Tex_Normal,
      63              :     Tex_Glow,
      64              : 
      65              :     Tex_Spec,
      66              :     Tex_Depth,
      67              :     Tex_Alpha,
      68              :     Tex_Unknown,
      69              : };
      70              : 
      71              : struct MatSlot final : Slot, VSlot
      72              : {
      73              :     MatSlot();
      74              : 
      75            0 :     int type() const override final
      76              :     {
      77            0 :         return SlotType_Material;
      78              :     }
      79              :     const char *name() const override final;
      80              : 
      81            0 :     VSlot &emptyvslot() override final
      82              :     {
      83            0 :         return *this;
      84              :     }
      85              : 
      86            0 :     int cancombine(int) const override final
      87              :     {
      88            0 :         return -1;
      89              :     }
      90              : 
      91            0 :     void reset()
      92              :     {
      93            0 :         Slot::reset();
      94            0 :         VSlot::reset();
      95            0 :     }
      96              : 
      97            0 :     void cleanup()
      98              :     {
      99            0 :         Slot::cleanup();
     100            0 :         VSlot::cleanup();
     101            0 :     }
     102              : };
     103              : 
     104              : struct texrotation
     105              : {
     106              :     bool flipx, flipy, swapxy;
     107              : };
     108              : 
     109              : extern const std::array<texrotation, 8> texrotations;
     110              : extern Texture *notexture;
     111              : extern int maxvsuniforms, maxfsuniforms;
     112              : 
     113              : extern SDL_Surface *loadsurface(const char *name);
     114              : 
     115              : extern MatSlot &lookupmaterialslot(int slot, bool load = true);
     116              : 
     117              : extern void mergevslot(VSlot &dst, const VSlot &src, const VSlot &delta);
     118              : extern void packvslot(std::vector<uchar> &buf, const VSlot &src);
     119              : 
     120              : extern Slot dummyslot;
     121              : extern VSlot dummyvslot;
     122              : extern DecalSlot dummydecalslot;
     123              : 
     124              : #endif
        

Generated by: LCOV version 2.0-1