PDA

View Full Version : Monochrome Bitmap as Texture



ben
04-13-2001, 04:45 AM
Hello,

On the Windows platform, I am attempting to use a monochrome bitmap resource as a texture for alpha values. I'm not sure how to specify the texture. The bitmap is 64x64 and each bit specifies the alpha value for a pixel in the bitmap.

My code for setting up the texture looks like this:

//Set texture attributes
glGenTextures(1, &m_nTextureId);
glBindTexture(GL_TEXTURE_2D, m_nTextureId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

//Create texture
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, bmpInfo.bmiHeader.biWidth, bmpInfo.bmiHeader.biHeight, 0, LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, (void *)m_pBmpBits);

Where m_pBmpBits is a pointer to the bits in the bitmap and bmpInfo is a BITMAPINFO struct filled with data about the bitmap.