Answer the question
In order to leave comments, you need to log in
RGBA not displaying correctly?
There is a source image bmp size 960 * 495
Here is the program
Here is the code:
void FileReader::FileReader__(const char__ *filename,const char__ *state)
{
std::string ext="";
int__ l=strlen(filename);
while(--l>0&&filename[l]!='.')
ext+=filename[l];
if(strstr(ext.c_str(),"fnoc") || strstr(ext.c_str(),"lmx"))
{
ext_=true;
file=fopen(filename,state);
open_=true;
char__ ch;
while((ch=fgetc(file))!=-1)
{
if(ch==10)
strokoffile++;
countbyte++;
}
fclose(file);
file=fopen(filename,state);
}
else
{
life=open(filename,_A_ARCH);
ext_=false;
org=0;
}
}
void__ FileReader::ReadFile(int__ size_,void__ *buf)
{
lseek(life,0,org);
read(life,buf,size_);
org=1;
}
void__ Scene::EnableTexture(float__*texcoor, float__*vercoor)
{
glBegin(GL_QUADS);
glTexCoord2f(texcoor[0],texcoor[2]);
glVertex2f(vercoor[0],vercoor[2]);
glTexCoord2f(texcoor[1],texcoor[2]);
glVertex2f(vercoor[1],vercoor[2]);
glTexCoord2f(texcoor[1],texcoor[3]);
glVertex2f(vercoor[1],vercoor[3]);
glTexCoord2f(texcoor[0],texcoor[3]);
glVertex2f(vercoor[0],vercoor[3]);
glEnd();
}
NewData=new uchar__[4*960*495];
NewTexture=new uint__[1];
void__ Scene::ShowBackGround()
{
filereader->FileReader__("J:\\фукрпкявамчс\\content\\Загрузки\\table.bmp","r");
filereader->ReadFile(960*495*4,NewData);
for(float__ i=0;i<960*495;i++)
{
int__ index=i*4;
uchar__ R,G,B,A;
B=NewData[index];
G=NewData[index+1];//Green(B)
A=NewData[index+2];//Red(G)
R=NewData[index+3];//blue(R)
NewData[index]=R;
NewData[index+1]=G;//(G)
NewData[index+2]=B;//(B)
NewData[index+3]=A;//(R)
//GBR
//BGsR
}
glBindTexture(GL_TEXTURE_2D,NewTexture[0]);
gluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGBA,960,495,GL_RGBA,GL_UNSIGNED_BYTE,NewData);
EnableTexture(GetTextureCoordinats(10),GetVertexCoordinats(0));
return;
}
Answer the question
In order to leave comments, you need to log in
for(float__ i=54;i<960*495;i++)
{
int__ index=i*4;
uchar__ R,G,B,A;
R=NewData[index]; //R
A=NewData[index+1];//Green(B) //G
B=NewData[index+2];//Red(G) //A
G=NewData[index+3];//blue(R) //B
NewData[index]=R;
NewData[index+1]=G;//(G)
NewData[index+2]=B;//(B)
NewData[index+3]=A;//(R)
//GBR
//BGsR
}
filereader->FileReader__("J:\\фукрпкявамчс\\content\\Загрузки\\table.bmp","r");
filereader->ReadFile(960*495*4,NewData);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question