Change texture on an object

Hi,
I’m new to OPenGL ES. I have Omap platform and GFX SDK/DDK from imagination technology which is running OK on my HW. Now I want to write a simple program which basically just display different picture on the screen when left/right arrow keys are pressed. I have preloaded the pictures to an array of texName (say photoTex[]). I used following code to map the texture to two triangles which form a rectangule (I had to use two triangles, for the SDK/DDK does not support GL_POLYGON, etc). The problem is that when the next picture is displayed, I still can see the previous pictures (looks like overlap). Can somebody help me? Is there any better way to display pictures?

Thanks a lot.

==================== Code =============================

   /* Check if left/right arrow key being pressed, if yes, update m_photoIdx and set m_Nextphoto to true */
   ....

   /* if picture not changed, then just return without doing anything */
   	if(!m_Nextphoto )
	return true;
   /* Now display the new picture */
glDisable(GL_DEPTH_TEST);

/* Disable Blending*/
glDisable(GL_BLEND);


glBindTexture(GL_TEXTURE_2D, photoTex[m_photoIdx]);
m_Nextphoto = false;

/* Lower right triangle */

{
VERTTYPE afVertices[] = {f2vt(-1.0f),f2vt(-1.0f),f2vt(0.0f), f2vt(1.0f), f2vt(-1.0f),f2vt(0.0f), f2vt(1.0f), f2vt(1.0f),f2vt(0.0f)};
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3,VERTTYPEENUM,0,afVertices);

// Pass the texture coordinates data
VERTTYPE afTexCoord[] = {f2vt(0.0f),f2vt(0.0f),  f2vt(1.0f),f2vt(0.0f), f2vt(1.0f),f2vt(1.0f)};
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2,VERTTYPEENUM,0,afTexCoord);

// Draws a non-indexed triangle array
glDrawArrays(GL_TRIANGLES, 0, 3);

}

/* upper left triangle */

{
VERTTYPE afVertices[] = {f2vt(-1.0f),f2vt(-1.0f),f2vt(0.0f), f2vt(1.0f),f2vt(1.0f),f2vt(0.0f), f2vt(-1.0f),f2vt(1.0f),f2vt(0.0f)};
VERTTYPE afTexCoord[] = {f2vt(0.0f),f2vt(0.0f), f2vt(1.0f),f2vt(1.0f), f2vt(0.0f),f2vt(1.0f)};

glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3,VERTTYPEENUM,0,afVertices);

glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2,VERTTYPEENUM,0,afTexCoord);

// Draws a non-indexed triangle array
glDrawArrays(GL_TRIANGLES, 0, 3);

}

OK, I figured it out. The problem was caused by
if(!m_Nextphoto )
return true;

For every frame, you have to render some data I think. So if no change for this frame, I just render same texture. Then the problem was gone.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.