This code is sooo old. I just wanted to stress that first before anyone flamed me Anyways I think the variables are named so you will know what they represent. You should at least get an idea how to do it from this code. If you can't understand some of it I can help you. I just don't feel like explaining it out when I can just show you. I'm kind of out the door right now so , enjoy.
Code:
// Center wall
yMin = (Height >> 1) - (WallHeight >> 1);
yMax = yMin + WallHeight;
vMod = MIN( 0, (Height >> 1) - (WallHeight >> 1) );
// Clamp yMin and yMax
if( yMin < 0 )
yMin = 0;
if( yMax >= pDest->GetHeight() )
yMax = (pDest->GetHeight() - 1);
// Get line pointer to desired index
pLine = pDest->GetLinePtr( yMin );
pLine += pDest->GetChannels() * ray;
// Take care of texturing
if( (bTextureEnable == true) && (bNotTextured == false) )
{
// Get a pointer to the bitmap for texture
pTexture = GetMapTexture( pThis, CellValueX );
if( (pTexture == NULL) || (!pTexture->isValidBitmap()) )
{
bNotTextured= true;
break;
}
for( i = yMin; i < yMax; i++ )
{
// Find out index into textures
fu = (XTextureOffset * pTexture->GetWidth());
fv = (float)((i - yMin - vMod) * pTexture->GetHeight() / WallHeight);
// Truncate to integers
iu = ClampValue( (int)fu, 0, pTexture->GetWidth() - 1 );
iv = ClampValue( (int)fv, 0, pTexture->GetHeight() - 1 );
if( pTexture->GetChannels() == 1 )
pTexture->GetPalette( *(pTexture->GetLinePtr(iv) + iu), 1, &rgbQuad );
else
{
// Handle 24-bit case
rgbQuad.rgbBlue = *(pTexture->GetLinePtr(iv) + (iu * pTexture->GetChannels()));
rgbQuad.rgbGreen = *(pTexture->GetLinePtr(iv) + (iu * pTexture->GetChannels() + 1));
rgbQuad.rgbRed = *(pTexture->GetLinePtr(iv) + (iu * pTexture->GetChannels() + 2));
}
// Write the pixel information to destination
*pLine = rgbQuad.rgbBlue;
*(pLine + 1) = rgbQuad.rgbGreen;
*(pLine + 2) = rgbQuad.rgbRed;
pLine += nStride;
}
}