Hi there,
I am using openGL to basically display a 2D graphic at real time.
In the background I want to display a grid and some other stuff (I will call it STATIC part).
To avoid drawing all the time the DYNAMIC part (2D graphic) plus the static part (grid and other things), I want to use textures…(layer concept).
Basically what I do is:
// 1. init GL
…
// 2. init texture
GLuint texName;
GLubyte checkImage[256][256][4];
glGenTextures( 1, &texName );
glBindTexture( GL_TEXTURE_2D, texName );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexImage2D( GL_TEXTURE_2D, 0, 4, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, checkImage );
// 3. draw STATIC part
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDisable( GL_TEXTURE_2D);
glLoadIdentity;
// do grid drawing and some other stuff (STATIC drawing)
...
glBindTexture(GL_TEXTURE_2D, texName);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 256, 256);
SwapBuffers( dc->m_hDC );
// 4. and when I want to update the 2D graphic (DYNAMIC part) I do:
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glEnable( GL_TEXTURE_2D );
glBindTexture(GL_TEXTURE_2D, texName);
// do dynamic stuff
...
SwapBuffers( dc->m_hDC );
The problem: This is not working!
Am I doing something wrong?
What I can see is just the window empty!
If I do not perform step 4, I can see the “STATIC part”, but when I try to use the generated texture…it looks like everyting is clear…
Any help will be highly appreciated!
Thanks in advance!
MV.