Sign in to follow this  
darkchrono4

GL_ARB_multitexture Question

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
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

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