Results 1 to 4 of 4

Thread: Pulling color data from texture coordinates

  1. #1
    Junior Member Newbie Pepretual's Avatar
    Join Date
    Jun 2008
    Location
    Orlando, FL
    Posts
    5

    Pulling color data from texture coordinates

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

    ~perpetual

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Pulling color data from texture coordinates

    Not sure if I understand what you want to do.

  3. #3
    V-man
    Guest

    Re: Pulling color data from texture coordinates

    It is more or less like this

    Code :
    //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.

  4. #4
    Junior Member Newbie
    Join Date
    Jun 2008
    Posts
    16

    Re: Pulling color data from texture coordinates

    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.

Similar Threads

  1. Texture Coordinates and Depth Buffer to obtain world coordinates
    By snkhan42 in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 04-27-2018, 11:52 AM
  2. Rendering Color Stored In Texture Coordinates?
    By PickleWorld in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-03-2011, 09:02 AM
  3. Pulling color data from texture coordinates
    By Pepretual in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 08-08-2008, 03:57 AM
  4. Vertex Program pulling AGP data (other than vertex data)
    By Cyranose in forum OpenGL: General
    Replies: 1
    Last Post: 05-01-2003, 08:16 PM
  5. extract color data from texture
    By mstepp in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-30-2001, 08:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean