Jump to content
  • Advertisement
Sign in to follow this  
darkchrono4

GL_ARB_multitexture Question

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

I'm playing around with the tutorial from Ultimate Game Programming about multitexturing. I'm also using Nehe's code as a base for all the Win32 stuff. When it displays the textures on the quad they are very dark. If I try using tga then its fine but these bitmaps are causing a problem. I know the simple answer is just to use tga but I want to know what the problem with bitmaps is. Code for setting up textures:
        memset(&texture_image, 0, sizeof(void *)*1);

	if (texture_image = LoadBMP("nehe3.bmp")) {
			status = TRUE;
			
		glGenTextures(1, &texture[0]);
		glBindTexture(GL_TEXTURE_2D, texture[0]);
		
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

		glTexImage2D(GL_TEXTURE_2D, 0, 3, texture_image->sizeX, texture_image->sizeY, 0, GL_RGB,
					 GL_UNSIGNED_BYTE, texture_image->data);
			
	}

	if (texture_image) {
		if (texture_image->data)
			free(texture_image->data);

		free(texture_image);
	}

	status = FALSE;
	memset(&texture_image, 0, sizeof(void *)*1);

	if (texture_image = LoadBMP("crate.bmp")) {
			status = TRUE;
			
		glGenTextures(1, &texture[1]);
		glBindTexture(GL_TEXTURE_2D, texture[1]);

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

		glTexImage2D(GL_TEXTURE_2D, 0, 3, texture_image->sizeX, texture_image->sizeY, 0, GL_RGB,
					 GL_UNSIGNED_BYTE, texture_image->data);

		
	}

Code for displaying and texturing quad:
	glActiveTextureARB(GL_TEXTURE0_ARB);
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, texture[0]);

	glActiveTextureARB(GL_TEXTURE1_ARB);
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, texture[1]);
	
	glBegin(GL_QUADS);
	
		glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 0.0f);
	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 0.0f);
	glVertex3f(-1.0f, -1.0f,  1.0f);	// Bottom Left Of The Texture and Quad
	
	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0f, 0.0f);
	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0f, 0.0f);
	glVertex3f( 1.0f, -1.0f,  1.0f);	// Bottom Right Of The Texture and Quad
	
	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0f, 1.0f);
	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0f, 1.0f);
	glVertex3f( 1.0f,  1.0f,  1.0f);	// Top Right Of The Texture and Quad
	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 1.0f);
	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 1.0f);
	glVertex3f(-1.0f,  1.0f,  1.0f);	// Top Left Of The Texture and Quad

	glEnd();

	glActiveTextureARB(GL_TEXTURE1_ARB);
	glBindTexture(GL_TEXTURE_2D, NULL);

	glActiveTextureARB(GL_TEXTURE0_ARB);
	glBindTexture(GL_TEXTURE_2D, NULL);

Share this post


Link to post
Share on other sites
Advertisement
What textures are you using? By default, the color values in them will be multiplied together - if either is dark, the result will certainly be dark.

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!