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