Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Black lines at edges of textures

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2012
    Posts
    1

    Black lines at edges of textures

    So when I draw textures I get black lines underneath and to the right. I'm using textures for images, since I can't find any other way with OpenGL.

    Here's my OpenGL initialisation code, if anything looks wrong please say, I'm very new to this. If anyone has any ideas what else might cause it, that would be very helpful.
    Thanks

    Code :
    private void initGL() {
    		try {
    			Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
    			Display.setTitle("User Interface");
    			Display.create();
    			Display.setVSyncEnabled(true);
    		} catch (LWJGLException e) {
    			e.printStackTrace();
    			System.exit(0);
    		}
     
    		glEnable(GL_TEXTURE_2D);
     
    		glClearColor(0, 0, 0, 0);
    		/*
    		// enable alpha blending
    		glEnable(GL_BLEND);
    		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    		*/
    		glViewport(0, 0, WIDTH, HEIGHT);
    		glMatrixMode(GL_MODELVIEW);
    		glMatrixMode(GL_PROJECTION);
    		glLoadIdentity();
    		glOrtho(0, WIDTH, HEIGHT, 0, 1, -1);
    		glMatrixMode(GL_MODELVIEW);
    	}

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    947
    Well, you didn't really specify what are you rendering and how, thus it's almost impossible to tell what's wrong with your code. The initialization code doesn't really help here.

    Quote Originally Posted by crisbr View Post
    I'm using textures for images, since I can't find any other way with OpenGL.
    What do you mean by using textures for images? What else would you like to use? Are you rendering a simple full-screen quad with an image stored in a texture?

    We need more information to be able to figure out what's the problem.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2012
    Posts
    15
    This seems like a blending artifact.

    Try changing the texture envelope and see if this solves the problem:
    Code :
    glTexEnv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
    The default mode (3rd parameter) is GL_MODULATE. GL_REPLACE should make sure you only use the texture's colors.

    Also, make sure that your texture image is correct (I'm assuming it is), but it could have slightly transparent and/or black pixels on the bottom and right edges.

    If you are displaying only one polygon, then you probably do not have a problem with depth testing and z-ordering. But if you are rendering multiple, make sure you call glEnable(GL_DEPTH_TEST), and modify your glClear() function to something like this:
    Code :
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

    If you have a non-opaque texture, then you should render your geometry by z-value order: Farthest first, and nearest last.

    Hope this helps!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •