Texture problem

Post: #1
I'm currently trying to use OpenGL to do some 2D. My project is tile-based so I put all my tiles (32x32) in one texture. Then what I do is pick parts of the texture, slap it on a 32x32 quad and render that to screen. My problem is that the board I set up needs something like 18x13 tiles that are touching each other. Say tile one goes from (0,0) to (32,32) then tile two would go from (32,0) to (64,32) etc.. So they have a vertex in common.

What happens is that some ugly lines appear on each of those common vertices. Any way to prevent that without spacing them?

- Kjurtyl.
Quote this message in a reply
Posts: 5,143
Joined: 2002.04
Post: #2
Quote this message in a reply
Post: #3
Well, here's a geocities website with a screenshot of the


Simply copy/paste this. Forgive any ads that may pop up.

- Kjurtyl.
Quote this message in a reply
Post: #4
Ah, I think I've found out the problem. I was using gluOrtho2d()
with parameters that did not match my actual window height/width.
When the texture pixels were transfered they were each scaled to fit. Not all my problems are over, but the lines thing seems to at least be lessened.

I am also curious as to how I could fetch pixels in the texture by using actual pixel numbers (like pixel 1 to 32) instead of percentage fractions (like 0.0f to 0.125f).

- Kjurtyl
Quote this message in a reply
Posts: 469
Joined: 2002.10
Post: #5
If you aren't already, are you using texcoordarrays and quadstrips? Big performance boost there.

As for the problems with the lines, I think (but not sure) that if you clamp the texture edges that they will go away (or maybe it's the reverse...?).

I had similar lines in my 2D before I used clamp to edge. My thoughts anyhow.

15.4" MacBook Pro revA
Quote this message in a reply
Post: #6
My lines problem was divided in two parts, clamp to edge fixed up the second part of the problem. Which means I don't have any more lines problem(s)!

Thanks! :-)

I use this for putting the stuff to screen:

glTexCoord2f( 0.0f, 3.0f * i);
            glVertex2i( 0 + k*32, 416 - j*32);   // Bottom left
            glTexCoord2f(1.0f * i, 3.0f * i  );
            glVertex2i( 32 + k*32, 416 - j*32);   // Bottom right
            glTexCoord2f( 1.0f * i, 4.0f * i );
            glVertex2i( 32 + k*32,  448 - j*32);   // Top right
            glTexCoord2f( 0.0f, 4.0f * i );
            glVertex2i( 0 + k*32,  448 - j*32);   // Top left
            glTexCoord2f( 0.0f, 3.0f * i);

This is inside a few for loops to cover the screen for now,
but if simply converting this to array-form is what you are
talking about then I'll get to it eventually.

- Kjurtyl.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Texture coordinate problem Oddity007 0 3,162 Jan 21, 2009 06:20 PM
Last Post: Oddity007
  Porting SDL to Cocoa OpenGL view--texture problem smittyz 7 8,942 Jul 21, 2007 07:53 PM
Last Post: smittyz
  problem with basic texture mapping class wyrmmage 8 7,810 Dec 22, 2006 02:25 PM
Last Post: wyrmmage
  Cocoa Texture Loading Code Problem Nick 1 3,996 Oct 28, 2005 11:44 PM
Last Post: OneSadCookie
  annoying cosmetic texture problem. WhatMeWorry 14 9,372 Jun 6, 2005 06:15 PM
Last Post: WhatMeWorry