/* Tested with LINT */ /************** TEXTURE.C Ver 1.0 ***************/ #include "GLD.h" #include "GEO.h" #include "TEX.h" #include "gli_st.h" #include "textu_st.h" #include "texture.h" #include "pvobj_st.h" #include "texbench.h" /* ======================================================================================= Access functions to texture structure ======================================================================================= */ /* * texture size */ void TEX_vGetTextureSize (struct GLI_tdstTexture_ *p_stTexture ,long *p_lSizeX, long *p_lSizeY) { *p_lSizeY = p_stTexture->lHeight; *p_lSizeX = p_stTexture->lWidth; } /* * Tiling mode */ void TEX_vSetTextureTilingMode( GLI_tdstTexture *p_stTexture, BOOL bTilingX , BOOL bTilingY ) { p_stTexture->ucCylingMode &= ~GLI_C_lCylingUV; if (bTilingX) if (bTilingY) p_stTexture->ucCylingMode |= GLI_C_lCylingUV; else p_stTexture->ucCylingMode |= GLI_C_lCylingU; else if (bTilingY) p_stTexture->ucCylingMode |= GLI_C_lCylingV; else p_stTexture->ucCylingMode |= 0; } void TEX_vGetTextureTilingMode( struct GLI_tdstTexture_ *p_stTexture, BOOL *p_bTilingX , BOOL *p_bTilingY ) { *p_bTilingX = (p_stTexture->ucCylingMode & GLI_C_lCylingU) ? 1 : 0; *p_bTilingY = (p_stTexture->ucCylingMode & GLI_C_lCylingV) ? 1 : 0; } void TEX_vSetTextureCyclingMode( GLI_tdstTexture *_p_stTexture, unsigned char _ucNewCyclingMode ) { _p_stTexture->ucCylingMode = _ucNewCyclingMode; } unsigned char TEX_ucGetTextureCyclingMode( GLI_tdstTexture *_p_stTexture ) { return _p_stTexture->ucCylingMode; } /* * Bilinear mode */ void TEX_vSetTextureBilinearMode( GLI_tdstTexture *p_stTexture, BOOL bTilingX , BOOL bTilingY) { if (bTilingX) if (bTilingY) p_stTexture->ucBilinearMode = GLI_C_lCylingUV; else p_stTexture->ucBilinearMode = GLI_C_lCylingU; else if (bTilingY) p_stTexture->ucBilinearMode = GLI_C_lCylingV; else p_stTexture->ucBilinearMode = 0; } void TEX_vGetTextureBilinearMode( GLI_tdstTexture *p_stTexture, BOOL *p_bTilingX , BOOL *p_bTilingY ) { *p_bTilingX = (p_stTexture->ucBilinearMode & GLI_C_lCylingU) ? 1 : 0; *p_bTilingY = (p_stTexture->ucBilinearMode & GLI_C_lCylingV) ? 1 : 0; } /* * ZWrite mode */ void TEX_vSetTextureZWriteMode( GLI_tdstTexture *p_Texture , long lOnOff) { if (lOnOff) p_Texture->lTextureCaps &= ~GLI_C_lNoZBufferWriteTexture; else p_Texture->lTextureCaps |= GLI_C_lNoZBufferWriteTexture; } long TEX_vGetTextureZWriteMode( struct GLI_tdstTexture_ *p_Texture ) { return (p_Texture->lTextureCaps & GLI_C_lNoZBufferWriteTexture); } /* * texture quality level */ void TEX_vSetTextureQualityLevel(struct GLI_tdstTexture_ *p_stTexture , char ucTextQuality) { p_stTexture->lTextureQuality = (unsigned long) ucTextQuality; } unsigned char TEX_ucGetTextureQualityLevel(struct GLI_tdstTexture_ *p_stTexture) { return ((unsigned char) (p_stTexture->lTextureQuality & 0x000000FF)); } /* * Nonzero texture */ long TEX_bIsTextureNZ (struct GLI_tdstTexture_ *p_stTexture) { return ( p_stTexture->lTextureCaps & GLI_C_lNZTexture ); } void TEX_vSetTextureChromakey (struct GLI_tdstTexture_ *p_stTexture , BOOL bSwitchOnOff , BOOL bFilteringOnOff , unsigned char ucR , unsigned char ucG , unsigned char ucB , unsigned char ucA ) { /*p_stTexture -> lChromakeyColorRGBA = ( ((long)ucR) << 24 ) | (((long)ucG) << 16) | (((long)ucB) << 8) | (ucA ) ;*/ p_stTexture -> lChromakeyColorRGBA = ( ((long)ucA) << 24 ) | (((long)ucB) << 16) | (((long)ucG) << 8) | (ucR ) ; if (bSwitchOnOff ) p_stTexture -> lTextureCaps |= GLI_C_lNZTexture; else p_stTexture -> lTextureCaps &= ~GLI_C_lNZTexture; if (bFilteringOnOff) p_stTexture -> lTextureCaps |= GLI_C_lNZFilteredTexture; else p_stTexture -> lTextureCaps &= ~GLI_C_lNZFilteredTexture; } void TEX_vGetTextureChromakey (struct GLI_tdstTexture_ *p_stTexture , BOOL *bSwitchOnOff, BOOL *bFilteringOnOff, unsigned char *ucR , unsigned char *ucG , unsigned char *ucB , unsigned char *ucA) { *ucA = (unsigned char)(( p_stTexture -> lChromakeyColorRGBA & 0xFF000000 ) >> 24); *ucB = (unsigned char)(( p_stTexture -> lChromakeyColorRGBA & 0xFF0000 ) >> 16); *ucG = (unsigned char)(( p_stTexture -> lChromakeyColorRGBA & 0xFF00 ) >> 8); *ucR = (unsigned char)(( p_stTexture -> lChromakeyColorRGBA & 0xFF) ); *bSwitchOnOff = p_stTexture->lTextureCaps & GLI_C_lNZTexture; *bFilteringOnOff = p_stTexture->lTextureCaps & GLI_C_lNZFilteredTexture; } /* * palette */ void TEX_vSetPaletteOfTexture ( struct GLI_tdstTexture_ *p_stTexture,TEX_tdstPalette *p_Palette) { (TEX_tdstPalette *) p_stTexture->p_vColorTable = p_Palette; } TEX_tdstPalette *TEX_vGetPaletteOfTexture ( struct GLI_tdstTexture_ *p_stTexture) { return ((TEX_tdstPalette *)p_stTexture -> p_vColorTable ); } /* * compression mode */ void TEX_vSetTextureCompressionMode ( struct GLI_tdstTexture_ *p_stTexture,long typeOfCompression) { p_stTexture->lTypeOfCompression = typeOfCompression; } long TEX_vGetTextureCompressionMode ( struct GLI_tdstTexture_ *p_stTexture) { return (p_stTexture->lTypeOfCompression ); } /* * mipmapping mode */ void TEX_vSetTextureMipMappingMode( struct GLI_tdstTexture_ *p_stTexture, long lTypeOfMipMapping) { p_stTexture->lTypeOfMipMapping = lTypeOfMipMapping; } long TEX_lGetTextureMipMappingMode( struct GLI_tdstTexture_ *p_stTexture) { return ( p_stTexture->lTypeOfMipMapping ) ; } /* * texture name */ void GLI_vSetTextureName( GLI_tdstTexture *p_stTexture , char *p_cName ) { //VLNEWTEXNAME strcpy(p_stTexture->a255_cFileName, p_cName) ; //strcpy(p_stTexture->szName, p_cName) ; } void GLI_vGetTextureName( GLI_tdstTexture *p_stTexture, char *p_cName ) { //VLNEWTEXNAME strcpy(p_cName, p_stTexture->a255_cFileName) ; //strcpy(p_cName, p_stTexture->szName ) ; } /* * texture substitution */ long TEX_bIsTextureSubstituedAfterCompression(struct GLI_tdstTexture_ *p_stTexture) { return ( (p_stTexture->lCompressionCounter != 0 ) && (p_stTexture->p_TextureOfSubstitution != NULL) ); } void TEX_vSetSupplyTexture ( struct GLI_tdstTexture_ *p_stTexture, struct GLI_tdstTexture_ *p_stSupplyTexture) { p_stTexture->p_TextureOfSubstitution = p_stSupplyTexture; } struct GLI_tdstTexture_ *TEX_p_tdstGetSupplyTexture ( struct GLI_tdstTexture_ *p_stTexture) { return(p_stTexture -> p_TextureOfSubstitution ); }