- Main Page
- Classes
- Files

- File List
- File Members

# flTexture.h

Go to the documentation of this file.

    00001 // Funclib Texture v1.0.0
    00002 //
    00003 // This module contains functions for dealing with textures and palettes.
    00004 // Required for almost any 2d/3d graphical application.
    00005 // This module requires FL_GRAPHICS to be fully functional.
    00006 //
    00007 // Contributor(s): Flatmush
    00008
    00009
    00010
    00011 #ifndef FLTEXTURE_H
    00012 #define FLTEXTURE_H
    00013
    00014 #include "flGlobal.h"
    00015
    00016 #if FL_TEXTURE != 0
    00017
    00018 #ifdef __cplusplus
    00019 extern "C" {
    00020 #endif
    00021
    00022 typedef struct {
    00023      u32   palEntries;
    00024      char* palData;
    00025      u8    palPixelFormat;
    00026      bool  palGlobal;
    00027 } Palette;
    00028
    00029 typedef struct {
    00030      u32      texWidth;
    00031      u32      texHeight;
    00032      u32      texDataWidth;
    00033      u32      texDataHeight;
    00034
    00035      u32      texStride;
    00036      char*    texData;
    00037      char*    texMipData[8];
    00038      Palette* texPalette;
    00039
    00040      u32      texUseCount;
    00041      u8       texPixelFormat;
    00042      bool     texSwizzled;
    00043      u8       texMipMaps;
    00044      #if FL_TEXTURE_PRESERVENONALPHA != 0
    00045      bool     texAlpha;
    00046      #endif
    00047 } Texture;
    00048
    00049 extern void* texBound;
    00050 extern void* palBound;
    00051
    00052 extern void        texInit();
    00053
    00054 extern Texture*    texLoad(char* inPath);
    00055 extern bool        texSave(Texture* inTex, char* inPath);
    00056 extern char*       texPath(Texture* inTex);
    00057
    00058 extern Texture*    texCreate(u32 inWidth, u32 inHeight, u8 inPixelFormat);
    00059 extern Texture*    texCreateBlank(u32 inWidth, u32 inHeight, u8 inPixelFormat);
    00060
    00061 #if FL_GRAPHICS != 0
    00062 extern bool        texSwizzle(Texture* inTex);
    00063 extern bool        texUnswizzle(Texture* inTex);
    00064 #endif
    00065
    00066 extern void        texBind(Texture* inTex);
    00067 extern void        texFree(void* inTex);
    00068
    00069 #if FL_GRAPHICS != 0
    00070 extern u8          texBPP(Texture* inTex);
    00071 #else
    00072 #define texBPP(inTex) (graphicsPixelFormatBPP(inTex->texPixelFormat))
    00073 #endif
    00074 #define texDataSize(inTex) (((inTex)->texDataWidth * (inTex)->texDataHeight * texBPP(inTex)) >> 3)
    00075 extern u8          texPalettized(Texture* inTex);
    00076
    00077 extern int         texMipMap(Texture* inTex, u8 inLevel);
    00078 extern bool        texMipMapAdd(Texture* inTex);
    00079
    00080
    00081 extern Palette*    palCreate(u32 inEntries, u8 inFormat, bool inGlobal);
    00082 extern void        palBind(Palette* inPalette);
    00083 extern void        palFree(Palette* inPalette);
    00084 extern u8          palBPP(Palette* inPal);
    00085 extern s32         palClosestColor(Palette* inPal, u32 inColor);
    00086
    00087 extern Palette*    palCreateGrayscaleT8();
    00088 extern Palette*    palCreateGrayscaleT4();
    00089 extern Palette*    palCreateMonoT4(u32 inForeColor, u32 inBackColor);
    00090 extern Palette*    palCreateDefaultColorT4();
    00091 extern Palette*    palGrayscaleT8();
    00092 extern Palette*    palGrayscaleT4();
    00093 extern Palette*    palDefaultColorT4();
    00094
    00095 #if FL_GRAPHICS != 0
    00096 extern Texture*    texScreenshot();
    00097 #endif
    00098
    00099 #if FL_MEMORY_VMEM != 0
    00100 extern bool        texMoveVMem(Texture* inTex);
    00101 extern bool        palMoveVMem(Palette* inPal);
    00102 #endif
    00103
    00104 extern u32         texPixel(Texture* inTex, int inX, int inY);
    00105 //extern void        texAddMagMap(Texture* inTex);
    00106
    00107
    00108 #ifdef __cplusplus
    00109 }
    00110 #endif
    00111
    00112 #endif
    00113
    00114 #endif