Sign in to follow this  
rm2000

Progress on Tile-based space Shooter -- Tex Question

Recommended Posts

rm2000    122
I am working on a tile based 2D space shooter which is coming along beautifully. I am using gl_Texture_2f to do my texturing and I am king of noticing a small bug which I can't figure out what the problem is. Please look at screenshot You will notice that almost all of the 64 pixel tiles draw correctly; they also scroll correctly as does the separate cloud layer. I have had about 3 textures now which (if they have bright, contrasting colors) along the edges seem to "wrap-around" so to speak to the top of the texture. If you look at the lighted pod in this case you will see how along the left edge and top edges of the tiles the texture has wrapped a little bit. It looks pretty distracting when it happens in the game and I can't figure out where its coming from. And since its not happening to all textures its kind of throwing me for a loop. My basic lines for drawing the arena tiles looks like:
glBindTexture(GL_TEXTURE_2D, g_Texture[frame[y][x]]);
      
//////////////////////////////////////////////
// Draw the tile

		 glBegin (GL_QUADS);

  		     glTexCoord2f(0.0f, 1.0f);
		     glVertex2f(frame1xpos, frame1ypos);				
		
	  	     glTexCoord2f(0.0f, 0.0f);
		     glVertex2f(frame1xpos, frame1ypos + tilesize);	
       										
		
		     glTexCoord2f(1.0f, 0.0f);
		     glVertex2f(frame1xpos + tilesize, frame1ypos + tilesize);	
		
	
		     glTexCoord2f(1.0f, 1.0f);
		     glVertex2f(frame1xpos + tilesize, frame1ypos);
			 
		    glEnd();


Obviously it loops through each column and row. Any suggestions?? Thanks!! &Mark

Share this post


Link to post
Share on other sites
_winterdyne_    530
2 tips:

1) Turn off texture filtering.
2) Dont use 0 or 1 in UV coordinates - use 0.0001 and 0.99999

Worked last time I did a tile engine.

EDIT: Mine was in D3D. Check the NeHe tutorials for how to set those in OpenGL.

Share this post


Link to post
Share on other sites
rm2000    122
I was under the impression that texture filtering was disabled by default. In OpenGL don't I have to enable filtering if I want it? Also I tried changing the UV coords and that made all of the textures look distorted. Thanks for trying to help, though.

Share this post


Link to post
Share on other sites
kburkhart84    3187
I think texture filtering is set to GL_NEAREST by default. Did you try using GL_LINEAR just to see if it works better. I never have this problem and I use GL_LINEAR for filtering and GL_REPEAT instead of GL_CLAMP.

Share this post


Link to post
Share on other sites
WarMuuh    145
Quote:
Original post by _winterdyne_
2) Dont use 0 or 1 in UV coordinates - use 0.0001 and 0.99999


i ma also working on a tilebased game and also i had the same problem.
the fact is, that you can enable linear filtering, thats no matter.
the method of clipping the UV-coordinates just worked for me.
but eventualy the values are to small?
the value should be a halfTexel
if your picture is 64 pixels width, you should try this value:
1/64; ( i know, this is one texel, but try it)

and also try to draw with blending enabled.

Share this post


Link to post
Share on other sites
rm2000    122
It appears as though setting the textures to wrap and setting to linear helped with the problem. It may not be perfect but I think the problem is almost not noticable anymore.

BTW, I am glad to hear there are others who are into tile games. I am working on this and our 3D demo and I think both genres are very enjoyable. A lot of people won't even touch a game anymore unless its 3D.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this