Jump to content
  • Advertisement
Sign in to follow this  
Moriquendi

OpenGL Textures with removed black color - how to fix it?

This topic is 3348 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

Hey. I draw my object at screen using OpenGL. Here's my code:
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, tekstura[numer]);		

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

	glBegin(GL_QUADS);							
		glColor3f(1.0f, 1.0f, 1.0f);				// 

		glTexCoord2f(0.0f, 0.0f); glVertex3f(x0, y0, 0.0f);
		glTexCoord2f(1.0f, 0.0f); glVertex3f(x1, y1, 0.0f);
		glTexCoord2f(1.0f, 1.0f); glVertex3f(x2, y2, 0.0f);
		glTexCoord2f(0.0f, 1.0f); glVertex3f(x3, y3, 0.0f);
	glEnd();
		glDisable(GL_TEXTURE_2D);
The problem is that textures are clearer or something like that(I don't really know how to say it in English. But they look like someone erased black color from them). So what's happening?

Share this post


Link to post
Share on other sites
Advertisement
Do you mean you can see through your quad to the background, where the texture is black?
If so, perhaps you have alpha-blending enabled (disable with glDisable(GL_BLEND)). If you mean that your black colors change to something else, then perhaps the problem is when loading the texture from file.

Share this post


Link to post
Share on other sites
This is how it looks:
http://xs844.xs.to/xs844/09423/xx624.jpg
with glDisable(GL_BLEND). Nothing changed.

And yes. The black was removing from my game. I removed this lines:
	glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

but nothing changed

Maybe the problem is somewhere here:

tekstura = SOIL_load_OGL_texture
(
sciezka.c_str(),
SOIL_LOAD_AUTO,
SOIL_CREATE_NEW_ID,
SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT
);
}


glEnable(GL_TEXTURE_2D); //włącza tekstury 2D

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);


Edit:
==============================================
Yea, I fond the solution.
When I make textures I used this FLAG
SOIL_FLAG_NTSC_SAFE_RGB 

When I removed it all started work.
In fact, I don't know what this flag do. Can you explain me it?:P

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!