Jump to content
  • Advertisement
Sign in to follow this  
metimmee

glTexSubImage2D help

This topic is 4231 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to draw a scanning radar display using a fan of 1024 textured GL_TRIANGLES. The texture is a 512 x 1024 array. I texture each triangle 'spoke' with a single row from the texture array. When I first implemented this, every time the frame was drawn I updated the whole texture
glTexSubImage2D( GL_TEXTURE_2D,
                 0,
                 0,
                 0,
                 TEXTURE_RESOLUTION_X,
                 TEXTURE_RESOLUTION_Y,
                 GL_RGBA,
                 GL_UNSIGNED_BYTE, 
                 mapTexture);

This works fine except that its quite inefficient. I wish only to update the part of the texture that is equal to the current directon of the radar scanner. I wish the remainder of the texture to remain intact and unchanged. I tried the following but it draws the same textured row across all of the spokes. The variable nCurrentSpoke runs from 0 to 1023 as the scanner rotates.
glTexSubImage2D(   GL_TEXTURE_2D,	//target
		   0,                   //level
                   0,                   //xOffset
                   m_nCurrentSpoke,     //yOffset
                   TEXTURE_RESOLUTION_X,//width
                   1,                   //height
                   GL_RGBA,             //format
                   GL_UNSIGNED_BYTE,    //type
                   mapTexture);         //pixels

The following only updates what was previously updated and is faster, but as the scanner reaches the latter part of its scan it slows down since its fetching and carrying an ever larger portion of the texture.
glTexSubImage2D(   GL_TEXTURE_2D,	//target
		   0,                   //level
                   0,                   //xOffset
                   1,                   //yOffset
                   TEXTURE_RESOLUTION_X,//width
                   m_nCurrentSpoke,     //height
                   GL_RGBA,             //format
                   GL_UNSIGNED_BYTE,    //type
                   mapTexture);         //pixels

Am I missing something here? Any help would be appreciated since I've been working on this for ages now and performance is becoming a big issue. Thanks

Share this post


Link to post
Share on other sites
Advertisement
I posted the same article on the OpenGL newsgroup. The problem was that I needed to supply the row's address. The solution is below:


glTexSubImage2D(GL_TEXTURE_2D, //target
0, //level
0, //xOffset
m_nCurrentSpoke, //yOffset
TEXTURE_RESOLUTION_X, //width
1, //height
GL_RGBA, //format
GL_UNSIGNED_BYTE, //type
&checkImage[m_nCurrentSpoke][0][0]);//pixels

Share this post


Link to post
Share on other sites
I think it would be better to just forget about updating the texture completely. What I'm thinking is to just have the radar "sweep" line pointing up in the texture then just rendering a quad with this texture applied and either rotating the quad itself or the texture coordinates.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!