00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00023 #ifndef INCLUDE_3D_TEXTURE_H
00024 #define INCLUDE_3D_TEXTURE_H
00025
00026 #include "3d.h"
00027 #include "color.h"
00028
00029 typedef enum
00030 {
00031 texture1D = GL_TEXTURE_1D ,
00032 texture2D = GL_TEXTURE_2D,
00033 texture3D = GL_TEXTURE_3D
00034 } TextureTarget;
00035
00036 typedef enum
00037 {
00038 clamp = GL_CLAMP,
00039 repeat = GL_REPEAT
00040 } TextureWrap;
00041
00042 typedef enum
00043 {
00044 nearest = GL_NEAREST,
00045 linear = GL_LINEAR
00046 } TextureFilter;
00047
00048 typedef enum
00049 {
00050 modulate = GL_MODULATE,
00051 decal = GL_DECAL,
00052 blend = GL_BLEND,
00053 replace = GL_REPLACE,
00054 } TextureEnvMode;
00055
00063 class Texture
00064 {
00065 private:
00066 GLubyte *dataOut;
00067
00068 public:
00069 static MyList<Texture *> list;
00070 GLint id;
00071 MyString name;
00072 MyString source;
00073 BOOL useResizing;
00074 GLdouble xScale,yScale;
00075 int xSize,ySize;
00076 TextureTarget target;
00077 TextureWrap wrapT,wrapS;
00078 TextureFilter magFilter,minFilter;
00079 TextureEnvMode envMode;
00080 Color envColor;
00081 Color border;
00082
00083 public:
00084 static Texture * Find(char *name);
00085 static BOOL Delete(Texture *texture);
00086
00087 public:
00088 void VerifyId();
00089 void Config();
00090 void ConfigPixelStore();
00091 GLubyte * ConfigSize (int _xSize,int _ySize,BOOL allocate,BOOL resizeIt);
00092 void SetCoord(double x,double y);
00093 double GetXCoord(double x);
00094 double GetYCoord(double y);
00095 BOOL Delete();
00096
00097 public:
00098 Texture();
00099 ~Texture();
00100 void Zero();
00101 void operator =(Texture &src);
00102 operator GLuint () const { return id; }
00103
00104 BOOL FromNull();
00105 BOOL FromFile(char *_name,char *fileName,BOOL resizeIt=FALSE);
00106 BOOL FromBitmap(char *_name,char *fileName,BOOL resizeIt=FALSE);
00107 BOOL FromText(char *_name,char *text,COLORREF color,COLORREF background,int xFormat=0,int yFormat=0);
00108
00109 BOOL Begin(char *_name,int deltaX,int deltaY);
00110 BOOL SetPixel(int x,int y,byte r,byte g,byte b);
00111 BOOL GetPixel(int x,int y,byte &r,byte &g,byte &b);
00112 BOOL AddText(char *text,COLORREF color,COLORREF background,int xFormat=0,int yFormat=0);
00113 BOOL End();
00114 };
00115
00116 #endif