You may be trying to map a 2D sprite, or texture overlay, to screen pixels, and having problems with filtering, where edges, or areas between pixels, become blurry, or black, or having some other pixel-fitting problem. OpenGL specifies pixel accurate transformation to viewport, and texture fetch and filtering. Thus, you can make it work just fine, if you know what you're doing. First, you want to use REPEAT or CLAMP_TO_EDGE texture filtering mode as TexParameter for EACH texture -- if you use CLAMP or CLAMP_TO_BORDER for some textures, it will filter with the border color, which by default is black (except on the GeForce 2 which doesn't do borders). Second, you should realize that "0,0" and "1,1" is the same texture coordinate, and sits right between all four corners of the texture, when you're using REPEAT (and 0,0 is in the low-left corner of the low-left texel when using CLAMP). To sample the center of a texel, in a texture with side length L, you need to have a coordinate that is (0.5/L)+(N/L) where N is an integer. Third, you should realize that, if you're using typical orthographic projection where (0,0)-(800,600) is left-bottom to right-top on a 800x600 screen, the coordinate (0,0) is at the left-bottom corner of the left-bottom pixel on the screen. However, textures are sampled in the middle of pixels. Thus, if you draw a quad from (0,0) to (256,256), and use a texture of size 256x256, and specify texture coordinates from (0,0) to (1,1), then each screen pixel will be EXACTLY sampled in the middle of each texel of the texture. The OpenGL specification guarantees this. |