SBSPSS/Utils/MapEdit/TexCache.h

68 lines
1.6 KiB
C
Raw Normal View History

2000-10-27 20:18:30 +02:00
/*********************/
/*** Texture Cache ***/
/*********************/
#ifndef __TEXCACHE_HEADER__
#define __TEXCACHE_HEADER__
#include "stdafx.h"
#include <gl\gl.h>
#include <gl\glu.h>
#include <Vector>
2000-11-24 23:34:20 +01:00
#include "Utils.h"
2000-11-30 23:17:55 +01:00
#include "List.h"
2001-02-06 23:25:39 +01:00
#include <misc.hpp>
2000-10-27 20:18:30 +02:00
2000-11-22 23:08:47 +01:00
struct sRGBData
{
int Width;
int Height;
2000-11-24 23:34:20 +01:00
u8 *RGB;
2000-11-22 23:08:47 +01:00
};
2000-10-27 20:18:30 +02:00
struct sTex
{
2001-02-07 19:46:59 +01:00
GString Filename;
2001-02-06 23:25:39 +01:00
GString Name;
2000-10-27 20:18:30 +02:00
GLuint TexID;
2000-11-30 23:17:55 +01:00
int TexWidth,TexHeight;
2001-03-22 21:49:58 +01:00
float ScaleU,ScaleV; // For wrong size textures
2000-12-29 23:20:38 +01:00
bool Loaded;
2000-11-30 23:17:55 +01:00
2001-03-22 21:49:58 +01:00
bool operator==(sTex const &v1) {return (Filename==v1.Filename);}
2000-10-27 20:18:30 +02:00
};
2000-11-28 00:07:07 +01:00
const RGBQUAD BlankRGB={255,0,255};
2000-10-27 20:18:30 +02:00
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
class CTexCache
{
public:
2000-11-30 23:17:55 +01:00
int GetTexIdx(sTex &Tex) {return(TexList.Find(Tex));}
2000-11-22 23:08:47 +01:00
2001-03-22 21:49:58 +01:00
int ProcessTexture(const char *Name,sRGBData *RGBData=0);
2000-11-22 23:08:47 +01:00
void Purge();
2001-02-06 23:25:39 +01:00
bool LoadBMP(const char *Filename,sRGBData &RGBData);
2000-11-22 23:08:47 +01:00
void FreeBMP(sRGBData &RGBData);
2000-11-30 23:17:55 +01:00
void FixBMP(sRGBData &RGBData);
2000-12-29 23:20:38 +01:00
bool IsSizeOk(int Size);
2000-11-30 23:17:55 +01:00
int AlignSize(int Size);
2000-11-22 23:08:47 +01:00
void LoadTex(sTex &ThisTex,sRGBData *TexData);
2000-11-30 23:17:55 +01:00
2000-10-27 22:21:39 +02:00
sTex &GetTex(int Id) {return(TexList[Id]);}
2001-02-07 19:46:59 +01:00
GString &GetTexFilename(int Id) {return(TexList[Id].Filename);}
2001-02-06 23:25:39 +01:00
GString &GetTexName(int Id) {return(TexList[Id].Name);}
2000-10-27 22:21:39 +02:00
GLuint GetTexGLId(int Id) {return(TexList[Id].TexID);}
2000-10-27 20:18:30 +02:00
2000-11-30 23:17:55 +01:00
CList<sTex> TexList;
2000-10-27 20:18:30 +02:00
};
/*****************************************************************************/
#endif