Pulling color data from texture coordinates

is there anyway to gather the color data from the UVs in C++, without using GLSL?? Thanks!!!

~perpetual

Not sure if I understand what you want to do.

It is more or less like this


//Compute integer coordinates
int X=(int)texcoord_clamp(u * (float)texture_width);
int Y=(int)texcoord_clamp(s * (float)texture_height);

//Sample the texture
texel[0] = texels[Y*texture_height+X*4];
texel[1] = texels[Y*texture_height+X*4+1];
texel[2] = texels[Y*texture_height+X*4+2];
texel[3] = texels[Y*texture_height+X*4+3];

texcoord_clamp() would do the job of GL_CLAMP_TO_EDGE.
I’m also assuming GL_RGBA8 format.
This is like GL_NEAREST, GL_NEAREST filtering.

Tex coords. can also wrap, so you should at least make sure they’re within the range of 0 to 1,
or use some math to knock them back within range.

This should get rid of the integer part of a float:
uv - floor(uv);

That’s of course if you have them set to WRAP instead of CLAMP.