Main Page | Alphabetical List | Compound List | File List | Compound Members | File Members

REGISTER.H File Reference

#include <Windows.h>
#include "ddraw.h"
#include "DCommon.h"

Go to the source code of this file.

Compounds

struct  geRDriver_THandle

Defines

#define MAX_TEXTURE_HANDLES   15000
#define THANDLE_UPDATE   (1<<0)
#define THANDLE_TRANS   (1<<2)
#define THANDLE_LOCKED   (1<<3)

Typedefs

typedef geRDriver_THandle geRDriver_THandle

Functions

geBoolean DRIVERCC DrvResetAll (void)
geRDriver_THandle *DRIVERCC CreateTexture (int32 Width, int32 Height, int32 NumMipLevels, const geRDriver_PixelFormat *PixelFormat)
geBoolean DRIVERCC DestroyTexture (geRDriver_THandle *THandle)
geBoolean DRIVERCC LockTextureHandle (geRDriver_THandle *THandle, int32 MipLevel, void **Data)
geBoolean DRIVERCC UnLockTextureHandle (geRDriver_THandle *THandle, int32 MipLevel)
geBoolean DRIVERCC THandle_GetInfo (geRDriver_THandle *THandle, int32 MipLevel, geRDriver_THandleInfo *Info)
geBoolean DRIVERCC SetPalette (geRDriver_THandle *THandle, geRDriver_THandle *PalHandle)
geRDriver_THandle *DRIVERCC GetPalette (geRDriver_THandle *THandle)
geBoolean DRIVERCC SetAlpha (geRDriver_THandle *THandle, geRDriver_THandle *PalHandle)
geRDriver_THandle *DRIVERCC GetAlpha (geRDriver_THandle *THandle)

Variables

geRDriver_THandle TextureHandles [MAX_TEXTURE_HANDLES]


Define Documentation

#define MAX_TEXTURE_HANDLES   15000
 

Definition at line 31 of file REGISTER.H.

#define THANDLE_LOCKED   (1<<3)
 

Definition at line 36 of file REGISTER.H.

#define THANDLE_TRANS   (1<<2)
 

Definition at line 35 of file REGISTER.H.

#define THANDLE_UPDATE   (1<<0)
 

Definition at line 34 of file REGISTER.H.


Typedef Documentation

typedef struct geRDriver_THandle geRDriver_THandle
 


Function Documentation

geRDriver_THandle* DRIVERCC CreateTexture int32  Width,
int32  Height,
int32  NumMipLevels,
const geRDriver_PixelFormat PixelFormat
 

Definition at line 133 of file register.c.

References geRDriver_THandle::BitPtr, DRIVERCC, DRV_ERROR_GENERIC, FindTextureHandle(), geRDriver_THandle::Flags, geRDriver_PixelFormat::Flags, GE_PIXELFORMAT_16BIT_555_RGB, GE_PIXELFORMAT_16BIT_565_RGB, GE_PIXELFORMAT_24BIT_RGB, GE_PIXELFORMAT_32BIT_ARGB, GE_PIXELFORMAT_32BIT_XRGB, GE_PIXELFORMAT_8BIT, geRDriver_THandle::Height, int32, geRDriver_THandle::MipLevels, NULL, geRDriver_PixelFormat::PixelFormat, geRDriver_THandle::PixelFormat, PixelFormat, RDRIVER_PF_3D, RDRIVER_PF_CAN_DO_COLORKEY, RDRIVER_PF_PALETTE, SetLastDrvError(), SnapToPower2(), THANDLE_TRANS, U16, U32, U8, and geRDriver_THandle::Width.

00134 {
00135         int32                           i, SWidth, SHeight;                     // Snapped to power of 2 width/height
00136         geRDriver_THandle       *THandle;
00137 
00138         assert(PixelFormat);
00139         
00140         THandle = FindTextureHandle();
00141 
00142         if (!THandle)
00143         {
00144                 SetLastDrvError(DRV_ERROR_GENERIC, "SOFT_CreateTexture: No more handles left.");
00145                 goto ExitWithError;
00146         }
00147 
00148         if(PixelFormat->Flags & RDRIVER_PF_3D)
00149         {
00150                 if (Width > 256)
00151                 {
00152                         SetLastDrvError(DRV_ERROR_GENERIC, "SOFT_CreateTexture: Width > 256.");
00153                         goto ExitWithError;
00154                 }
00155 
00156                 if (Height > 256)
00157                 {
00158                         SetLastDrvError(DRV_ERROR_GENERIC, "SOFT_CreateTexture: Height > 256.");
00159                         goto ExitWithError;
00160                 }
00161                 SWidth = SnapToPower2(Width);
00162                 SHeight = SnapToPower2(Height);
00163 
00164                 if (Width != SWidth)
00165                 {
00166                         SetLastDrvError(DRV_ERROR_GENERIC, "SOFT_CreateTexture: Not a power of 2.");
00167                         goto ExitWithError;
00168                 }
00169 
00170                 if (Height != SHeight)
00171                 {
00172                         SetLastDrvError(DRV_ERROR_GENERIC, "SOFT_CreateTexture: Not a power of 2.");
00173                         goto ExitWithError;
00174                 }
00175         }
00176         
00177         THandle->MipLevels              =NumMipLevels;
00178         THandle->Width                  =Width;
00179         THandle->Height                 =Height;
00180         THandle->PixelFormat    =*PixelFormat;
00181         THandle->Flags                  =0;
00182 
00183         for(i=0;i < NumMipLevels;i++)
00184         {
00185                 if(PixelFormat->Flags & RDRIVER_PF_PALETTE)
00186                 {
00187                         if( PixelFormat->PixelFormat == GE_PIXELFORMAT_32BIT_ARGB ||
00188                                 PixelFormat->PixelFormat == GE_PIXELFORMAT_32BIT_XRGB ) // <> CB added XRGB
00189                         {
00190                                 THandle->BitPtr[i]      =(U16 *)malloc(sizeof(U32) * Width * Height);
00191                         }
00192                         else
00193                         {
00194                                 SetLastDrvError(DRV_ERROR_GENERIC, "SOFT_CreateTexture: Bad Pal format.");
00195                                 goto ExitWithError;
00196                         }
00197                 }
00198                 else
00199                 {
00200                         switch (PixelFormat->PixelFormat)
00201                         {
00202                                 case GE_PIXELFORMAT_16BIT_565_RGB:
00203                                 {
00204                                         THandle->BitPtr[i]      =(U16 *)malloc(sizeof(U16) * Width * Height);
00205                                         break;
00206                                 }
00207                                 
00208                                 case GE_PIXELFORMAT_16BIT_555_RGB:
00209                                 {
00210                                         THandle->BitPtr[i]      =(U16 *)malloc(sizeof(U16) * Width * Height);
00211                                         break;
00212                                 }
00213 
00214                                 case GE_PIXELFORMAT_8BIT:
00215                                 {
00216                                         THandle->BitPtr[i]      =(U16 *)malloc(sizeof(U8) * Width * Height);
00217                                         break;
00218                                 }
00219 
00220                                 case GE_PIXELFORMAT_24BIT_RGB:
00221                                 {
00222                                         THandle->BitPtr[i]      =(U16 *)malloc((sizeof(U8)*3) * Width * Height);
00223                                         break;
00224                                 }
00225 
00226                                 default:
00227                                 {
00228                                         SetLastDrvError(DRV_ERROR_GENERIC, "SOFT_Create3DTexture: Invalid pixel format.");
00229                                         goto ExitWithError;
00230 //                                      THandle->BitPtr[i]      =(U16 *)malloc(sizeof(U16) * Width * Height);
00231 //                                      break;
00232                                 }
00233                         }
00234 
00235                         if ( PixelFormat->Flags & RDRIVER_PF_CAN_DO_COLORKEY )
00236                         {
00237                                 THandle->Flags |= THANDLE_TRANS;
00238                         }
00239                 }
00240         }
00241 
00242         return THandle;
00243                 
00244         ExitWithError:
00245         {
00246                 return NULL;
00247         }
00248 }

geBoolean DRIVERCC DestroyTexture geRDriver_THandle THandle  ) 
 

Definition at line 330 of file register.c.

References DRIVERCC, FreeTextureHandle(), and geBoolean.

00331 {
00332         return FreeTextureHandle(THandle);
00333 }

geBoolean DRIVERCC DrvResetAll void   ) 
 

Definition at line 89 of file D3ddrv7x.cpp.

References D3DMain_Reset(), DRIVERCC, and geBoolean.

00090 {
00091         return D3DMain_Reset();
00092 }

geRDriver_THandle* DRIVERCC GetAlpha geRDriver_THandle THandle  ) 
 

Definition at line 319 of file register.c.

References geRDriver_THandle::Active, geRDriver_THandle::AlphaHandle, DRIVERCC, and GE_FALSE.

00320 {
00321         assert(THandle);
00322 #ifdef _DEBUG
00323         if ( ! THandle->Active )
00324                 return GE_FALSE;
00325 #endif
00326 
00327         return  THandle->AlphaHandle;
00328 }

geRDriver_THandle* DRIVERCC GetPalette geRDriver_THandle THandle  ) 
 

Definition at line 289 of file register.c.

References geRDriver_THandle::Active, DRIVERCC, GE_FALSE, and geRDriver_THandle::PalHandle.

00290 {
00291         assert(THandle);
00292 #ifdef _DEBUG
00293         if ( ! THandle->Active )
00294                 return GE_FALSE;
00295 #endif
00296 
00297         return  THandle->PalHandle;
00298 }

geBoolean DRIVERCC LockTextureHandle geRDriver_THandle THandle,
int32  MipLevel,
void **  Data
 

Definition at line 335 of file register.c.

References geRDriver_THandle::Active, geRDriver_THandle::BitPtr, DRIVERCC, geRDriver_THandle::Flags, GE_FALSE, GE_TRUE, geBoolean, THANDLE_LOCKED, and uint16.

00336 {
00337         assert(THandle);
00338         assert(MipLevel <= THandle->MipLevels && MipLevel >= 0);
00339 #ifdef _DEBUG
00340         if ( ! THandle->Active )
00341                 return GE_FALSE;
00342         if ( ! THandle->BitPtr[MipLevel] )
00343                 return GE_FALSE;
00344 #endif
00345 
00346         THandle->Flags  |=(THANDLE_LOCKED << MipLevel);
00347         *Data                   =(uint16*)THandle->BitPtr[MipLevel];
00348 
00349         return  GE_TRUE;
00350 }

geBoolean DRIVERCC SetAlpha geRDriver_THandle THandle,
geRDriver_THandle PalHandle
 

Definition at line 300 of file register.c.

References geRDriver_THandle::Active, geRDriver_THandle::AlphaHandle, DRIVERCC, geRDriver_PixelFormat::Flags, GE_FALSE, GE_TRUE, geBoolean, geRDriver_THandle::PixelFormat, RDRIVER_PF_ALPHA, and RDRIVER_PF_HAS_ALPHA.

00301 {
00302         assert(THandle);
00303 #ifdef _DEBUG
00304         if ( ! THandle->Active )
00305                 return GE_FALSE;
00306 #endif
00307 
00308         if(THandle->PixelFormat.Flags & RDRIVER_PF_HAS_ALPHA)
00309         {
00310                 if(AHandle->PixelFormat.Flags & RDRIVER_PF_ALPHA)
00311                 {
00312                         THandle->AlphaHandle    =AHandle;
00313                         return  GE_TRUE;
00314                 }
00315         }
00316         return  GE_FALSE;
00317 }

geBoolean DRIVERCC SetPalette geRDriver_THandle THandle,
geRDriver_THandle PalHandle
 

Definition at line 279 of file register.c.

References DRIVERCC, GE_TRUE, geBoolean, and geRDriver_THandle::PalHandle.

00280 {
00281         assert(THandle);
00282 
00283         THandle->PalHandle      =PalHandle;
00284 
00285         return  GE_TRUE;
00286 }

geBoolean DRIVERCC THandle_GetInfo geRDriver_THandle THandle,
int32  MipLevel,
geRDriver_THandleInfo Info
 

Definition at line 594 of file D3D7xDrv/THandle.cpp.

00595 {
00596         DebugIf (MipLevel > THandle->Log, return GE_FALSE);
00597 
00598         Info->Width = THandle->Width>>MipLevel;
00599         Info->Height = THandle->Height>>MipLevel;
00600         Info->Stride = THandle->Stride>>MipLevel;
00601 
00602         if (THandle->PixelFormat.Flags & RDRIVER_PF_CAN_DO_COLORKEY)
00603         {
00604                 Info->Flags = RDRIVER_THANDLE_HAS_COLORKEY;
00605                 Info->ColorKey = 1;
00606         }
00607         else
00608         {
00609                 Info->Flags = 0;
00610                 Info->ColorKey = 0;
00611         }
00612 
00613         Info->PixelFormat = THandle->PixelFormat;
00614 
00615         return GE_TRUE;
00616 }

geBoolean DRIVERCC UnLockTextureHandle geRDriver_THandle THandle,
int32  MipLevel
 

Definition at line 352 of file register.c.

References DRIVERCC, geRDriver_THandle::Flags, GE_FALSE, GE_TRUE, geBoolean, THANDLE_LOCKED, and THANDLE_UPDATE.

00353 {
00354         assert(THandle);
00355         if (!(THandle->Flags & (THANDLE_LOCKED << MipLevel)))
00356                 return GE_FALSE;
00357 
00358         THandle->Flags  &=~(THANDLE_LOCKED << MipLevel);        // This mip is now unlocked
00359         THandle->Flags  |=THANDLE_UPDATE;                                       // Mark it for updating...
00360 
00361         return GE_TRUE;
00362 }


Variable Documentation

geRDriver_THandle TextureHandles[MAX_TEXTURE_HANDLES]
 

Definition at line 49 of file REGISTER.H.


Generated on Tue Sep 30 12:37:59 2003 for GTestAndEngine by doxygen 1.3.2