I tried to create texture based on reading a buffer (here the front buffer). I got it to work pretty well but I encounter some strange things.
The one involved in this thread is a problem of artifacts. Indeed, when I run the program, the gl window is fine, but the desktop (I’m not in fullscreen) encounters some disruptions, like little wavings about 1 up to 5 pixels on almost the whole screen (but the gl window). This artifact can be seen well on the text on a tty. If I disable making a texture from the buffer, there’s no more artifacts.
I wonder what could produce that. Maybe my program is not well (I don’t think so), or maybe it’s a system dependant bug.
My system: linux 2.6.10 compiled myself with several specific options, Nvidia geforce fx, drivers nvidia 1.0-7167 using agpgart (SIS 746), g++ 3.4.3.
I use glut for this program.
Here is the code involved:
unsigned char pixel_data[3*512*512];
// init function
memset (pixel_data,0xff,3*512*512*sizeof (unsigned char));
glEnable (GL_TEXTURE_2D);
glGenTextures (1, &texture);
glBindTexture (GL_TEXTURE_2D, texture);
glTexImage2D ( GL_TEXTURE_2D, 0,GL_RGB,512,512,0, GL_RGB,GL_UNSIGNED_BYTE, pixel_data);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
//display function
glEnable (GL_TEXTURE_2D);
glBindTexture (GL_TEXTURE_2D, texture);
//glCopyTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 0, 0, 512, 512);
glCopyTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, 0,0, 512,512, 0);
Ps:
#1: notice that this code doesn’t take the whole buffer since I read only a 512512 buffer (the window is 800600). I’ll have a look later on how to snap the whole screen in a texture, but this is not the topic of this thread.
#2: I’ll surely post more specific things. I’m gonna look if glut has something to do with this issue even if I’m sure it doesn’t.