Weird problem with textures

This is a discussion on Weird problem with textures within the Game Programming forums, part of the General Programming Boards category; OK first I have to say that I am very very bad at OpenGL, to the point that when I ...

  1. #1
    Registered User
    Join Date
    Aug 2008
    Posts
    30

    Weird problem with textures

    OK first I have to say that I am very very bad at OpenGL, to the point that when I search for solutions to my problems in OpenGL and find people talking about buffers and whatnot, I get really confused.

    So here's the problem. I've been searching blindly for very long because I have no idea what this problem is called so even if it is already in this forum please don't bombard me. =) The problem is that when I texture my planes and look closely at the plane's texture, I would notice a weird white line at the border with I can't seem to remove in Photoshop or GIMP because it's not there...

    As much as I would like to paste some code here I have no idea which part of my code should I paste here so..please help me in any way you can!

  2. #2
    Registered User
    Join Date
    Mar 2007
    Posts
    416
    Picture might help but I think I know what you're talking about. What file format are you loading the textures from? The only thing I can think of is you're not loading a segment of the file correctly and it's becoming a white line, or you're not binding the texture all the way across the plane/face.

  3. #3
    Registered User
    Join Date
    Aug 2008
    Posts
    30
    My teacher gave me her TGA loader which I think might be the problem, however I can't do anything because I don't know anything about a loader and everytime I ask her question she gives me crap answers like "go find out yourself". Also I checked my picture for white lines but there were none.

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Doesn't OpenGL have a texel origin setting? This sort of problem usually indicates that even though your u and v's might be correct your texel origin may not be. U and V coordinates correspond to the center of the texel and not the upper left corner of the texel. This can cause white lines where no texture data is to appear at the edges of your triangles. To solve this you can offset your vertices by 0.5f.

    There is a ton of information on the internet about this very problem. Most of it pertains to Direct3D since this is usually where the problem manifests itself a lot.

  5. #5
    Registered User
    Join Date
    Aug 2008
    Posts
    30
    Offset my vertices? Meaning instead of glVertex3f(1000,1000,1000); I put glVertex3f(999.5,999.5,999.5); for every glVertex3f that I have?

    Also any good websites to recommend? I really suck at finding stuff over the internet and random information will get me nowhere. I'm also curious to know if one can actually learn OpenGL on their own. To me it is way more time consuming and difficult than C++ and is cutting into my C++ time...

  6. #6
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    You have to turn on texture clamping,

    Code:
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    It's got nothing at all to do with the source images.

  7. #7
    Registered User
    Join Date
    Aug 2008
    Posts
    30
    I tried putting those in her TGA loader but the white pixels are still there.

  8. #8
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    If what zacs7 said does not work then try my idea. It is one or the other or possibly both. If your texture addressing mode is not set to clamp it is probably just using the diffuse color of the vertices when it goes beyond the bounds of the textures. Wrap will wrap at this point and clamp will clamp the texture - although in Direct3D clamp can cause the last row and column of pixels to be repeated across the remainder of the primitive. I rarely use anything but clamp since tiling can be accomplished without using a texture addressing mode. The only time I've used wrap is in the case of spheres when the last 'slice' of the sphere should wrap around from 1.0f back to 0.0f to <some_value>. If you don't use wrap the entire texture will be in the final slice making for one very ugly sphere.
    Last edited by VirtualAce; 01-15-2009 at 12:59 PM.

  9. #9
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    What interpolation are you using? You may need to turn it off. Ie set it to GL_NEAREST.

    Post a small sample program that shows your borders, we don't need to see the TGA loader or setting up a window etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Weird problem with sscanf
    By g4j31a5 in forum C++ Programming
    Replies: 17
    Last Post: 10-04-2006, 09:16 PM
  2. very weird problem (pointers I think)
    By hannibar in forum C Programming
    Replies: 2
    Last Post: 10-11-2005, 06:45 AM
  3. Replies: 6
    Last Post: 05-12-2005, 03:39 AM
  4. Weird mouse problem in XP
    By VirtualAce in forum Game Programming
    Replies: 5
    Last Post: 06-16-2004, 11:47 AM
  5. Weird class problem!
    By aker_y3k in forum C++ Programming
    Replies: 2
    Last Post: 09-25-2002, 06:12 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21