This commit is contained in:
parent
e2bc92802a
commit
d2dd4ffd27
20 changed files with 330 additions and 152 deletions
|
@ -107,13 +107,39 @@ void CTexCache::FreeBMP(sRGBData &RGBData)
|
|||
/**************************************************************************************/
|
||||
void CTexCache::LoadTex(sTex &ThisTex,sRGBData *TexData)
|
||||
{
|
||||
ThisTex.Width=TexData->Width;
|
||||
ThisTex.Height=TexData->Height;
|
||||
std::vector<u8> Buffer;
|
||||
int Width=TexData->Width;
|
||||
int Height=TexData->Height;
|
||||
int Size=Width*Height;
|
||||
// create RGB & alpha texture
|
||||
Buffer.resize(Size*4);
|
||||
u8 *RgbPtr=TexData->RGB;
|
||||
|
||||
for (int i=0;i<Size;i++)
|
||||
{
|
||||
u8 R=*RgbPtr++;
|
||||
u8 G=*RgbPtr++;
|
||||
u8 B=*RgbPtr++;
|
||||
u8 A=255;
|
||||
if ((R==BlankRGB.rgbRed && G==BlankRGB.rgbGreen && B==BlankRGB.rgbBlue)) // Create alpha for transparent pixels (flagged with PINK!!)
|
||||
{
|
||||
A=0;
|
||||
}
|
||||
|
||||
Buffer[(i*4)+0]=R;
|
||||
Buffer[(i*4)+1]=G;
|
||||
Buffer[(i*4)+2]=B;
|
||||
Buffer[(i*4)+3]=A;
|
||||
}
|
||||
|
||||
|
||||
ThisTex.Width=Width;
|
||||
ThisTex.Height=Height;
|
||||
|
||||
glGenTextures(1, &ThisTex.TexID);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, ThisTex.TexID);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, 3, TexData->Width, TexData->Height, 0, GL_RGB, GL_UNSIGNED_BYTE, TexData->RGB);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, 4, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &Buffer[0]);
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue