2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
#ifndef __GLTEXTURE_H
|
|
|
|
#define __GLTEXTURE_H
|
|
|
|
|
2014-05-11 19:47:54 +00:00
|
|
|
#ifdef LoadImage
|
|
|
|
#undef LoadImage
|
|
|
|
#endif
|
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
#define SHADED_TEXTURE -1
|
|
|
|
#define DIRECT_PALETTE -2
|
|
|
|
|
|
|
|
#include "tarray.h"
|
2016-09-04 11:14:14 +00:00
|
|
|
#include "gl/system/gl_interface.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
class FCanvasTexture;
|
|
|
|
class AActor;
|
2016-05-02 23:00:52 +00:00
|
|
|
typedef TMap<int, bool> SpriteHits;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-05-11 17:44:19 +00:00
|
|
|
// For error catching while changing parameters.
|
|
|
|
enum EInvalid
|
|
|
|
{
|
|
|
|
Invalid = 0
|
|
|
|
};
|
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
GLT_CLAMPX=1,
|
|
|
|
GLT_CLAMPY=2
|
|
|
|
};
|
|
|
|
|
|
|
|
class FHardwareTexture
|
|
|
|
{
|
2014-08-22 21:50:38 +00:00
|
|
|
public:
|
2013-06-23 07:49:34 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
MAX_TEXTURES = 16
|
|
|
|
};
|
|
|
|
|
2014-08-22 21:50:38 +00:00
|
|
|
private:
|
2013-06-23 07:49:34 +00:00
|
|
|
struct TranslatedTexture
|
|
|
|
{
|
|
|
|
unsigned int glTexID;
|
|
|
|
int translation;
|
2014-08-22 21:50:38 +00:00
|
|
|
bool mipmapped;
|
|
|
|
|
|
|
|
void Delete();
|
2013-06-23 07:49:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
static unsigned int lastbound[MAX_TEXTURES];
|
|
|
|
|
2016-09-04 11:14:14 +00:00
|
|
|
static int GetTexDimension(int value)
|
|
|
|
{
|
|
|
|
if (value > gl.max_texturesize) return gl.max_texturesize;
|
|
|
|
return value;
|
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-08-25 23:36:21 +00:00
|
|
|
static void InitGlobalState() { for (int i = 0; i < MAX_TEXTURES; i++) lastbound[i] = 0; }
|
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
short texwidth, texheight;
|
|
|
|
bool forcenocompression;
|
|
|
|
|
2014-08-22 21:50:38 +00:00
|
|
|
TranslatedTexture glDefTex;
|
|
|
|
TArray<TranslatedTexture> glTex_Translated;
|
2013-06-23 07:49:34 +00:00
|
|
|
unsigned int glDepthID; // only used by camera textures
|
|
|
|
|
2014-08-22 21:50:38 +00:00
|
|
|
TranslatedTexture * GetTexID(int translation);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
int GetDepthBuffer();
|
2014-04-15 09:59:41 +00:00
|
|
|
void Resize(int width, int height, unsigned char *src_data, unsigned char *dst_data);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
public:
|
2014-08-22 21:50:38 +00:00
|
|
|
FHardwareTexture(int w, int h, bool nocompress);
|
2013-06-23 07:49:34 +00:00
|
|
|
~FHardwareTexture();
|
|
|
|
|
|
|
|
static void Unbind(int texunit);
|
|
|
|
static void UnbindAll();
|
|
|
|
|
|
|
|
void BindToFrameBuffer();
|
|
|
|
|
2014-09-09 11:21:36 +00:00
|
|
|
unsigned int Bind(int texunit, int translation, bool needmipmap);
|
2016-08-17 21:18:47 +00:00
|
|
|
unsigned int CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation, const FString &name);
|
2016-11-28 01:32:57 +00:00
|
|
|
unsigned int GetTextureHandle(int translation);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
void Clean(bool all);
|
2016-05-02 23:00:52 +00:00
|
|
|
void CleanUnused(SpriteHits &usedtranslations);
|
2013-06-23 07:49:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|