00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef THANDLE_H
00023 #define THANDLE_H
00024
00025 #include <Windows.h>
00026
00027 #include "DCommon.h"
00028 #include "BaseType.h"
00029 #include "GCache.h"
00030 #include "Glide.h"
00031
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif
00035
00036 #define MAX_TEXTURE_HANDLES 20000
00037
00038
00039 #define THANDLE_UPDATE (1<<0) // Force a thandle to be uploaded to the card
00040 #define THANDLE_LOCKED (1<<1) // THandle is currently locked (invalid for rendering etc)
00041
00042 #define THANDLE_PALETTE_FORMAT (GE_PIXELFORMAT_32BIT_XRGB)
00043
00044
00045
00046 typedef struct
00047 {
00048 int32 RefCount;
00049 int32 Width;
00050 int32 Height;
00051 int32 LogSize;
00052 uint8 NumMipLevels;
00053 geRDriver_PixelFormat PixelFormat;
00054
00055 uint8 Log;
00056 geFloat OneOverLogSize_255;
00057 } THandle_Info;
00058
00059 typedef struct geRDriver_THandle
00060 {
00061 uint8 Active;
00062 struct geRDriver_THandle *PalHandle;
00063 int32 Width;
00064 int32 Height;
00065 int32 LogSize;
00066 uint8 NumMipLevels;
00067 geFloat OneOverLogSize_255;
00068 uint8 Log;
00069 geRDriver_PixelFormat PixelFormat;
00070
00071
00072
00073 void *Data;
00074
00075 GCache_Type *CacheType;
00076 GCache_Slot *Slot;
00077
00078 uint8 Flags;
00079 } geRDriver_THandle;
00080
00081 extern geRDriver_THandle TextureHandles[MAX_TEXTURE_HANDLES];
00082
00083
00084 extern GMemMgr *MemMgr[2];
00085
00086
00087 extern GCache *TextureCache;
00088 extern GCache *LMapCache;
00089
00090 extern geRDriver_THandle TextureHandles[MAX_TEXTURE_HANDLES];
00091
00092 extern geBoolean TexturesChanged;
00093 extern geBoolean LMapsChanged;
00094
00095
00096
00097 geBoolean GTHandle_Startup(void);
00098 void GTHandle_Shutdown(void);
00099 void GTHandle_FreeAllCaches(void);
00100 geRDriver_THandle *GTHandle_FindTextureHandle();
00101 void GTHandle_FreeTextureHandle(geRDriver_THandle *THandle);
00102 void GTHandle_FreeAllTextureHandles(void);
00103 geBoolean GTHandle_SetupInfo(GrTexInfo *Info, int32 Width, int32 Height, int32 NumMipLevels, GrTextureFormat_t Format, int32 *Size);
00104 geBoolean GlideFormatFromGenesisFormat(gePixelFormat Format, GrTextureFormat_t *Out);
00105 geRDriver_THandle *Create3DTexture(int32 Width, int32 Height, int32 NumMipLevels, const geRDriver_PixelFormat *PixelFormat);
00106 geRDriver_THandle *CreateLightmapTexture(int32 Width, int32 Height, int32 NumMipLevels, const geRDriver_PixelFormat *PixelFormat);
00107 geRDriver_THandle *Create2DTexture(int32 Width, int32 Height, int32 NumMipLevels, const geRDriver_PixelFormat *PixelFormat);
00108 geRDriver_THandle *DRIVERCC GTHandle_Create(int32 Width, int32 Height, int32 NumMipLevels, const geRDriver_PixelFormat *PixelFormat);
00109 geBoolean DRIVERCC GTHandle_Destroy(geRDriver_THandle *THandle);
00110 geBoolean DRIVERCC GTHandle_Lock(geRDriver_THandle *THandle, int32 MipLevel, void **Data);
00111 geBoolean DRIVERCC GTHandle_UnLock(geRDriver_THandle *THandle, int32 MipLevel);
00112 geBoolean DRIVERCC GThandle_SetPal(geRDriver_THandle *THandle, geRDriver_THandle *PalHandle);
00113 geRDriver_THandle *DRIVERCC GThandle_GetPal(geRDriver_THandle *THandle);
00114 geBoolean DRIVERCC GTHandle_GetInfo(geRDriver_THandle *THandle, int32 MipLevel, geRDriver_THandleInfo *Info);
00115 geBoolean GTHandle_CheckTextures(void);
00116 geBoolean GetLod(S32 Width, GrLOD_t *Lod);
00117 geBoolean GetAspectRatio(int32 Width, int32 Height, GrAspectRatio_t *Aspect);
00118 uint32 GetLog(uint32 P2);
00119 int32 SnapToPower2(int32 Width);
00120
00121 #ifdef __cplusplus
00122 }
00123 #endif
00124
00125 #endif