Jump to content
  • Advertisement
Sign in to follow this  
norbip

Texture blending problem

This topic is 3180 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello I'm trying to draw some trees in my program with billboards. I'm using 32 bit tga files with alpha channel as texture, and I got the following 'error': Image Those lines appear on the edges of my billboards and I don't really know how they get there. The texture seems to be ok. My texture init code:
	glGenTextures(1, &texture[3]);
	image = tgaLoad("C:\\grass.tga");
	glBindTexture(GL_TEXTURE_2D, texture[3]);
	gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, image->width, image->height, GL_RGBA, GL_UNSIGNED_BYTE, image->imageData);
	
	glTexParameteri( texture[3], GL_TEXTURE_WRAP_S, GL_REPEAT );
	glTexParameteri( texture[3], GL_TEXTURE_WRAP_T, GL_REPEAT );
	glTexParameteri( texture[3], GL_TEXTURE_MAG_FILTER, GL_LINEAR );
	glTexParameteri( texture[3], GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR  );



rendering part:
glPushMatrix();
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);              
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D, texture[3]);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0);
glDisable(GL_CULL_FACE);
glTranslatef( _pos.x, _pos.y, _pos.z );
glBegin(GL_QUADS);

glTexCoord2f(0, 0); glVertex3f(-size/2.0f, 0, 0);
glTexCoord2f(1, 0); glVertex3f( size/2.0f, 0, 0);
glTexCoord2f(1, 1); glVertex3f( size/2.0f, 0, size);
glTexCoord2f(0, 1); glVertex3f(-size/2.0f, 0, size);

glTexCoord2f(0, 0); glVertex3f(0, -size/2.0f, 0);
glTexCoord2f(1, 0); glVertex3f(0,  size/2.0f, 0);
glTexCoord2f(1, 1); glVertex3f(0,  size/2.0f, size);
glTexCoord2f(0, 1); glVertex3f(0, -size/2.0f, size);
glEnd();

glEnable(GL_CULL_FACE);
glDisable(GL_ALPHA_TEST);        
glDisable(GL_BLEND);            
glDisable(GL_TEXTURE_2D);
glPopMatrix();

Any ideas? :S

Share this post


Link to post
Share on other sites
Advertisement
Why are you passing a texture ID to
glTexParameteri( texture[3], GL_TEXTURE_WRAP_S, GL_REPEAT );

it should be
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );

Share this post


Link to post
Share on other sites
Quote:
Original post by V-man
Why are you passing a texture ID to
glTexParameteri( texture[3], GL_TEXTURE_WRAP_S, GL_REPEAT );

it should be
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );


Thanks, I've fixed that part, but the lines dont really want to get away. :]

Share this post


Link to post
Share on other sites
One more question related to billboarding..

How can I improve its performance? :/ Drawing a lot of quads isnt really fast at the moment. Point sprites/smaller textures would be faster?

[Edited by - norbip on December 5, 2009 12:21:36 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!