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
stream_texture.cpp
Go to the documentation of this file.
1 #include "stream_texture.h"
2 
4 {
5  unsigned char *x = Map();
6  StreamTexture *ret = new StreamTexture( sizeX, sizeY, filtertype, x );
7  UnMap( false );
8  return ret;
9 }
10 
11 StreamTexture::StreamTexture( int width, int height, enum FILTER filtertype, unsigned char *origdata )
12 {
13  /*
14  * img_type=Unrecognized;
15  * img_depth=8;
16  * img_color_type=(PNG_HAS_COLOR&PNG_HAS_ALPHA);
17  * img_alpha=true;
18  * strip_16=true;
19  */
20  mode = _24BITRGBA;
21  this->stage = 0;
22  this->sizeX = width;
23  this->sizeY = height;
24  this->original = NULL;
25  this->palette = NULL;
26  this->refcount = 0;
29  ismipmapped = filtertype;
30  GFXCreateTexture( width, height, RGBA32, &name, 0, 0, filtertype );
31  this->mutabledata = (unsigned char*) malloc( sizeof (unsigned char)*width*height*4 );
32  if (origdata) {
33  memcpy( this->mutabledata, origdata, sizeof (unsigned char)*width*height*4 );
34  GFXTransferTexture( mutabledata, name, sizeX, sizeY, RGBA32 );
35  }
36 }
37 
38 unsigned char* StreamTexture::Map()
39 {
40  return mutabledata;
41 }
42 
44 {
45  if (changed) {
46  MakeActive( 0 );
47  GFXTransferTexture( mutabledata, name, sizeX, sizeY, RGBA32 );
48  }
49 }
50 
52 {
54  name = -1;
55  if (this->mutabledata)
56  free( this->mutabledata );
57  this->mutabledata = NULL;
58 }
59 
60 void StreamTexture::MakeActive( int stage )
61 {
62  GFXSelectTexture( name, stage );
63 }
64