Results 1 to 3 of 3

Thread: Weird colors w/ my textures!

  1. #1
    Junior Member Newbie
    Join Date
    May 2003
    Posts
    24

    Weird colors w/ my textures!

    Ok, I'm just saving my framebuffer to a texture and drawing it as a texture in the exact same place and the colors are different, like they're dithered or something! The position is right, though.

    [on a related note, interesting enough even my splats look like concentric circles instead of a nice gradient, I wonder what I am doing wrong].

    Here's my code:
    glBindTexture( GL_TEXTURE_2D, texName );
    glCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, Vx, Vy, Sx, Sy);

    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
    glDisable(GL_ALPHA_TEST);
    glDisable(GL_BLEND);
    glColor4f(1,1,1,1);

    glBegin(GL_QUADS);
    glTexCoord2f(0., 0.);
    glVertex2f(0, 0);
    glTexCoord2f((float)Sx/1024.0, 0.);
    glVertex2f(1,1);
    glTexCoord2f((float)Sx/1024.0, (float)Sy/1024.0);
    glVertex2f(1,1);
    glTexCoord2f(0., (float)Sy/1024.0);
    glVertex2f(0,1);
    glEnd();


    And this is how I create the texture: (I have also tried GL_NEAREST w/o success)

    glBindTexture( GL_TEXTURE_2D, texName );
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)1024, (GLsizei)1024, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);

  2. #2
    Junior Member Newbie
    Join Date
    May 2003
    Posts
    24

    Re: Weird colors w/ my textures!

    I have finally fixed:

    The correct version is:

    glTexImage2D(GL_TEXTURE_2D, 0,


    /*****/ GL_RGBA8, /*****/


    (GLsizei)1024, (GLsizei)1024, 0, GL_RGBA,
    GL_UNSIGNED_BYTE, 0);

  3. #3
    Senior Member Frequent Contributor
    Join Date
    Aug 2001
    Location
    Italy
    Posts
    625

    Re: Weird colors w/ my textures!

    Interesting. Thank you.

    Maybe you can use TexSubImage to get some additional performance.

Similar Threads

  1. Replies: 2
    Last Post: 06-15-2015, 03:26 AM
  2. colors acting weird
    By Raposo in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 06-19-2011, 04:23 PM
  3. Textures and colors
    By Thomas Alton in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 01-12-2009, 01:51 PM
  4. textures and colors
    By m3xican in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 03-13-2008, 07:12 AM
  5. Weird colors when texture mapping
    By Ace_Man in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-30-2000, 11:40 PM

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