Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PipelinedTexture Class Reference

#include <pipelined_texture.h>

Inheritance diagram for PipelinedTexture:
Texture

Public Member Functions

bool operator== (const Texture &b)
 
bool operator< (const Texture &b)
 
virtual TextureClone ()
 
virtual TextureOriginal ()
 
 PipelinedTexture ()
 
 PipelinedTexture (unsigned int width, unsigned int height, unsigned char *current, unsigned char *last)
 
 ~PipelinedTexture ()
 
unsigned char * beginMutate ()
 
void Swap ()
 
void endMutate (int xoffset, int yoffset, int width, int height)
 
void MakeBothActive ()
 
void MakeActive ()
 Binds the texture in the GFX library. More...
 
void MakeLastActive ()
 
- Public Member Functions inherited from Texture
void FileNotFound (const std::string &)
 
GFXBOOL checkold (const std::string &s, bool shared, std::string &hashname)
 Returns if this texture is actually already loaded. More...
 
void modold (const std::string &s, bool shared, std::string &hashname)
 
void setold ()
 Loads the old texture. More...
 
bool checkbad (const string &s)
 
void setbad (const string &s)
 
void InitTexture ()
 Inits the class with default values. More...
 
int Bind (Texture *other, int maxdimension=65536, GFXBOOL detailtexture=GFXFALSE)
 Binds this texture to the same name as the given texture - for multipart textures. More...
 
 Texture (int stage=0, enum FILTER mipmap=MIPMAP, enum TEXTURE_TARGET target=TEXTURE2D, enum TEXTURE_IMAGE_TARGET imagetarget=TEXTURE_2D, enum ADDRESSMODE address_mode=DEFAULT_ADDRESS_MODE)
 Creates an unbounded texture. Set data and dimensions before binding. Or explicitly load a file. More...
 
 Texture (const char *, const char *, int stage=0, enum FILTER mipmap=MIPMAP, enum TEXTURE_TARGET target=TEXTURE2D, enum TEXTURE_IMAGE_TARGET imagetarget=TEXTURE_2D, float alpha=1, int zeroval=0, GFXBOOL force=GFXFALSE, int max_dimension_size=65536, GFXBOOL detail_texture=GFXFALSE, GFXBOOL nocache=false, enum ADDRESSMODE address_mode=DEFAULT_ADDRESS_MODE, Texture *main=0)
 Creates a texture with a single bitmap as color data and another grayscale .bmp as alpha data. More...
 
 Texture (const char *FileName, int stage=0, enum FILTER mipmap=MIPMAP, enum TEXTURE_TARGET target=TEXTURE2D, enum TEXTURE_IMAGE_TARGET imagetarget=TEXTURE_2D, GFXBOOL force=GFXFALSE, int max_dimension_size=65536, GFXBOOL detail_texture=GFXFALSE, GFXBOOL nocache=false, enum ADDRESSMODE address_mode=DEFAULT_ADDRESS_MODE, Texture *main=0)
 Creates a texture with only color data as a single bitmap. More...
 
 Texture (VSFileSystem::VSFile *f, int stage=0, enum FILTER mipmap=MIPMAP, enum TEXTURE_TARGET target=TEXTURE2D, enum TEXTURE_IMAGE_TARGET imagetarget=TEXTURE_2D, GFXBOOL force=GFXFALSE, int max_dimension_size=65536, GFXBOOL detail_texture=GFXFALSE, GFXBOOL nocache=false, enum ADDRESSMODE address_mode=DEFAULT_ADDRESS_MODE, Texture *main=0)
 
void Load (const char *, const char *, int stage=0, enum FILTER mipmap=MIPMAP, enum TEXTURE_TARGET target=TEXTURE2D, enum TEXTURE_IMAGE_TARGET imagetarget=TEXTURE_2D, float alpha=1, int zeroval=0, GFXBOOL force=GFXFALSE, int max_dimension_size=65536, GFXBOOL detail_texture=GFXFALSE, GFXBOOL nocache=false, enum ADDRESSMODE address_mode=DEFAULT_ADDRESS_MODE, Texture *main=0)
 
void Load (const char *FileName, int stage=0, enum FILTER mipmap=MIPMAP, enum TEXTURE_TARGET target=TEXTURE2D, enum TEXTURE_IMAGE_TARGET imagetarget=TEXTURE_2D, GFXBOOL force=GFXFALSE, int max_dimension_size=65536, GFXBOOL detail_texture=GFXFALSE, GFXBOOL nocache=false, enum ADDRESSMODE address_mode=DEFAULT_ADDRESS_MODE, Texture *main=0)
 
virtual const TextureOriginal () const
 
virtual ~Texture ()
 Texture copy constructor that increases appropriate refcounts. More...
 
virtual unsigned int numFrames () const
 
virtual double curTime () const
 
virtual void setTime (double tim)
 
virtual float framesPerSecond () const
 
virtual unsigned int numLayers () const
 
virtual unsigned int numPasses () const
 
virtual bool canMultiPass () const
 
virtual bool constFrameRate () const
 
int getStage () const
 
int getFilter () const
 
int getTarget () const
 
int getImageTarget () const
 
bool operator< (const Texture &b) const
 A way to sort the texture by the original address (to make sure like textures stick togehter. More...
 
bool operator== (const Texture &b) const
 A way to test if the texture is equal to another based on original values. More...
 
void setReference (Texture *other)
 Make this instance a reference of "other". More...
 
virtual void MakeActive (int stage)
 
virtual void MakeActive (int stage, int pass)
 
virtual bool SetupPass (int pass, const enum BLENDFUNC src, const enum BLENDFUNC dst)
 
virtual bool SetupPass (int pass, int stage, const enum BLENDFUNC src, const enum BLENDFUNC dst)
 
virtual bool LoadSuccess ()
 If the texture has loaded properly returns true. More...
 
virtual void Prioritize (float)
 Changes priority of texture. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Texture
static TextureExists (std::string s)
 Whether or not the string exists as a texture. More...
 
static TextureExists (std::string s, std::string a)
 Whether or not the color and alpha data already exist. More...
 
- Public Attributes inherited from Texture
StringPool::Reference texfilename
 The file name used to load this texture. More...
 
enum FILTER ismipmapped
 the filter mode of this texture More...
 
unsigned char * data
 The data of this texture (used in between functions, deleted) More...
 
int name
 The GFXname of this texture. More...
 
int stage
 The multitexture stage of this texture. More...
 
Vector mintcoord
 The minimum/maximum texturing coordinates for this texture (have in mind that it is not always enforce, ie. for meshes) (i=s, j=t, k=u) More...
 
Vector maxtcoord
 
Textureoriginal
 The original data that would represent this texture. More...
 
bool bound
 For re-biding. More...
 
uint boundSizeX
 
uint boundSizeY
 
VSImageMode boundMode
 
int refcount
 The number of references on the original data. More...
 
enum TEXTURE_TARGET texture_target
 The target this will go to (cubemap or otherwise) More...
 
enum TEXTURE_IMAGE_TARGET image_target
 
enum ADDRESSMODE address_mode
 The address mode being used with this texture. More...
 
- Protected Member Functions inherited from Texture
int Bind (int maxdimension, GFXBOOL detailtexture)
 Binds this texture to GFX library. More...
 
void UnBind ()
 UnBinds from GFX library. More...
 
void Transfer (int maxdimension, GFXBOOL detailtexture)
 Transfers this texture to GFX library. More...
 

Detailed Description

Definition at line 6 of file pipelined_texture.h.

Constructor & Destructor Documentation

PipelinedTexture::PipelinedTexture ( )

Definition at line 3 of file pipelined_texture.cpp.

Referenced by Clone().

3 : Texture() {}
PipelinedTexture::PipelinedTexture ( unsigned int  width,
unsigned int  height,
unsigned char *  current,
unsigned char *  last 
)

Definition at line 24 of file pipelined_texture.cpp.

References BILINEAR, Texture::data, GFXCreateTexture(), GFXTransferTexture(), height, Texture::image_target, Texture::ismipmapped, Texture::name, Texture::original, PALETTE8, Texture::refcount, RGB32, RGBA32, Texture::stage, TEXTURE2D, TEXTURE_2D, Texture::texture_target, and width.

25  : Texture()
26 {
27  this->sizeX = width;
28  this->sizeY = height;
29  this->clone = 0;
31  mode = _24BITRGBA;
32  data = new unsigned char[4*width*height];
33  stage = 0;
34  original = NULL;
35  refcount = 0;
38  GFXCreateTexture( sizeX, sizeY, (mode == _24BITRGBA) ? RGBA32 : ( (mode == _8BIT) ? PALETTE8 : RGB32 ), &name, NULL,
39  (stage == 1) ? 0 : 1 );
40  GFXCreateTexture( sizeX,
41  sizeY,
42  (mode == _24BITRGBA) ? RGBA32 : ( (mode == _8BIT) ? PALETTE8 : RGB32 ),
43  &this->current,
44  NULL,
45  (stage == 1) ? 0 : 1 );
46  GFXCreateTexture( sizeX,
47  sizeY,
48  (mode == _24BITRGBA) ? RGBA32 : ( (mode == _8BIT) ? PALETTE8 : RGB32 ),
49  &this->last,
50  NULL,
51  (stage == 1) ? 0 : 1 );
52  if (current)
53  GFXTransferTexture( current, this->current, sizeX, sizeY,
54  (mode == _24BITRGBA) ? RGBA32 : ( (mode == _8BIT) ? PALETTE8 : RGB32 ), TEXTURE_2D );
55  if (last)
56  GFXTransferTexture( last, this->last, sizeX, sizeY,
57  (mode == _24BITRGBA) ? RGBA32 : ( (mode == _8BIT) ? PALETTE8 : RGB32 ), TEXTURE_2D );
58 }
PipelinedTexture::~PipelinedTexture ( )

Definition at line 108 of file pipelined_texture.cpp.

References GFXDeleteTexture(), and Texture::name.

109 {
110  if (clone < 2)
111  GFXDeleteTexture( current );
112  if (!clone)
113  GFXDeleteTexture( last );
115 }

Member Function Documentation

unsigned char * PipelinedTexture::beginMutate ( )

Definition at line 4 of file pipelined_texture.cpp.

References Texture::data.

5 {
6  return data;
7 }
Texture * PipelinedTexture::Clone ( )
virtual

Reimplemented from Texture.

Definition at line 87 of file pipelined_texture.cpp.

References BILINEAR, Texture::data, GFXCreateTexture(), GFXTransferTexture(), VsnetOSS::memcpy(), Texture::name, PALETTE8, PipelinedTexture(), RGB32, RGBA32, sizeof(), Texture::stage, TEXTURE2D, and TEXTURE_2D.

88 {
89  PipelinedTexture *retval = new PipelinedTexture();
90  *retval = *this;
91  retval->last = last;
92  retval->current = current;
93  retval->clone = 2;
94  int bpp = (mode == _24BITRGBA) ? 4 : ( (mode == _8BIT) ? 1 : 3 );
95  retval->data = new unsigned char[sizeX*sizeY*bpp];
96  memcpy( retval->data, data, bpp*sizeof (unsigned char)*sizeX*sizeY );
97  GFXCreateTexture( sizeX, sizeY, (mode == _24BITRGBA) ? RGBA32 : ( (mode == _8BIT) ? PALETTE8 : RGB32 ), &name, NULL,
98  (stage == 1) ? 0 : 1, BILINEAR, TEXTURE2D );
99  GFXTransferTexture( retval->data,
100  name,
101  sizeX,
102  sizeY,
103  (mode == _24BITRGBA) ? RGBA32 : ( (mode == _8BIT) ? PALETTE8 : RGB32 ),
104  TEXTURE_2D );
105  return retval;
106 }
void PipelinedTexture::endMutate ( int  xoffset,
int  yoffset,
int  width,
int  height 
)

Definition at line 19 of file pipelined_texture.cpp.

References Texture::data, GFXTransferSubTexture(), Texture::name, and TEXTURE_2D.

20 {
21  GFXTransferSubTexture( data, name, xoffset, yoffset, width, height, TEXTURE_2D );
22 }
void PipelinedTexture::MakeActive ( )
virtual

Binds the texture in the GFX library.

Reimplemented from Texture.

Definition at line 60 of file pipelined_texture.cpp.

References GFXSelectTexture(), and Texture::stage.

61 {
62  GFXSelectTexture( current, stage );
63 }
void PipelinedTexture::MakeBothActive ( )

Definition at line 68 of file pipelined_texture.cpp.

References GFXSelectTexture(), and Texture::stage.

69 {
70  GFXSelectTexture( current, stage );
71  GFXSelectTexture( last, (stage == 1) ? 0 : 1 );
72 }
void PipelinedTexture::MakeLastActive ( )

Definition at line 64 of file pipelined_texture.cpp.

References GFXSelectTexture().

65 {
66  GFXSelectTexture( last, 0 );
67 }
bool PipelinedTexture::operator< ( const Texture b)
inline

Definition at line 17 of file pipelined_texture.h.

18  {
19  return true;
20  }
bool PipelinedTexture::operator== ( const Texture b)
inline

Definition at line 13 of file pipelined_texture.h.

14  {
15  return false;
16  }
Texture * PipelinedTexture::Original ( )
virtual

Reimplemented from Texture.

Definition at line 9 of file pipelined_texture.cpp.

References Texture::original, and Texture::Original().

10 {
11  //Had to duplicate the Texture::Original() function otherwise VC++ 6 would not compile anymore
12  //reporting an undefined reference to Texture::Original()
13  if (original)
14  return original->Original();
15  else
16  return this;
17 }
void PipelinedTexture::Swap ( )

Definition at line 73 of file pipelined_texture.cpp.

References GFXCreateTexture(), Texture::name, PALETTE8, RGB32, RGBA32, and Texture::stage.

74 {
75  stage = (stage+1)%2;
76  int tmp = name;
77  name = last;
78  last = current;
79  current = tmp;
80  if (clone) {
81  clone--;
82  GFXCreateTexture( sizeX, sizeY, (mode == _24BITRGBA) ? RGBA32 : ( (mode == _8BIT) ? PALETTE8 : RGB32 ), &name, NULL,
83  (stage == 1) ? 0 : 1 );
84  }
85 }

The documentation for this class was generated from the following files: