what could I do to ensure one point in texture is correspond one pixel in window. Because I want to get the same RGBA value from every pixel in window with RGBA of the point in texture. I use following code. But when I read the pixel, there are alway some drift from the original RGBA value of the texture.
void reshape(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void display()
{
...
glBindTexture(GL_TEXTURE_2D, _tID);
glTexParameteri(GL_TEXTURE_2D,
GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,
GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0);
glVertex3f( -1.0f, -1.0f, 0.0f);
glTexCoord2f(0.0, 1.0);
glVertex3f( -1.0f, 1.0f, 0.0f);
glTexCoord2f(1.0, 1.0);
glVertex3f( 1.0f, 1.0f, 0.0f);
glTexCoord2f(1.0, 0.0);
glVertex3f( 1.0f, -1.0f, 0.0f);
glEnd();
glReadPixels(0,0,WIDTH,HEIGHT,
GL_RGBA,GL_FLOAT,pData);
...
}
The RGBA value in pData is different from the original RGBA value in bmp file.
from texture to pixel
Started by jeffreytest, Jan 28 2005 05:36 AM
4 replies to this topic
#1
Posted 28 January 2005 - 05:36 AM
#2
Posted 28 January 2005 - 05:52 AM
If you are texturing an object in 3D space you can't! Yes, you can probably use mipmaps to correct the sampling problems but you can never be sure that one texel corresponds to one pixel!
#3
Posted 28 January 2005 - 07:03 AM
set up an orthogonal projection matrix and render a quad from 0 -> width and 0 -> height with texture coordinates from 0 -> 1. make sure you disable all filtering options in your driver settings. that might not be perfect either but is the best you can get in opengl. alternatively you can use the opengl raster functions like glBitmap. that will give you the right result, allthough it's obviously a lot slower.
anyway, why do you need it this exact ?
anyway, why do you need it this exact ?
If Prolog is the answer, what is the question ?
#4
Posted 29 January 2005 - 07:12 PM
Dont use OpenGL. Use SDL or some other library that lets you blit directly to the screen.
Jesse Coyle
#5
Posted 14 February 2005 - 09:16 AM
anubis said:
set up an orthogonal projection matrix and render a quad from 0 -> width and 0 -> height with texture coordinates from 0 -> 1. make sure you disable all filtering options in your driver settings. that might not be perfect either but is the best you can get in opengl. alternatively you can use the opengl raster functions like glBitmap. that will give you the right result, allthough it's obviously a lot slower.
anyway, why do you need it this exact ?
anyway, why do you need it this exact ?
great anubis !!! but i'll always exists drift, as u comment.
I'm curious to kwon, why u need this feature ? ( printscreen ? )
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












