BrawlCrate v0.41
Wii File Editor
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Properties | List of all members
BrawlLib.OpenGL.GLTexture Class Reference

Public Member Functions

 GLTexture ()
 
 GLTexture (int width, int height)
 
 GLTexture (Bitmap b)
 
int Initialize ()
 
void SetPalette (PLT0Node plt)
 
void Attach (TEX0Node tex, PLT0Node plt)
 
void Attach (Bitmap bmp)
 
void Default ()
 
void Bind ()
 
void Bind (int index=-1, int program=-1)
 
void Delete ()
 
override string ToString ()
 

Public Attributes

string _name
 
int _texId
 
IImageSource _source
 

Properties

int Width [get]
 
int Height [get]
 

Constructor & Destructor Documentation

◆ GLTexture() [1/3]

BrawlLib.OpenGL.GLTexture.GLTexture ( )
inline
27 {
28 }

◆ GLTexture() [2/3]

BrawlLib.OpenGL.GLTexture.GLTexture ( int  width,
int  height 
)
inline
31 {
32 _width = width;
33 _height = height;
34 _source = null;
35 }
IImageSource _source
Definition: GLTexture.cs:15

◆ GLTexture() [3/3]

BrawlLib.OpenGL.GLTexture.GLTexture ( Bitmap  b)
inline
38 {
39 _width = b.Width;
40 _height = b.Height;
41 ClearImages();
42 ClearTexture();
43 _textures = new Bitmap[] {b};
44 _remake = true;
45 _source = null;
46 }

Member Function Documentation

◆ Attach() [1/2]

void BrawlLib.OpenGL.GLTexture.Attach ( Bitmap  bmp)
inline
152 {
153 ClearImages();
154
155 _source = null;
156
157 _textures = new Bitmap[] {bmp};
158
159 if (_textures.Length != 0)
160 {
161 _width = _textures[0].Width;
162 _height = _textures[0].Height;
163 }
164
165 ifmt = PixelInternalFormat.Four;
166
167 _remake = true;
168 Initialize();
169 }
int Initialize()
Definition: GLTexture.cs:48

◆ Attach() [2/2]

void BrawlLib.OpenGL.GLTexture.Attach ( TEX0Node  tex,
PLT0Node  plt 
)
inline
115 {
116 ClearImages();
117
118 _source = tex;
119
120 _textures = new Bitmap[tex.LevelOfDetail];
121 for (int i = 0; i < tex.LevelOfDetail; i++)
122 {
123 _textures[i] = tex.GetImage(i, plt);
124 }
125
126 if (_textures.Length != 0 && _textures[0] != null)
127 {
128 _width = _textures[0].Width;
129 _height = _textures[0].Height;
130 }
131
132 switch (tex.Format)
133 {
134 case WiiPixelFormat.I4:
135 case WiiPixelFormat.I8:
136 ifmt = PixelInternalFormat.Intensity;
137 break;
138 case WiiPixelFormat.IA4:
139 case WiiPixelFormat.IA8:
140 ifmt = PixelInternalFormat.Luminance8Alpha8;
141 break;
142 default:
143 ifmt = PixelInternalFormat.Four;
144 break;
145 }
146
147 _remake = true;
148 Initialize();
149 }
Bitmap GetImage(int index)
Definition: TEX0Node.cs:311
WiiPixelFormat Format
Definition: TEX0Node.cs:104
int LevelOfDetail
Definition: TEX0Node.cs:105
WiiPixelFormat
Definition: Enum.cs:4

◆ Bind() [1/2]

void BrawlLib.OpenGL.GLTexture.Bind ( )
inline
183 {
184 Bind(-1, -1);
185 }
void Bind()
Definition: GLTexture.cs:182

◆ Bind() [2/2]

void BrawlLib.OpenGL.GLTexture.Bind ( int  index = -1,
int  program = -1 
)
inline
188 {
189 if (program != -1 && index >= 0 && index < 8)
190 {
191 GL.Uniform1(GL.GetUniformLocation(program, "texture" + index), index);
192 }
193
194 GL.BindTexture(TextureTarget.Texture2D, Initialize());
195 }

◆ Default()

void BrawlLib.OpenGL.GLTexture.Default ( )
inline
172 {
173 Bitmap b = new Bitmap(32, 32, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
174 using (Graphics grp = Graphics.FromImage(b))
175 {
176 grp.FillRectangle(Brushes.White, 0, 0, 32, 32);
177 }
178
179 Attach(b);
180 }
void Attach(TEX0Node tex, PLT0Node plt)
Definition: GLTexture.cs:114

◆ Delete()

void BrawlLib.OpenGL.GLTexture.Delete ( )
inline
198 {
199 ClearImages();
200 ClearTexture();
201 }

◆ Initialize()

int BrawlLib.OpenGL.GLTexture.Initialize ( )
inline
49 {
50 if (_remake && _textures != null)
51 {
52 ClearTexture();
53
54 _texId = GL.GenTexture();
55
56 GL.BindTexture(TextureTarget.Texture2D, _texId);
57 GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureBaseLevel, 0);
58 GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMaxLevel, _textures.Length - 1);
59 GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinLod, 0);
60 GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMaxLod, _textures.Length - 1);
61 //GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.GenerateMipmap, 1);
62
63 for (int i = 0; i < _textures.Length; i++)
64 {
65 Bitmap bmp = _textures[i];
66 if (bmp != null)
67 {
68 BitmapData data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height),
69 ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
70 GL.TexImage2D(TextureTarget.Texture2D, i, ifmt, data.Width, data.Height, 0,
71 OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);
72 bmp.UnlockBits(data);
73 }
74 }
75
76 _remake = false;
77 ClearImages();
78 }
79
80 return _texId;
81 }
int _texId
Definition: GLTexture.cs:13

◆ SetPalette()

void BrawlLib.OpenGL.GLTexture.SetPalette ( PLT0Node  plt)
inline
107 {
108 if (_source is TEX0Node)
109 {
110 Attach((TEX0Node) _source, plt);
111 }
112 }
Definition: TEX0Node.cs:22

◆ ToString()

override string BrawlLib.OpenGL.GLTexture.ToString ( )
inline
204 {
205 return _name;
206 }
string _name
Definition: GLTexture.cs:12

Member Data Documentation

◆ _name

string BrawlLib.OpenGL.GLTexture._name

◆ _source

IImageSource BrawlLib.OpenGL.GLTexture._source

◆ _texId

int BrawlLib.OpenGL.GLTexture._texId

Property Documentation

◆ Height

int BrawlLib.OpenGL.GLTexture.Height
get

◆ Width

int BrawlLib.OpenGL.GLTexture.Width
get

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