This commit is contained in:
parent
80cb6d30d8
commit
8aa783b27b
10 changed files with 63 additions and 73 deletions
|
@ -42,7 +42,7 @@ sRGBData ThisRGB;
|
|||
{
|
||||
int Idx=GetTexIdx(NewTex); // Is already loaded?
|
||||
if (Idx!=-1) return(Idx);
|
||||
// sprintf(NewTex.Filename,"%s%s",Path,TexName);
|
||||
|
||||
TRACE1("Loading Texture %s\n",NewTex.Filename);
|
||||
LoadBMP(NewTex.Filename,ThisRGB);
|
||||
RGBData=&ThisRGB;
|
||||
|
@ -100,25 +100,6 @@ void CTexCache::FreeBMP(sRGBData &RGBData)
|
|||
}
|
||||
|
||||
/**************************************************************************************/
|
||||
/*
|
||||
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;
|
||||
}
|
||||
*/
|
||||
|
||||
void CTexCache::LoadTex(sTex &ThisTex,sRGBData *TexData)
|
||||
{
|
||||
std::vector<u8> Buffer;
|
||||
|
@ -127,53 +108,41 @@ int TexHeight=TexData->Height;
|
|||
int GLWidth=AlignSize(TexWidth);
|
||||
int GLHeight=AlignSize(TexHeight);
|
||||
u8 *Src,*Dst;
|
||||
u8 R,G,B,A;
|
||||
|
||||
// create RGB & alpha texture & ensuse texture is correct size for GL
|
||||
|
||||
Buffer.resize(GLWidth*GLHeight*4);
|
||||
Src=TexData->RGB;
|
||||
Dst=&Buffer[0];
|
||||
for (int Y=0; Y<GLHeight; Y++)
|
||||
for (int Y=0; Y<TexHeight; Y++)
|
||||
{
|
||||
for (int X=0; X<GLWidth; X++)
|
||||
for (int X=0; X<TexWidth; X++)
|
||||
{
|
||||
|
||||
if (X<=TexWidth && Y<=TexHeight)
|
||||
{
|
||||
Src=(u8*)&TexData->RGB[((Y*TexWidth)+X)*3];
|
||||
R=*Src++;
|
||||
G=*Src++;
|
||||
B=*Src++;
|
||||
A=255;
|
||||
if ((R==BlankRGB.rgbRed && G==BlankRGB.rgbGreen && B==BlankRGB.rgbBlue)) // Create alpha for transparent pixels (flagged with PINK!!)
|
||||
u8 R,G,B,A;
|
||||
|
||||
R=*Src++;
|
||||
G=*Src++;
|
||||
B=*Src++;
|
||||
A=255;
|
||||
if ((R==BlankRGB.rgbRed && G==BlankRGB.rgbGreen && B==BlankRGB.rgbBlue)) // Create alpha for transparent pixels (flagged with PINK!!)
|
||||
{
|
||||
A=0;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
R=255;
|
||||
G=0;
|
||||
B=255;
|
||||
A=255;
|
||||
}
|
||||
*Dst++=R;
|
||||
*Dst++=G;
|
||||
*Dst++=B;
|
||||
*Dst++=A;
|
||||
}
|
||||
Dst+=(GLWidth-TexWidth)*4;
|
||||
}
|
||||
|
||||
ThisTex.TexWidth=TexWidth;
|
||||
ThisTex.TexHeight=TexHeight;
|
||||
ThisTex.GLWidth=GLWidth;
|
||||
ThisTex.GLHeight=GLHeight;
|
||||
ThisTex.dW=1.0f/(GLWidth/16);
|
||||
ThisTex.dW=((float)TexWidth/(float)GLWidth)/(GLWidth/16);
|
||||
ThisTex.dH=((float)TexHeight/(float)GLHeight)/(GLHeight/16);
|
||||
|
||||
glGenTextures(1, &ThisTex.TexID);
|
||||
|
||||
ThisTex.dW=(1.0f)/(float)(GLWidth/16.0f);
|
||||
ThisTex.dH=(1.0f)/(float)(GLHeight/16.0f);
|
||||
|
||||
glGenTextures(1, &ThisTex.TexID);
|
||||
glBindTexture(GL_TEXTURE_2D, ThisTex.TexID);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, 4, GLWidth, GLHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, &Buffer[0]);
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue