I got it! Its because some wrong code in resizeGl(); method.
Now I ran the Texture mapping code, I cannot see the Image being displayed. Please find the code below.
void GLWidget::initializeGL()
{
PicData( “./PICS/Car_New1.png” , Structure holding PIC id, Height and width );
//ANd.
iTexture = glGenLists( 10 );
bindingImage( 1 ,GLUINT );
}
void GLWidget::vStorePicData( QString _sPath , sPic_Data _sPic )
{
imgLoaded = img.load(_sPath);
if(true == imgLoaded)
{
_sPic.iId = this->bindTexture(img, GL_TEXTURE_2D, GL_RGB);
_sPic.iHeight = img.height();
_sPic.iWidth = img.width();
}
}
void GLWidget::bindingImage
(
int PIC_Index ,
GLuint PIC_ID
)
{
glNewList(PIC_Index, GL_COMPILE );
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D, PIC_ID );
glBegin(GL_QUADS);
glTexCoord2d(0.0,1.0);
glVertex3f( -150 , -150 , 0.0f);
glTexCoord2d(0.0,0.0);
glVertex3f( -150 , +150 , 0.0f);
glTexCoord2d(1.0,0.0);
glVertex3f( +150 , +150 , 0.0f);
glTexCoord2d(1.0,1.0);
glVertex3f( +150 , -150 , 0.0f);
glEnd();
glEndList();
}
So finally in PaintGL() i will call the function to draw texture.
void GLWidget::DrawImage
(
Positions pos,
Rotations Rot,
Color col,
int index
)
{
makeCurrent();
glPushMatrix( );
/*Translate, Rotate, Color the Position*/
glTranslated( pos.fX , pos.fY , pos.fZ );
glRotatef( rot.Angle , rot.fX, rot.fY, rot.fZ );
glColor4f( col.Red , col.Green , col.Blue , 1.0f );
// Call the required texture from the list
glCallList( index );
/drawTexture(rect, _iIndex, GL_TEXTURE_2D );/
/*Return the Screen back to normal scenario*/
glPopMatrix();
}
in glCalllist() I am sending the texture index that i have used for glnewList in bindingImage function.
Can you tell where this has gone wrong or do I need to adapt a new way to this problem?
Thanks in Advance!