OpenGL Questions... Borders and Colors...

This is a discussion on OpenGL Questions... Borders and Colors... within the Game Programming forums, part of the General Programming Boards category; Below is some of my first work in 3D (please don't be too harsh). It is drawn as squares then ...

  1. #1
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094

    OpenGL Questions... Borders and Colors...

    Below is some of my first work in 3D (please don't be too harsh). It is drawn as squares then rotated 45 degrees to get the isometric look. And because of the nature of what I want, it is done in an orthographic view. For now it uses a border that is part of the image file where the texture is loaded from. I want to get rid of that and just use a plain texture, but I am having some problems.

    Code:
    glGenTextures(1,&texture);
        glBindTexture(GL_TEXTURE_2D,texture);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        float color[4] = {1.0,1.0,1.0,1.0};
        glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, color);
        glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,grass->GetWidth(),grass->GetHeight(),
    		 0,GL_RGB,GL_UNSIGNED_BYTE,grass->GetImage());
    This is where I do all my texture initialization (image loading code can be provided if needed). I enable GL_TEXTURE_2D above this... What I don't get is why if I turn on borders after setting the GL_TEXTURE_BORDER_COLOR, everything that is textured (only one texture is used so far) turns white.
    Attached Images Attached Images  

  2. #2
    Software engineer
    Join Date
    Aug 2005
    Location
    Oregon
    Posts
    283
    I thought I had an idea of what could be wrong, but I voted against it. I hope someone can help! The more code, the better.
    Last edited by dxfoo; 10-01-2006 at 10:44 PM.

  3. #3
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    float color[4] = {1.0,1.0,1.0,1.0};

    Is the variable I am using, I have tried Red, Green, Blue (I know how to make the different colors) and usually I leave alpha at 1.0 for each of them.

    I know to set the border parameter to 1 when I want it on, it isn't in the code above because that is the last working state.

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584
    Diffuse vertex color normally dictates the color in a non T&L lighting environment or moreso lack of lighting environment. Tiles look good though.

    So are you drawing each line horizontally or are you starting at the top of each diagonal column and drawing down? The latter seems easier.
    Last edited by VirtualAce; 10-02-2006 at 04:26 AM.

  5. #5
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,070
    For now it uses a border that is part of the image file where the texture is loaded from. I want to get rid of that and just use a plain texture, but I am having some problems.
    I'm a little confused...are you trying to turn off OpenGL borders, or turn them on, or...?
    Memorial University of Newfoundland
    Computer Science

    Mac and OpenGL evangelist.

  6. #6
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Psycho:I am trying to turn on OpenGL borders, since as it is, the tiles look good when they are in a diagonal state, but when I rotate the map the lines look a little thicker (they are 2px) and it looks like crap.

    Another thing is, the edge of the texture seems to be bleeding into the sides, so if the edges of the textures are black, the sides of the tiles are black too. Even if I set the color to something else before drawing the sides.

    Bubba:I don't understand what you said in the first sentence... still learning the 3d techno-babble.

    As it is, I start by drawing the bottom, back tile, then work my way to the bottom right, then draw the next level of tiles back to front (in a pattern like I said in my other thread). I use a set of if statements to draw the map in the right order for the current view (though I don't know if this is the best way).

    Eventually I want to optimize it to only draw the sides that are visable, but for now it draws every tile all 6 sides (though I guess I could get rid of the bottom safely right now).

    EDIT: Attached is the exe, tga, and source code. I didn't write the CTargaImage stuff, and most of the stuff in main.cpp is from a base in the book I am using. I intend to change main.cpp to use SDL instead of Win32 to make it portable. 5 files max, so tga is in next post, and I can't post the .exe (for understandable reasons).
    Attached Files Attached Files
    Last edited by Wraithan; 10-02-2006 at 05:39 AM.

  7. #7
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Targa file: .tga files are not one of the allowed types (probably an oversight) so rename this back to .tga from .txt
    Attached Files Attached Files

  8. #8
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,070
    I am trying to turn on OpenGL borders, since as it is, the tiles look good when they are in a diagonal state, but when I rotate the map the lines look a little thicker (they are 2px) and it looks like crap.
    The OpenGL borders wouldn't even be noticiable, would they? Since the loaded texture image already has a border. Perhaps i'm still missing the point here.
    Memorial University of Newfoundland
    Computer Science

    Mac and OpenGL evangelist.

  9. #9
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    I am going to remove border on the texture and just use the OpenGL borders when I get them working. That way I can use the texture for other things than just while on the battle map.

  10. #10
    Amazingly beautiful user.
    Join Date
    Jul 2005
    Location
    If you knew I'd have to kill you
    Posts
    254
    I know this is more of a work around than a fix, but why not do one of the following:
    A. Draw a border on each texture as you load it (during runtime), before binding it with OpenGL, and load a second copy to use without the border
    B. Instead of doing the border on the texture, you could use GL_LINES and draw the borders yourself.
    Programming Your Mom. http://www.dandongs.com/

  11. #11
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,070
    I tried it and couldn't get it to work either (with the method you show in the OP).

    There's a page on opengl.org about it though. May be of some help.
    Memorial University of Newfoundland
    Computer Science

    Mac and OpenGL evangelist.

  12. #12
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    I have read that page several times, but I can't see what I am doing wrong.

    Does anyone have a working example of using borders on textures?

    Anyway, I am going to continue googling and playing with it, but for now it is back burnered in priority so I can get my mapfile setup and then use that for drawing instead of some hardcoded values. Once I can get that done, I will probably rewrite the all of the OpenGL code since as it is, it was written as needed/learned and not really planned out. Perhaps then I will find out my problem.

    EDIT: Also at that point I could do the line overlays if I can't get borders working.
    Last edited by Wraithan; 10-02-2006 at 11:14 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ncurses, windows, and colors
    By subflood in forum Linux Programming
    Replies: 2
    Last Post: 08-26-2004, 10:14 AM

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