#include <Windows.h>#include <Assert.h>#include "GTHandle.h"#include "GCache.h"#include "GMain.h"#include "GlideDrv.h"Go to the source code of this file.
|
|
Definition at line 32 of file GThandle.c. |
|
|
Definition at line 31 of file GThandle.c. |
|
||||||||||||||||||||
|
Definition at line 458 of file GThandle.c. References geRDriver_THandle::Data, DRV_ERROR_GENERIC, GTHandle_FindTextureHandle(), geRDriver_THandle::Height, int32, geRDriver_THandle::LogSize, NULL, geRDriver_THandle::NumMipLevels, geRDriver_THandle::PixelFormat, PixelFormat, SetLastDrvError(), uint16, uint8, and geRDriver_THandle::Width. Referenced by GTHandle_Create().
00459 {
00460 geRDriver_THandle *THandle;
00461 int32 Size;
00462
00463 THandle = GTHandle_FindTextureHandle();
00464
00465 if (!THandle)
00466 {
00467 SetLastDrvError(DRV_ERROR_GENERIC, "GLIDE_CreateTexture: No more handles left.");
00468 return NULL;
00469 }
00470
00471 THandle->Width = Width;
00472 THandle->Height = Height;
00473 THandle->LogSize = Width;
00474 THandle->NumMipLevels = (uint8)NumMipLevels;
00475
00476 Size = Width*Height;
00477
00478 THandle->Data = (uint16*)malloc(sizeof(uint16)*Size);
00479 THandle->PixelFormat = *PixelFormat;
00480
00481 return THandle;
00482 }
|
|
||||||||||||||||||||
|
Definition at line 295 of file GThandle.c. References geRDriver_THandle::Active, geRDriver_THandle::CacheType, geRDriver_THandle::Data, DRV_ERROR_GENERIC, GCache_TypeCreate(), GE_TRUE, geFloat, GetLog(), GlideFormatFromGenesisFormat(), GTHandle_FindTextureHandle(), GTHandle_SetupInfo(), geRDriver_THandle::Height, int32, geRDriver_THandle::Log, geRDriver_THandle::LogSize, NULL, geRDriver_THandle::NumMipLevels, geRDriver_THandle::OneOverLogSize_255, PixelFormat, geRDriver_PixelFormat::PixelFormat, geRDriver_THandle::PixelFormat, SetLastDrvError(), SnapToPower2(), TextureCache, TexturesChanged, uint8, and geRDriver_THandle::Width. Referenced by GTHandle_Create().
00296 {
00297 int32 SWidth, SHeight; // Snapped to power of 2 width/height
00298 GrTexInfo Info;
00299 int32 DataSize;
00300 uint8 *Data;
00301 geRDriver_THandle *THandle;
00302 GrTextureFormat_t Format;
00303
00304 assert(PixelFormat);
00305
00306 Data = NULL;
00307
00308 THandle = GTHandle_FindTextureHandle();
00309
00310 if (!THandle)
00311 {
00312 SetLastDrvError(DRV_ERROR_GENERIC, "GLIDE_Create3DTexture: No more handles left.");
00313 goto ExitWithError;
00314 }
00315
00316 if (Width > 256)
00317 {
00318 SetLastDrvError(DRV_ERROR_GENERIC, "GLIDE_Create3DTexture: Width > 256.");
00319 goto ExitWithError;
00320 }
00321
00322 if (Height > 256)
00323 {
00324 SetLastDrvError(DRV_ERROR_GENERIC, "GLIDE_Create3DTexture: Height > 256.");
00325 goto ExitWithError;
00326 }
00327
00328 SWidth = SnapToPower2(Width);
00329 SHeight = SnapToPower2(Height);
00330
00331 if (Width != SWidth)
00332 {
00333 SetLastDrvError(DRV_ERROR_GENERIC, "GLIDE_Create3DTexture: Not a power of 2.");
00334 goto ExitWithError;
00335 }
00336
00337 if (Height != SHeight)
00338 {
00339 SetLastDrvError(DRV_ERROR_GENERIC, "GLIDE_Create3DTexture: Not a power of 2.");
00340 goto ExitWithError;
00341 }
00342
00343 if (!GlideFormatFromGenesisFormat(PixelFormat->PixelFormat, &Format))
00344 {
00345 SetLastDrvError(DRV_ERROR_GENERIC, "GLIDE_RegisterMiscTexture: GlideFormatFromGenesisFormat failed...");
00346 goto ExitWithError;
00347 }
00348
00349 if (!GTHandle_SetupInfo(&Info, Width, Height, NumMipLevels, Format, &THandle->LogSize))
00350 {
00351 SetLastDrvError(DRV_ERROR_GENERIC, "GLIDE_RegisterMiscTexture: SetupInfo failed...");
00352 goto ExitWithError;
00353 }
00354
00355 THandle->Log = (uint8)GetLog(THandle->LogSize);
00356
00357 // Get the size of the data so we can create a block of memory for it
00358 DataSize = grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &Info);
00359
00360 // Allocate the data
00361 Data = (uint8*)malloc(sizeof(uint8)*DataSize);
00362
00363 if (!Data)
00364 {
00365 SetLastDrvError(DRV_ERROR_GENERIC, "GLIDE_RegisterMiscTexture: out of memory for data.");
00366 goto ExitWithError;
00367 }
00368
00369 #if 0
00370 memset(Data, 0xff, DataSize); // For debugging
00371 #endif
00372
00373 // Save the data pointer...
00374 Info.data = (void*)Data;
00375
00376 // Save the data
00377 THandle->Data = Data;
00378 THandle->Active = GE_TRUE;
00379 THandle->NumMipLevels = (uint8)NumMipLevels;
00380 //THandle->Info = Info;
00381
00382 // Save off some other goot info
00383 THandle->Width = Width; // Original Width
00384 THandle->Height = Height;
00385
00386 THandle->OneOverLogSize_255 = 255.0f / (geFloat)THandle->LogSize;
00387
00388 THandle->CacheType = GCache_TypeCreate(TextureCache, THandle->LogSize, THandle->LogSize, NumMipLevels, &Info);
00389
00390 THandle->PixelFormat = *PixelFormat;
00391
00392 TexturesChanged = GE_TRUE;
00393
00394 return THandle;
00395
00396 ExitWithError:
00397 {
00398 if (Data)
00399 free(Data);
00400
00401 return NULL;
00402 }
00403 }
|
|
||||||||||||||||||||
|
Definition at line 408 of file GThandle.c. References geRDriver_THandle::CacheType, DRV_ERROR_GENERIC, geRDriver_PixelFormat::Flags, GCache_TypeCreate(), GE_FALSE, GE_PIXELFORMAT_16BIT_565_RGB, GE_TRUE, geFloat, GetLog(), GTHandle_FindTextureHandle(), GTHandle_SetupInfo(), geRDriver_THandle::Height, LMapCache, geRDriver_THandle::Log, geRDriver_THandle::LogSize, NULL, geRDriver_THandle::OneOverLogSize_255, PixelFormat, geRDriver_PixelFormat::PixelFormat, RDRIVER_PF_LIGHTMAP, SetLastDrvError(), TexturesChanged, uint8, and geRDriver_THandle::Width. Referenced by GTHandle_Create().
00409 {
00410 geRDriver_THandle *THandle;
00411 geFloat Size;
00412
00413 THandle = GTHandle_FindTextureHandle();
00414
00415 if (!THandle)
00416 {
00417 SetLastDrvError(DRV_ERROR_GENERIC, "GLIDE_CreateLightmapTexture: Max texture handles.");
00418 return NULL;
00419 }
00420
00421 if ( ! (PixelFormat->Flags&RDRIVER_PF_LIGHTMAP) ) // This should be the only bit set (except for Can_Do_ColorKey)
00422 {
00423 SetLastDrvError(DRV_ERROR_GENERIC, "GLIDE_CreateLightmapTexture: Invalid pixel format.");
00424 return NULL;
00425 }
00426
00427 if (PixelFormat->PixelFormat != GE_PIXELFORMAT_16BIT_565_RGB)
00428 {
00429 SetLastDrvError(DRV_ERROR_GENERIC, "GLIDE_CreateLightmapTexture: PixelFormat != GE_PIXELFORMAT_16BIT_565_RGB.");
00430 return NULL;
00431 }
00432
00433 THandle->Width = Width;
00434 THandle->Height = Height;
00435
00436 {
00437 GrTexInfo Info;
00438
00439 if (!GTHandle_SetupInfo(&Info, Width, Height, 1, GR_TEXFMT_RGB_565, &THandle->LogSize))
00440 return GE_FALSE;
00441 THandle->Log = (uint8)GetLog(THandle->LogSize);
00442
00443 THandle->CacheType = GCache_TypeCreate(LMapCache, THandle->LogSize, THandle->LogSize, NumMipLevels, &Info);
00444 }
00445
00446 Size = (geFloat)(THandle->LogSize<<4);
00447
00448 THandle->OneOverLogSize_255 = 255.0f / Size;
00449
00450 TexturesChanged = GE_TRUE;
00451
00452 return THandle;
00453 }
|
|
||||||||||||||||||||
|
Definition at line 487 of file GThandle.c. References geRDriver_THandle::Active, geRDriver_THandle::Data, DRV_ERROR_GENERIC, GE_TRUE, GTHandle_FindTextureHandle(), geRDriver_THandle::Height, int32, geRDriver_THandle::LogSize, NULL, geRDriver_THandle::NumMipLevels, geRDriver_THandle::PixelFormat, geRDriver_PixelFormat::PixelFormat, PixelFormat, SetLastDrvError(), THANDLE_PALETTE_FORMAT, uint32, uint8, and geRDriver_THandle::Width. Referenced by GTHandle_Create().
00488 {
00489 int32 DataSize;
00490 uint32 *Data;
00491 geRDriver_THandle *THandle;
00492 GrTextureFormat_t Format;
00493
00494 assert(PixelFormat);
00495
00496 Data = NULL;
00497
00498 THandle = GTHandle_FindTextureHandle();
00499
00500 if (!THandle)
00501 {
00502 SetLastDrvError(DRV_ERROR_GENERIC, "GLIDE_CreatePalTexture: No more handles left.");
00503 goto ExitWithError;
00504 }
00505
00506 assert(Width == 256);
00507 assert(Height == 1);
00508 assert(NumMipLevels == 1);
00509
00510 switch (PixelFormat->PixelFormat)
00511 {
00512 case THANDLE_PALETTE_FORMAT:
00513 {
00514 Format = GR_TEXFMT_P_8;
00515 break;
00516 }
00517
00518 default:
00519 {
00520 SetLastDrvError(DRV_ERROR_GENERIC, "GLIDE_CreatePalTexture: Invalid pixel format.");
00521 goto ExitWithError;
00522 }
00523 }
00524
00525 // Allocate the data
00526 DataSize = sizeof(uint32)*256;
00527
00528 Data = (uint32*)malloc(DataSize);
00529
00530 if (!Data)
00531 {
00532 SetLastDrvError(DRV_ERROR_GENERIC, "GLIDE_RegisterMiscTexture: out of memory for data.");
00533 goto ExitWithError;
00534 }
00535
00536 #if 0
00537 memset(Data, 0xff, DataSize); // For debugging
00538 #endif
00539
00540 // Save the data
00541 THandle->Data = Data;
00542 THandle->Active = GE_TRUE;
00543 THandle->NumMipLevels = (uint8)NumMipLevels;
00544
00545 THandle->Width = Width; // Original Width
00546 THandle->Height = Height;
00547 THandle->LogSize = Width;
00548 THandle->PixelFormat = *PixelFormat;
00549
00550 return THandle;
00551
00552 ExitWithError:
00553 {
00554 if (Data)
00555 free(Data);
00556
00557 return NULL;
00558 }
00559 }
|
|
||||||||||||||||
|
Definition at line 780 of file GThandle.c. References GE_FALSE, GE_TRUE, and geBoolean. Referenced by GTHandle_SetupInfo().
00781 {
00782 int Aspect2;
00783
00784 Aspect2 = ( 8 * Width ) / Height;
00785
00786 switch( Aspect2)
00787 {
00788 case 64:
00789 *Aspect = GR_ASPECT_8x1;
00790 break;
00791 case 32:
00792 *Aspect = GR_ASPECT_4x1;
00793 break;
00794 case 16:
00795 *Aspect = GR_ASPECT_2x1;
00796 break;
00797 case 8:
00798 *Aspect = GR_ASPECT_1x1;
00799 break;
00800 case 4:
00801 *Aspect = GR_ASPECT_1x2;
00802 break;
00803 case 2:
00804 *Aspect = GR_ASPECT_1x4;
00805 break;
00806 case 1:
00807 *Aspect = GR_ASPECT_1x8;
00808 break;
00809
00810 default:
00811 return GE_FALSE;
00812 }
00813
00814 return GE_TRUE;
00815 }
|
|
||||||||||||
|
Definition at line 748 of file GThandle.c. References DRV_ERROR_GENERIC, GE_FALSE, GE_TRUE, geBoolean, and SetLastDrvError(). Referenced by GTHandle_SetupInfo().
00749 {
00750 if (Width == 1)
00751 *Lod = GR_LOD_1;
00752 else if (Width == 2)
00753 *Lod = GR_LOD_2;
00754 else if (Width == 4)
00755 *Lod = GR_LOD_4;
00756 else if (Width == 8)
00757 *Lod = GR_LOD_8;
00758 else if (Width == 16)
00759 *Lod = GR_LOD_16;
00760 else if (Width == 32)
00761 *Lod = GR_LOD_32;
00762 else if (Width == 64)
00763 *Lod = GR_LOD_64;
00764 else if (Width == 128)
00765 *Lod = GR_LOD_128;
00766 else if (Width == 256)
00767 *Lod = GR_LOD_256;
00768 else
00769 {
00770 SetLastDrvError(DRV_ERROR_GENERIC, "GLIDE_GetLod: Invalid texture width.");
00771 return GE_FALSE;
00772 }
00773
00774 return GE_TRUE;
00775 }
|
|
|
Definition at line 820 of file GThandle.c.
|
|
||||||||||||
|
Definition at line 249 of file GThandle.c. References GE_FALSE, GE_PIXELFORMAT_16BIT_1555_ARGB, GE_PIXELFORMAT_16BIT_4444_ARGB, GE_PIXELFORMAT_16BIT_565_RGB, GE_PIXELFORMAT_8BIT, GE_TRUE, and geBoolean. Referenced by Create3DTexture(), and SetupTexture().
00250 {
00251 switch(Format)
00252 {
00253 case GE_PIXELFORMAT_16BIT_565_RGB:
00254 {
00255 *Out = GR_TEXFMT_RGB_565;
00256 break;
00257 }
00258 case GE_PIXELFORMAT_16BIT_4444_ARGB:
00259 {
00260 *Out = GR_TEXFMT_ARGB_4444;
00261 break;
00262
00263 }
00264 case GE_PIXELFORMAT_16BIT_1555_ARGB:
00265 {
00266 *Out = GR_TEXFMT_ARGB_1555;
00267 break;
00268
00269 }
00270 case GE_PIXELFORMAT_8BIT:
00271 {
00272 #ifdef ALPHA_PALETTE
00273 *Out = GR_TEXFMT_AP_88;
00274 #else
00275 *Out = GR_TEXFMT_P_8;
00276 #endif
00277 break;
00278 }
00279
00280 default:
00281 {
00282 assert(!"GlideFormatFromGenesisFormat: Invalid Pixel format.");
00283 *Out = GE_PIXELFORMAT_8BIT;
00284 return GE_FALSE;
00285 }
00286 }
00287
00288 return GE_TRUE;
00289 }
|
|
|
Definition at line 712 of file GThandle.c. References DRV_ERROR_INVALID_REGISTER_MODE, GCache_AdjustSlots(), GE_FALSE, GE_TRUE, geBoolean, int32, LMapCache, MAX_TEXTURE_HANDLES, NULL, SetLastDrvError(), geRDriver_THandle::Slot, TextureCache, TextureHandles, and TexturesChanged. Referenced by BeginScene(), SetupLMapTexture(), and SetupTexture().
00713 {
00714 int32 i;
00715 geRDriver_THandle *pTHandle;
00716
00717 if (!TexturesChanged)
00718 return GE_TRUE;
00719
00720 if (!GCache_AdjustSlots(TextureCache))
00721 {
00722 SetLastDrvError(DRV_ERROR_INVALID_REGISTER_MODE, "GTHandle_CheckTextures: GCache_AdjustSlots for textures.");
00723 return GE_FALSE;
00724 }
00725
00726 if (!GCache_AdjustSlots(LMapCache))
00727 {
00728 SetLastDrvError(DRV_ERROR_INVALID_REGISTER_MODE, "GTHandle_CheckTextures: GCache_AdjustSlots for lightmaps.");
00729 return GE_FALSE;
00730 }
00731
00732 // Make sure no THandles reference any slots, because they mave have been moved around, or gotten destroyed...
00733 // (Evict all textures in the cache)
00734 pTHandle = TextureHandles;
00735
00736 for (i=0; i< MAX_TEXTURE_HANDLES; i++, pTHandle++)
00737 pTHandle->Slot = NULL;
00738
00739 // Reset the tedxture handle changed boolean
00740 TexturesChanged = GE_FALSE;
00741
00742 return GE_TRUE;
00743 }
|
|
||||||||||||||||||||
|
Definition at line 564 of file GThandle.c. References Create2DTexture(), Create3DTexture(), CreateLightmapTexture(), CreatePalTexture(), DRIVERCC, DRV_ERROR_GENERIC, geRDriver_PixelFormat::Flags, GE_FALSE, PixelFormat, RDRIVER_PF_2D, RDRIVER_PF_3D, RDRIVER_PF_LIGHTMAP, RDRIVER_PF_PALETTE, and SetLastDrvError().
00565 {
00566 if (PixelFormat->Flags & RDRIVER_PF_2D)
00567 return Create2DTexture(Width, Height, NumMipLevels, PixelFormat);
00568 else if (PixelFormat->Flags & RDRIVER_PF_3D)
00569 return Create3DTexture(Width, Height, NumMipLevels, PixelFormat);
00570 else if (PixelFormat->Flags & RDRIVER_PF_LIGHTMAP)
00571 return CreateLightmapTexture(Width, Height, NumMipLevels, PixelFormat);
00572 else if (PixelFormat->Flags & RDRIVER_PF_PALETTE)
00573 return CreatePalTexture(Width, Height, NumMipLevels, PixelFormat);
00574 else
00575 {
00576 SetLastDrvError(DRV_ERROR_GENERIC, "GLIDE_CreateTexture: Invalid pixelformat.");
00577 return GE_FALSE;
00578 }
00579 }
|
|
|
Definition at line 584 of file GThandle.c. References DRIVERCC, GE_TRUE, geBoolean, and GTHandle_FreeTextureHandle().
00585 {
00586 GTHandle_FreeTextureHandle(THandle);
00587
00588 return GE_TRUE;
00589 }
|
|
|
Definition at line 142 of file GThandle.c. References geRDriver_THandle::Active, geRDriver_THandle::Data, GE_TRUE, int32, MAX_TEXTURE_HANDLES, NULL, and TextureHandles. Referenced by Create2DTexture(), Create3DTexture(), CreateLightmapTexture(), and CreatePalTexture().
00143 {
00144 int32 i;
00145 geRDriver_THandle *THandle;
00146
00147 THandle = TextureHandles;
00148
00149 for (i=0; i< MAX_TEXTURE_HANDLES; i++, THandle++)
00150 {
00151 if (!THandle->Active)
00152 {
00153 assert(THandle->Data == NULL);
00154
00155 memset(THandle, 0, sizeof(geRDriver_THandle));
00156
00157 THandle->Active = GE_TRUE;
00158
00159 return THandle;
00160 }
00161 }
00162
00163 return NULL;
00164 }
|
|
|
Definition at line 120 of file GThandle.c. References GCache_Destroy(), GMemMgr_Destroy(), LMapCache, MemMgr, NULL, and TextureCache. Referenced by GTHandle_Shutdown(), and GTHandle_Startup().
00121 {
00122 if (LMapCache)
00123 GCache_Destroy(LMapCache);
00124 if (TextureCache)
00125 GCache_Destroy(TextureCache);
00126
00127 TextureCache = NULL;
00128 LMapCache = NULL;
00129
00130 if (MemMgr[1])
00131 GMemMgr_Destroy(MemMgr[1]);
00132 if (MemMgr[0])
00133 GMemMgr_Destroy(MemMgr[0]);
00134
00135 MemMgr[0] = NULL;
00136 MemMgr[1] = NULL;
00137 }
|
|
|
Definition at line 189 of file GThandle.c. References geRDriver_THandle::Active, geRDriver_THandle::Data, GTHandle_FreeTextureHandle(), int32, MAX_TEXTURE_HANDLES, NULL, and TextureHandles. Referenced by GTHandle_Shutdown(), and GTHandle_Startup().
00190 {
00191 int32 i;
00192 geRDriver_THandle *pTHandle;
00193
00194 pTHandle = TextureHandles;
00195
00196 for (i=0; i< MAX_TEXTURE_HANDLES; i++, pTHandle++)
00197 {
00198 if (!pTHandle->Active)
00199 {
00200 assert(pTHandle->Data == NULL);
00201 continue;
00202 }
00203
00204 GTHandle_FreeTextureHandle(pTHandle);
00205 }
00206 }
|
|
|
Definition at line 169 of file GThandle.c. References geRDriver_THandle::Active, geRDriver_THandle::CacheType, geRDriver_THandle::Data, GCache_TypeDestroy(), GE_TRUE, and TexturesChanged. Referenced by GTHandle_Destroy(), and GTHandle_FreeAllTextureHandles().
00170 {
00171 assert(THandle);
00172 assert(THandle->Active == GE_TRUE);
00173
00174 if (THandle->Data)
00175 free(THandle->Data);
00176
00177 if (THandle->CacheType)
00178 {
00179 GCache_TypeDestroy(THandle->CacheType);
00180 TexturesChanged = GE_TRUE;
00181 }
00182
00183 memset(THandle, 0, sizeof(geRDriver_THandle));
00184 }
|
|
||||||||||||||||
|
|
Definition at line 675 of file GThandle.c. References DRIVERCC, and geRDriver_THandle::PalHandle.
00676 {
00677 return THandle->PalHandle;
00678 }
|
|
||||||||||||||||
|
Definition at line 594 of file GThandle.c. References geRDriver_THandle::Data, DRIVERCC, DRV_ERROR_GENERIC, geRDriver_PixelFormat::Flags, geRDriver_THandle::Flags, GE_FALSE, GE_PIXELFORMAT_8BIT, GE_TRUE, geBoolean, int32, geRDriver_THandle::LogSize, geRDriver_THandle::PixelFormat, geRDriver_PixelFormat::PixelFormat, RDRIVER_PF_LIGHTMAP, SetLastDrvError(), THANDLE_LOCKED, uint16, and uint8.
00595 {
00596 int32 i, Size;
00597 uint16 *pData;
00598 uint8 *pData8;
00599
00600 assert(MipLevel <= THandle->NumMipLevels);
00601
00602 if (THandle->PixelFormat.Flags & RDRIVER_PF_LIGHTMAP)
00603 {
00604 SetLastDrvError(DRV_ERROR_GENERIC, "GLIDE_LockTextureHandle: Attempt to lock a lightmap texture.");
00605 return GE_FALSE;
00606 }
00607
00608 THandle->Flags |= THANDLE_LOCKED; // This texture is now locked
00609
00610 Size = THandle->LogSize*THandle->LogSize;
00611
00612 if (THandle->PixelFormat.PixelFormat == GE_PIXELFORMAT_8BIT)
00613 {
00614 pData8 = (uint8*)THandle->Data;
00615
00616 for (i=0; i<MipLevel; i++)
00617 {
00618 pData8 += Size;
00619 Size >>=2;
00620 }
00621
00622 *Data = pData8;
00623 }
00624 else
00625 {
00626 pData = (uint16*)THandle->Data;
00627
00628 for (i=0; i<MipLevel; i++)
00629 {
00630 pData += Size;
00631 Size >>=2;
00632 }
00633
00634 *Data = pData;
00635 }
00636
00637 return GE_TRUE;
00638 }
|
|
||||||||||||
|
Definition at line 659 of file GThandle.c. References DRIVERCC, geRDriver_PixelFormat::Flags, GE_TRUE, geBoolean, geRDriver_THandle::Height, geRDriver_THandle::LogSize, geRDriver_THandle::PalHandle, geRDriver_THandle::PixelFormat, geRDriver_PixelFormat::PixelFormat, RDRIVER_PF_PALETTE, THANDLE_PALETTE_FORMAT, and geRDriver_THandle::Width.
00660 {
00661 assert(PalHandle->PixelFormat.PixelFormat == THANDLE_PALETTE_FORMAT);
00662 assert(PalHandle->PixelFormat.Flags & RDRIVER_PF_PALETTE);
00663 assert(PalHandle->Width = 256);
00664 assert(PalHandle->LogSize = 256);
00665 assert(PalHandle->Height = 1);
00666
00667 THandle->PalHandle = PalHandle;
00668
00669 return GE_TRUE;
00670 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 211 of file GThandle.c. References DRV_ERROR_GENERIC, GE_FALSE, GE_TRUE, geBoolean, GetAspectRatio(), GetLod(), int32, max, SetLastDrvError(), and SnapToPower2(). Referenced by Create3DTexture(), and CreateLightmapTexture().
00212 {
00213 GrLOD_t LLod, SLod;
00214 GrAspectRatio_t Ratio;
00215 int32 SquareSize;
00216
00217 SquareSize = max(Width, Height);
00218 SquareSize = SnapToPower2(SquareSize);
00219
00220 if (!GetLod(SquareSize, &LLod))
00221 return GE_FALSE;
00222
00223 if (!GetLod((SquareSize>>(NumMipLevels-1)), &SLod))
00224 return GE_FALSE;
00225
00226 #if 1
00227 Ratio = GR_ASPECT_1x1;
00228 #else
00229 if (!GetAspectRatio(SquareSize, SquareSize, &Ratio))
00230 {
00231 SetLastDrvError(DRV_ERROR_GENERIC, "GLIDE_SetupInfo: Invalid aspect ratio.");
00232 return GE_FALSE;
00233 }
00234 #endif
00235
00236 *Size = SquareSize;
00237
00238 Info->largeLod = LLod;
00239 Info->smallLod = SLod;
00240 Info->aspectRatio = Ratio;
00241 Info->format = Format;
00242
00243 return GE_TRUE;
00244 }
|
|
|
Definition at line 107 of file GThandle.c. References GE_FALSE, GTHandle_FreeAllCaches(), GTHandle_FreeAllTextureHandles(), LMapsChanged, and TexturesChanged. Referenced by GMain_ResetAll(), and GMain_Shutdown().
00108 {
00109 // Free all the texture handles first!!!
00110 GTHandle_FreeAllTextureHandles();
00111 // Then free all the caches
00112 GTHandle_FreeAllCaches();
00113
00114 TexturesChanged = GE_FALSE;
00115 LMapsChanged = GE_FALSE;
00116 }
|
|
|
Definition at line 49 of file GThandle.c. References g_BoardInfo, GCache_Create(), GE_FALSE, GE_TRUE, geBoolean, geFloat, GMemMgr_Create(), GTHandle_FreeAllCaches(), GTHandle_FreeAllTextureHandles(), LMapCache, MemMgr, GMain_BoardInfo::NumTMU, TEXTURE_CACHE_PERCENT, TextureCache, TMU, and uint32. Referenced by GMain_ResetAll(), and GMain_Startup().
00050 {
00051 if (g_BoardInfo.NumTMU >= 2)
00052 {
00053 TMU[0] = GR_TMU0;
00054 TMU[1] = GR_TMU1;
00055
00056 MemMgr[0] = GMemMgr_Create(GR_TMU0, grTexMinAddress(GR_TMU0), grTexMaxAddress(GR_TMU0));
00057 if (!MemMgr[0])
00058 goto ExitWithError;
00059 MemMgr[1] = GMemMgr_Create(GR_TMU1, grTexMinAddress(GR_TMU1), grTexMaxAddress(GR_TMU1));
00060 if (!MemMgr[1])
00061 goto ExitWithError;
00062
00063 }
00064 else
00065 {
00066 uint32 MinAddress, MaxAddress, MidAddress;
00067
00068 TMU[0] = GR_TMU0;
00069 TMU[1] = GR_TMU0;
00070
00071 MinAddress = grTexMinAddress(GR_TMU0);
00072 MaxAddress = grTexMaxAddress(GR_TMU0);
00073 MidAddress = MinAddress + (uint32)((geFloat)(MaxAddress - MinAddress)*TEXTURE_CACHE_PERCENT);
00074
00075 MemMgr[0] = GMemMgr_Create(GR_TMU0, MinAddress, MidAddress);
00076 if (!MemMgr[0])
00077 goto ExitWithError;
00078 MemMgr[1] = GMemMgr_Create(GR_TMU0, MidAddress+1, MaxAddress);
00079 if (!MemMgr[1])
00080 goto ExitWithError;
00081 }
00082
00083 TextureCache = GCache_Create("Texture Cache", MemMgr[0]);
00084
00085 if (!TextureCache)
00086 goto ExitWithError;
00087
00088 LMapCache = GCache_Create("Lightmap Cache", MemMgr[1]);
00089
00090 if (!LMapCache)
00091 goto ExitWithError;
00092
00093 return GE_TRUE;
00094
00095 ExitWithError:
00096 {
00097 GTHandle_FreeAllTextureHandles();
00098 GTHandle_FreeAllCaches();
00099
00100 return GE_FALSE;
00101 }
00102 }
|
|
||||||||||||
|
Definition at line 643 of file GThandle.c. References DRIVERCC, geRDriver_THandle::Flags, GE_TRUE, geBoolean, THANDLE_LOCKED, and THANDLE_UPDATE.
00644 {
00645 #pragma message ("FIXME: Flags needs to be per-mip!!!")
00646
00647 //if (!(THandle->Flags & THANDLE_LOCKED))
00648 // return GE_FALSE;
00649
00650 THandle->Flags &= ~THANDLE_LOCKED; // This handle is now unlocked
00651 THandle->Flags |= THANDLE_UPDATE; // Mark it for updating...
00652
00653 return GE_TRUE;
00654 }
|
|
|
Definition at line 834 of file GThandle.c. References int32.
00835 {
00836 int RetWidth;
00837 // CB : I couldn't stand that big branch of if's !
00838 for ( RetWidth = 1; RetWidth < Width; RetWidth <<= 1 ) ;
00839 assert( RetWidth <= 256 );
00840 return RetWidth;
00841 }
|
|
|
Definition at line 39 of file GThandle.c. |
|
|
Definition at line 44 of file GThandle.c. Referenced by GTHandle_Shutdown(). |
|
|
Definition at line 35 of file GThandle.c. |
|
|
Definition at line 38 of file GThandle.c. |
|
|
Definition at line 41 of file GThandle.c. |
|
|
Definition at line 43 of file GThandle.c. Referenced by Create3DTexture(), CreateLightmapTexture(), GTHandle_CheckTextures(), GTHandle_FreeTextureHandle(), and GTHandle_Shutdown(). |
1.3.2