Hello Openglrs
I have this problem: I textured a plane to visualize an image. Now, I have the cursor of the mouse defining a region on the image. I want to grab the correspondent data in the frame buffer and texture a squared plane with center on the cursor. The square is 20x20.
I save the texture in:
imageCursor = (unsigned char ) malloc (32323sizeof(unsigned char));
then call:
glReadPixels(cursor.center.x-cursor.radius,
cursor.center.y-cursor.radius,
32,32,GL_RGB,GL_UNSIGNED_BYTE,imageCursor);
glBindTexture(GL_TEXTURE_2D, 2); //Create an ID For a texture
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, imageCursor);
and for the rendering I do:
glBindTexture(GL_TEXTURE_2D, 2);
glBegin(GL_QUADS);
glTexCoord2f(0,0);glVertex2f(cursor.center.x-cursor.radius,cursor.center.y-cursor.radius);
glTexCoord2f(1,0);glVertex2f(cursor.center.x+cursor.radius,cursor.center.y-cursor.radius);
glTexCoord2f(1,1);glVertex2f(cursor.center.x+cursor.radius,cursor.center.y+cursor.radius);
glTexCoord2f(0,1);glVertex2f(cursor.center.x-cursor.radius,cursor.center.y+cursor.radius);
glEnd();
but I get a kind of dilation of the underneath image (see snapshot)Can anybody help?
.