Problem with setup glTexImage2D data with GL_UNSIGNED_BYTE and GL_NEAREST

[ATTACH=CONFIG]1447[/ATTACH] [ATTACH=CONFIG]1448[/ATTACH]

On the first image it is present the result when I am using GL_UNSIGNED_BYTE:


glVertexAttribPointer(texcoord_attrib_index, 2, GL_UNSIGNED_BYTE, GL_TRUE, 0, NULL);
...
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture.w, texture.h, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture.data);
glGenerateMipmap(GL_TEXTURE_2D);

When I am using UV coordinates with GL_FLOAT [0.0 - 1.0] - it is all ok (second image), and GPU cutting textures from the image correctly. But when I am using GL_UNSIGNED_BYTE format [0 - 255] I can’t cut image textured fragment exactly at the pixel boundary. What is wrong?

Unsigned bytes don’t go from 0…265, they go from 0…255.

mhagain

Yes, 256 - it is first bit from the second byte. We have 256 digits from 0 to 255. Thank you.