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

GTHandle.h

Go to the documentation of this file.
00001 /****************************************************************************************/
00002 /*  GTHandle.h                                                                          */
00003 /*                                                                                      */
00004 /*  Author: John Pollard                                                                */
00005 /*  Description: THandle manager for glide                                              */
00006 /*                                                                                      */
00007 /*  The contents of this file are subject to the Genesis3D Public License               */
00008 /*  Version 1.01 (the "License"); you may not use this file except in                   */
00009 /*  compliance with the License. You may obtain a copy of the License at                */
00010 /*  http://www.genesis3d.com                                                            */
00011 /*                                                                                      */
00012 /*  Software distributed under the License is distributed on an "AS IS"                 */
00013 /*  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See                */
00014 /*  the License for the specific language governing rights and limitations              */
00015 /*  under the License.                                                                  */
00016 /*                                                                                      */
00017 /*  The Original Code is Genesis3D, released March 25, 1999.                            */
00018 /*  Genesis3D Version 1.1 released November 15, 1999                                 */
00019 /*  Copyright (C) 1999 WildTangent, Inc. All Rights Reserved           */
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 // THandle flags
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;                          // Original width/height
00064         int32                                   Height;
00065         int32                                   LogSize;                        // Square width/height in cache
00066         uint8                                   NumMipLevels;
00067         geFloat                                 OneOverLogSize_255;
00068         uint8                                   Log;
00069         geRDriver_PixelFormat   PixelFormat;
00070         //GrTexInfo                             Info;
00071         //uint16                                InfoIndex;                      // Use this ASAP!!!
00072 
00073         void                                    *Data;                          // Actual data bits of LogSize*LogSize
00074 
00075         GCache_Type                             *CacheType;
00076         GCache_Slot                             *Slot;                          // Current slot this handle is being textured with
00077 
00078         uint8                                   Flags;                  
00079 } geRDriver_THandle;
00080 
00081 extern geRDriver_THandle        TextureHandles[MAX_TEXTURE_HANDLES];
00082 
00083 // Memory managers
00084 extern GMemMgr                          *MemMgr[2];
00085 
00086 // Texture caches
00087 extern GCache                           *TextureCache;                  // Texture cache
00088 extern GCache                           *LMapCache;                             // Lightmap texture cache
00089 
00090 extern geRDriver_THandle        TextureHandles[MAX_TEXTURE_HANDLES];            // Contain Texture/Decal/Lightmap 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

Generated on Tue Sep 30 12:35:55 2003 for GTestAndEngine by doxygen 1.3.2