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

Render.c File Reference

#include <assert.h>
#include <Math.h>
#include "Render.h"
#include "GMain.h"
#include "GlideDrv.h"
#include "GSpan.h"
#include "GTHandle.h"

Go to the source code of this file.

Defines

#define ENABLE_WIREFRAME
#define MAX_LMAP_SIZE   32
#define SNAP_VERT(v)   ( ( geFloat )( ( long )( ( v ) * 16 ) ) * 0.0625f )
#define RENDER_MAX_PNTS   (64)

Enumerations

enum  Render_ColorCombine {
  ColorCombine_Undefined, ColorCombine_Gouraud, ColorCombine_Texture, ColorCombine_TextureGouraud,
  ColorCombine_TextureGouraudWithFog
}
enum  Render_TexCombine {
  TexCombine_Undefined, TexCombine_SinglePassGouraud, TexCombine_SinglePassTexture, TexCombine_SimultaneousPass,
  TexCombine_PassThrough
}

Functions

void TextureSource (GrChipID_t Tmu, FxU32 startAddress, FxU32 evenOdd, GrTexInfo *info)
void Render_SetColorCombine (Render_ColorCombine ColorCombine)
void Render_SetTexCombine (Render_TexCombine TexCombine)
void Render_SetHardwareMode (int32 NewMode, uint32 NewFlags)
geBoolean DRIVERCC Render_GouraudPoly (DRV_TLVertex *Pnts, int32 NumPoints, uint32 Flags)
geBoolean DRIVERCC Render_LinesPoly (DRV_TLVertex *Pnts, int32 NumPoints)
geBoolean DRIVERCC Render_WorldPoly (DRV_TLVertex *Pnts, int32 NumPoints, geRDriver_THandle *THandle, DRV_TexInfo *TexInfo, DRV_LInfo *LInfo, uint32 Flags)
void RenderLightmapPoly (GrVertex *vrtx, int32 NumPoints, DRV_LInfo *LInfo, geBoolean Dynamic, uint32 Flags)
void DownloadLightmap (DRV_LInfo *LInfo, int32 Wh, GCache_Slot *Slot, int32 LMapNum)
geBoolean DRIVERCC Render_MiscTexturePoly (DRV_TLVertex *Pnts, int32 NumPoints, geRDriver_THandle *THandle, uint32 Flags)
void SetupTexture (geRDriver_THandle *THandle)
GCache_SlotSetupLMapTexture (geRDriver_THandle *THandle, DRV_LInfo *LInfo, geBoolean Dynamic, int32 LMapNum)
geBoolean DRIVERCC Render_DrawDecal (geRDriver_THandle *THandle, RECT *SRect, int32 x, int32 y)
geBoolean DRIVERCC BeginScene (geBoolean Clear, geBoolean ClearZ, RECT *WorldRect)
geBoolean DRIVERCC EndScene (void)
geBoolean DRIVERCC BeginWorld (void)
geBoolean DRIVERCC EndWorld (void)
geBoolean DRIVERCC BeginMeshes (void)
geBoolean DRIVERCC EndMeshes (void)
geBoolean DRIVERCC BeginModels (void)
geBoolean DRIVERCC EndModels (void)

Variables

int DoWireFrame = 0
DRV_RENDER_MODE RenderMode = RENDER_NONE
Render_ColorCombine Render_OldColorCombine = ColorCombine_Undefined
Render_TexCombine Render_OldTexCombine = TexCombine_Undefined
int32 Render_HardwareMode = RENDER_UNKNOWN_MODE
uint32 Render_HardwareFlags = 0
uint32 PolyMode = DRV_POLYMODE_NORMAL
DRV_CacheInfo CacheInfo
uint32 CurrentLRU
 g_FogEnable
FxU32 LastTextureAddr [2] = {(FxU32)-1, (FxU32)-1}
geRDriver_THandleOldPalHandle


Define Documentation

#define ENABLE_WIREFRAME
 

Definition at line 31 of file GlideDrv/Render.c.

#define MAX_LMAP_SIZE   32
 

Definition at line 37 of file GlideDrv/Render.c.

Referenced by DownloadLightmap(), and GetSurfInfo().

#define RENDER_MAX_PNTS   (64)
 

Definition at line 41 of file GlideDrv/Render.c.

Referenced by Render_GouraudPoly(), Render_LinesPoly(), Render_MiscTexturePoly(), and Render_WorldPoly().

#define SNAP_VERT v   )     ( ( geFloat )( ( long )( ( v ) * 16 ) ) * 0.0625f )
 

Definition at line 39 of file GlideDrv/Render.c.


Enumeration Type Documentation

enum Render_ColorCombine
 

Enumeration values:
ColorCombine_Undefined 
ColorCombine_Gouraud 
ColorCombine_Texture 
ColorCombine_TextureGouraud 
ColorCombine_TextureGouraudWithFog 

Definition at line 43 of file GlideDrv/Render.c.

enum Render_TexCombine
 

Enumeration values:
TexCombine_Undefined 
TexCombine_SinglePassGouraud 
TexCombine_SinglePassTexture 
TexCombine_SimultaneousPass 
TexCombine_PassThrough 

Definition at line 52 of file GlideDrv/Render.c.


Function Documentation

geBoolean DRIVERCC BeginMeshes void   ) 
 

Definition at line 1378 of file GlideDrv/Render.c.

References DRIVERCC, geBoolean, RENDER_MESHES, RenderMode, and TRUE.

01379 {
01380         
01381         RenderMode = RENDER_MESHES;
01382 
01383         return TRUE;
01384 }

geBoolean DRIVERCC BeginModels void   ) 
 

Definition at line 1393 of file GlideDrv/Render.c.

References DRIVERCC, geBoolean, RENDER_MODELS, RenderMode, and TRUE.

01394 {
01395 
01396         RenderMode = RENDER_MODELS;
01397 
01398         return TRUE;
01399 }

geBoolean DRIVERCC BeginScene geBoolean  Clear,
geBoolean  ClearZ,
RECT WorldRect
 

Definition at line 1285 of file GlideDrv/Render.c.

01286 {
01287         memset(&CacheInfo, 0, sizeof(DRV_CacheInfo));
01288 
01289 #ifdef ENABLE_WIREFRAME 
01290         {
01291                 uint32 KeyState1, KeyState2;
01292                 
01293                 #pragma message("Glide : WireFrame enabled!")
01294                 KeyState1 = GetAsyncKeyState(VK_CONTROL) & 0x8001;
01295                 KeyState2 = GetAsyncKeyState(VK_F8) & 0x8001;
01296                 if (KeyState1 && KeyState2)
01297                 {
01298                         DoWireFrame ^= 1;
01299                 }
01300         }
01301 
01302         if (DoWireFrame)
01303         {
01304                 Clear = GE_TRUE;
01305                 ClearZ = GE_TRUE;
01306         }
01307 #endif
01308         
01309         if (!GTHandle_CheckTextures())
01310                 return GE_FALSE;
01311 
01312         // FIXME:       Make clear zbuffer and frame buffer seperate
01313         if (Clear)
01314                 grColorMask(FXTRUE, FXFALSE);
01315         else
01316                 grColorMask(FXFALSE, FXFALSE);
01317 
01318         
01319         if (g_FogEnable)
01320                 grBufferClear(((uint32)g_FogB<<16)|((uint32)g_FogG<<8)|(uint32)g_FogR, 0, GR_ZDEPTHVALUE_FARTHEST);
01321         else
01322                 grBufferClear(0, 0, GR_ZDEPTHVALUE_FARTHEST);
01323 
01324         grColorMask(FXTRUE, FXTRUE);
01325 
01326         GLIDEDRV.NumRenderedPolys = 0;
01327         
01328         CurrentLRU++;
01329 
01330         return TRUE;
01331 }

geBoolean DRIVERCC BeginWorld void   ) 
 

Definition at line 1353 of file GlideDrv/Render.c.

References ClientWindow, DRIVERCC, geBoolean, GLIDEDRV, DRV_Window::Height, DRV_Driver::NumWorldPixels, NumWorldPixels, DRV_Driver::NumWorldSpans, RENDER_WORLD, RenderMode, ResetSpans(), and TRUE.

01354 {
01355 
01356         ResetSpans(ClientWindow.Height);
01357         NumWorldPixels = 0;
01358 
01359         GLIDEDRV.NumWorldPixels = 0;
01360         GLIDEDRV.NumWorldSpans = 0;
01361 
01362         RenderMode = RENDER_WORLD;
01363 
01364         return TRUE;
01365 }

void DownloadLightmap DRV_LInfo LInfo,
int32  Wh,
GCache_Slot Slot,
int32  LMapNum
 

Definition at line 982 of file GlideDrv/Render.c.

References GCache_SlotGetInfo(), GCache_UpdateSlot(), DRV_LInfo::Height, int32, LMapCache, MAX_LMAP_SIZE, r, DRV_LInfo::RGBLight, uint16, uint8, and DRV_LInfo::Width.

Referenced by RenderLightmapPoly(), and SetupLMapTexture().

00983 {
00984         uint16                  TempL[MAX_LMAP_SIZE*MAX_LMAP_SIZE];                     // Temp to hold converted 565 lightmap
00985         int32                   w,h;
00986         uint16                  *pTempP = TempL;
00987         uint8                   r,g,b;
00988         uint8                   *Bits;
00989         int32                   W = LInfo->Width;
00990         int32                   H = LInfo->Height;
00991         GrTexInfo               *Info;
00992 
00993         //memset(TempL, 0, sizeof(uint6)*32*32);
00994         Bits = (uint8*)LInfo->RGBLight[LMapNum];
00995 
00996         for (h = 0; h< H; h++)
00997         {
00998                 for (w = 0; w< W; w++)
00999                 {
01000                         r = *(Bits++);
01001                         g = *(Bits++);
01002                         b = *(Bits++);
01003 
01004                         r >>= 3;
01005                         g >>= 2;
01006                         b >>= 3;
01007 
01008                         *pTempP++ = (uint16)((r<<(11)) + (g << 5) + b);
01009                 }
01010                 pTempP += (Wh - w);
01011         }
01012         
01013         Info = GCache_SlotGetInfo(Slot);
01014         Info->data = TempL;
01015         
01016         GCache_UpdateSlot(LMapCache, Slot, Info);
01017 }

geBoolean DRIVERCC EndMeshes void   ) 
 

Definition at line 1386 of file GlideDrv/Render.c.

References DRIVERCC, geBoolean, RENDER_NONE, RenderMode, and TRUE.

01387 {
01388         RenderMode = RENDER_NONE;
01389 
01390         return TRUE;
01391 }

geBoolean DRIVERCC EndModels void   ) 
 

Definition at line 1401 of file GlideDrv/Render.c.

References DRIVERCC, geBoolean, RENDER_NONE, RenderMode, and TRUE.

01402 {
01403 
01404         RenderMode = RENDER_NONE;
01405 
01406         return TRUE;
01407 }

geBoolean DRIVERCC EndScene void   ) 
 

Definition at line 1333 of file GlideDrv/Render.c.

References DRIVERCC, DRV_RENDER_NO_ZMASK, DRV_RENDER_NO_ZWRITE, geBoolean, Render_HardwareFlags, and TRUE.

01334 {
01335 
01336 // Mike: force z buffer on
01337         grDepthMask(FXTRUE);
01338         Render_HardwareFlags &= ~DRV_RENDER_NO_ZWRITE;
01339 
01340         grDepthBufferFunction( GR_CMP_GEQUAL ); 
01341         Render_HardwareFlags &= ~DRV_RENDER_NO_ZMASK;
01342 
01343         // swapping the front and back buffer on the next vertical retrace
01344 #if 1
01345         grBufferSwap( 1 );
01346 #else
01347         grBufferSwap( 0 );
01348 #endif
01349 
01350         return TRUE;
01351 }

geBoolean DRIVERCC EndWorld void   ) 
 

Definition at line 1367 of file GlideDrv/Render.c.

References DRIVERCC, geBoolean, GLIDEDRV, NumSpans, NumWorldPixels, DRV_Driver::NumWorldPixels, DRV_Driver::NumWorldSpans, RENDER_NONE, RenderMode, and TRUE.

01368 {
01369         
01370         GLIDEDRV.NumWorldPixels = NumWorldPixels;
01371         GLIDEDRV.NumWorldSpans = NumSpans;
01372 
01373         RenderMode = RENDER_NONE;
01374 
01375         return TRUE;
01376 }

geBoolean DRIVERCC Render_DrawDecal geRDriver_THandle THandle,
RECT SRect,
int32  x,
int32  y
 

Definition at line 1180 of file GlideDrv/Render.c.

References tagRECT::bottom, ClientWindow, geRDriver_THandle::Data, DRIVERCC, DRV_ERROR_GENERIC, FALSE, GE_FALSE, GE_TRUE, geBoolean, DRV_Window::Height, geRDriver_THandle::Height, int32, tagRECT::left, RENDER_DECAL_MODE, Render_SetHardwareMode(), tagRECT::right, SetLastDrvError(), tagRECT::top, TRUE, uint16, DRV_Window::Width, geRDriver_THandle::Width, and y.

01181 {
01182         int32           Width, Height, Stride, OriginalWidth, w, h, Add1, Add2;
01183         uint16          *Data;
01184         GrLfbInfo_t     Info;
01185         uint16          *BackBuffer;
01186         
01187         if (x >= ClientWindow.Width)
01188                 return TRUE;
01189         if (y >= ClientWindow.Height)
01190                 return TRUE;
01191 
01192         Width = THandle->Width;
01193         OriginalWidth = Width;
01194         Height = THandle->Height;
01195         Stride = Width<<1;
01196         Data = (uint16*)THandle->Data;
01197 
01198         if (SRect)
01199         {
01200                 Data += SRect->top*Width + SRect->left;
01201                 Height = SRect->bottom - SRect->top;
01202                 Width = SRect->right - SRect->left;
01203         }
01204 
01205         if (x < 0)
01206         {
01207                 if (x+Width <= 0)
01208                         return TRUE;
01209                 Data += -x;
01210                 Width -= -x;
01211                 x=0;
01212         }
01213 
01214         if (y < 0)
01215         {
01216                 if (y+Height <= 0)
01217                         return TRUE;
01218                 Data += (-y)*OriginalWidth;
01219                 Height -= -y;
01220                 y=0;
01221         }
01222         
01223         if (x + Width >= ClientWindow.Width)
01224                 Width -= (x+Width) - ClientWindow.Width;
01225 
01226         if (y + Height >= ClientWindow.Height)
01227                 Height -=  (y+Height)- ClientWindow.Height;
01228 
01229         /*
01230         if (!grLfbWriteRegion(GR_BUFFER_BACKBUFFER , 
01231                                                 x, y, 
01232                                                 GR_LFB_SRC_FMT_1555, 
01233                                                 Width, Height, Stride, 
01234                                                 (void*)Data))
01235         {
01236                 SetLastDrvError(DRV_ERROR_GENERIC, "GLIDE_BlitDecal:  The GLIDE decal blit operation could not be performed.");
01237                 return FALSE;
01238         }
01239         */
01240 
01241         Info.size = sizeof(Info);
01242 
01243         Render_SetHardwareMode(RENDER_DECAL_MODE, 0);
01244         
01245         if (!grLfbLock(GR_LFB_WRITE_ONLY, GR_BUFFER_BACKBUFFER, GR_LFBWRITEMODE_565, 0, FXFALSE, &Info))
01246         //if (!grLfbLock(GR_LFB_WRITE_ONLY, GR_BUFFER_BACKBUFFER, GR_LFBWRITEMODE_1555, 0, FXTRUE, &Info))
01247         {
01248                 SetLastDrvError(DRV_ERROR_GENERIC, "GLIDE_BlitDecal:  Could not lock the back buffer.");
01249                 return FALSE;
01250         }
01251 
01252         BackBuffer = (uint16*)Info.lfbPtr;
01253 
01254         BackBuffer += (y * (Info.strideInBytes>>1)) + x;
01255 
01256         Add1 = OriginalWidth - Width;
01257         Add2 = (Info.strideInBytes>>1) - Width;
01258 
01259         for (h=0; h<Height; h++)
01260         {
01261                 for (w=0; w<Width; w++)
01262                 {
01263                         if (*Data != 1)
01264                                 *BackBuffer = *Data;
01265 
01266                         Data++;
01267                         BackBuffer++;
01268                 }
01269                 Data += Add1;
01270                 BackBuffer += Add2;
01271         }
01272 
01273         if (!grLfbUnlock(GR_LFB_WRITE_ONLY, GR_BUFFER_BACKBUFFER))
01274         {
01275                 SetLastDrvError(DRV_ERROR_GENERIC, "GLIDE_BlitDecal:  Could not unlock the back buffer.");
01276                 return GE_FALSE;
01277         }
01278 
01279         return GE_TRUE;
01280 }

geBoolean DRIVERCC Render_GouraudPoly DRV_TLVertex Pnts,
int32  NumPoints,
uint32  Flags
 

Definition at line 713 of file GlideDrv/Render.c.

00714 {
00715         int32 i;
00716         GrVertex        vrtx[RENDER_MAX_PNTS];
00717         geFloat         Alpha = Pnts->a;
00718 
00719         for (i = 0; i< NumPoints; i++)
00720         {
00721                 geFloat ZRecip;
00722 
00723                 vrtx[i].r = Pnts->r;
00724                 vrtx[i].g = Pnts->g;
00725                 vrtx[i].b = Pnts->b;
00726                 vrtx[i].a = Alpha;
00727                 
00728                 // set the SOW, TOW, and OOW values for a 1 TMU configuration TMU0 
00729                 ZRecip = (1.0f/(Pnts->z));
00730                 vrtx[i].ooz = (65535.0f) * ZRecip;
00731                 vrtx[i].oow = ZRecip;
00732                 vrtx[i].tmuvtx[0].oow = ZRecip;
00733 
00734                 vrtx[i].x = SNAP_VERT(Pnts->x);
00735                 vrtx[i].y = SNAP_VERT(Pnts->y);
00736 
00737                 Pnts++;
00738         }
00739 
00740         Render_SetHardwareMode(RENDER_MISC_GOURAD_POLY_MODE, Flags);
00741 
00742         grDrawPolygonVertexList( NumPoints, vrtx); 
00743 
00744         GLIDEDRV.NumRenderedPolys++;
00745 
00746         return TRUE;
00747 }

geBoolean DRIVERCC Render_LinesPoly DRV_TLVertex Pnts,
int32  NumPoints
 

Definition at line 752 of file GlideDrv/Render.c.

References DRIVERCC, geBoolean, geFloat, GLIDEDRV, int32, DRV_Driver::NumRenderedPolys, RENDER_LINES_POLY_MODE, RENDER_MAX_PNTS, Render_SetHardwareMode(), SNAP_VERT, TRUE, DRV_TLVertex::x, DRV_TLVertex::y, and DRV_TLVertex::z.

Referenced by Render_MiscTexturePoly(), and Render_WorldPoly().

00753 {
00754         int32 i;
00755         GrVertex        vrtx[RENDER_MAX_PNTS];
00756 
00757         for (i = 0; i< NumPoints; i++)
00758         {
00759                 geFloat ZRecip;
00760 
00761                 vrtx[i].r = 255.0f;//Pnts->r;
00762                 vrtx[i].g = 255.0f;//Pnts->g;
00763                 vrtx[i].b = 255.0f;//Pnts->b;
00764                 vrtx[i].a = 255.0f;
00765                 
00766                 // set the SOW, TOW, and OOW values for a 1 TMU configuration TMU0 
00767                 ZRecip = (1/(Pnts->z));
00768                 vrtx[i].ooz = (65535.0f) / Pnts->z;
00769                 vrtx[i].oow = ZRecip;
00770                 vrtx[i].tmuvtx[0].oow = ZRecip;
00771 
00772                 vrtx[i].x = SNAP_VERT(Pnts->x);
00773                 vrtx[i].y = SNAP_VERT(Pnts->y);
00774 
00775                 Pnts++;
00776         }
00777 
00778         Render_SetHardwareMode(RENDER_LINES_POLY_MODE, 0);
00779 
00780         for (i=0; i< NumPoints; i++)
00781         {
00782                 int32 i2 = ((i+1) < NumPoints) ? (i+1) : 0;
00783 
00784                 grDrawLine(&vrtx[i], &vrtx[i2]);
00785         }
00786 
00787         GLIDEDRV.NumRenderedPolys++;
00788 
00789         return TRUE;
00790 }

geBoolean DRIVERCC Render_MiscTexturePoly DRV_TLVertex Pnts,
int32  NumPoints,
geRDriver_THandle THandle,
uint32  Flags
 

Definition at line 1023 of file GlideDrv/Render.c.

01024 {
01025         int32                           i;
01026         GrVertex                        vrtx[RENDER_MAX_PNTS];
01027         DRV_TLVertex            *pPnt = Pnts;
01028         geFloat                         Alpha, Width_255, Height_255;
01029         
01030 #ifdef ENABLE_WIREFRAME
01031         if ( DoWireFrame )
01032                 return (Render_LinesPoly(Pnts, NumPoints));
01033 #endif
01034 
01035         assert( Pnts != NULL );
01036         assert( NumPoints < RENDER_MAX_PNTS );
01037         assert( THandle != NULL );
01038 
01039         {
01040                 geFloat OneOverLogSize;
01041                 
01042                 OneOverLogSize = THandle->OneOverLogSize_255;
01043 
01044                 Width_255  = (geFloat)THandle->Width  * OneOverLogSize;
01045                 Height_255 = (geFloat)THandle->Height * OneOverLogSize;
01046         }
01047 
01048         Alpha = Pnts->a;
01049 
01050         for (i = 0; i< NumPoints; i++)
01051         {
01052                 geFloat ZRecip;
01053 
01054                 vrtx[i].a = Alpha;
01055                 vrtx[i].r = pPnt->r;
01056                 vrtx[i].g = pPnt->g;
01057                 vrtx[i].b = pPnt->b;
01058                 // set the SOW, TOW, and OOW values for a 1 TMU configuration TMU0 
01059                 ZRecip = (1.0f/(pPnt->z));              // 1/2 frame in this divide.
01060                 vrtx[i].ooz = (65535.0f) * ZRecip; 
01061                 vrtx[i].oow = ZRecip;
01062                 vrtx[i].tmuvtx[0].oow = ZRecip;
01063 
01064                 vrtx[i].tmuvtx[0].sow = pPnt->u * Width_255 * ZRecip;
01065                 vrtx[i].tmuvtx[0].tow = pPnt->v * Height_255 * ZRecip;
01066 
01067                 vrtx[i].x = SNAP_VERT(pPnt->x);
01068                 vrtx[i].y = SNAP_VERT(pPnt->y);
01069 
01070                 pPnt++;
01071         }
01072 
01073         SetupTexture(THandle);
01074 
01075         Render_SetHardwareMode(RENDER_MISC_TEX_POLY_MODE, Flags);
01076 
01077         grDrawPolygonVertexList( NumPoints, vrtx); 
01078         //grAADrawPolygonVertexList( NumPoints, vrtx); 
01079 
01080         //GLIDEDRV.NumRenderedPolys++;
01081 
01082         return TRUE;
01083 }

void Render_SetColorCombine Render_ColorCombine  ColorCombine  ) 
 

Definition at line 93 of file GlideDrv/Render.c.

References ColorCombine_Gouraud, ColorCombine_Texture, ColorCombine_TextureGouraud, ColorCombine_TextureGouraudWithFog, and Render_OldColorCombine.

Referenced by Render_SetHardwareMode().

00094 {
00095         if (Render_OldColorCombine == ColorCombine)
00096                 return;         // Nothing to change
00097         
00098         switch(ColorCombine)
00099         {
00100                 case ColorCombine_Gouraud:
00101                 {
00102                         guColorCombineFunction( GR_COLORCOMBINE_ITRGB);
00103                         break;
00104                 }
00105                 case ColorCombine_Texture:
00106                 {
00107                         guColorCombineFunction( GR_COLORCOMBINE_DECAL_TEXTURE);
00108                         break;
00109                 }
00110                 case ColorCombine_TextureGouraud:
00111                 {
00112                         guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
00113                         break;
00114                 }
00115                 case ColorCombine_TextureGouraudWithFog:
00116                 {
00117                         guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB_ADD_ALPHA);
00118                         break;
00119                 }
00120 
00121                 default:
00122                         assert(0);
00123         }
00124         
00125         Render_OldColorCombine = ColorCombine;
00126 }

void Render_SetHardwareMode int32  NewMode,
uint32  NewFlags
 

Definition at line 187 of file GlideDrv/Render.c.

References ColorCombine_Gouraud, ColorCombine_TextureGouraud, DRV_RENDER_CLAMP_UV, DRV_RENDER_NO_ZMASK, DRV_RENDER_NO_ZWRITE, g_BoardInfo, g_FogEnable, GMain_BoardInfo::NumTMU, RENDER_DECAL_MODE, Render_HardwareFlags, Render_HardwareMode, RENDER_LIGHTMAP_FOG_POLY_MODE, RENDER_LIGHTMAP_POLY_MODE, RENDER_LINES_POLY_MODE, RENDER_MISC_GOURAD_POLY_MODE, RENDER_MISC_TEX_POLY_MODE, Render_SetColorCombine(), Render_SetTexCombine(), RENDER_WORLD_POLY_MODE, RENDER_WORLD_POLY_MODE_NO_LIGHTMAP, RENDER_WORLD_TRANSPARENT_POLY_MODE, TexCombine_PassThrough, TexCombine_SimultaneousPass, TexCombine_SinglePassGouraud, TexCombine_SinglePassTexture, and TMU.

Referenced by Render_DrawDecal(), Render_GouraudPoly(), Render_LinesPoly(), Render_MiscTexturePoly(), Render_WorldPoly(), and RenderLightmapPoly().

00188 {
00189         if (NewFlags != Render_HardwareFlags)           // See if the flags gave changed,,,
00190         {
00191                 if (NewFlags & DRV_RENDER_NO_ZMASK)
00192                         grDepthBufferFunction(GR_CMP_ALWAYS);
00193                 else if (Render_HardwareFlags & DRV_RENDER_NO_ZMASK)
00194                         grDepthBufferFunction( GR_CMP_GEQUAL ); 
00195 
00196                 if (NewFlags & DRV_RENDER_NO_ZWRITE)
00197                         grDepthMask(FXFALSE);
00198                 else if (Render_HardwareFlags & DRV_RENDER_NO_ZWRITE)
00199                         grDepthMask(FXTRUE);
00200                 
00201                 if (NewFlags & DRV_RENDER_CLAMP_UV)
00202                         grTexClampMode(TMU[0], GR_TEXTURECLAMP_CLAMP,GR_TEXTURECLAMP_CLAMP);
00203                 else if (Render_HardwareFlags & DRV_RENDER_CLAMP_UV)
00204                         grTexClampMode(TMU[0], GR_TEXTURECLAMP_WRAP,GR_TEXTURECLAMP_WRAP);
00205         }
00206 
00207         // Make these flags recent
00208         Render_HardwareFlags = NewFlags;
00209 
00210         if (NewMode == Render_HardwareMode)// && NewFlags == Render_HardwareFlags) 
00211                 return;         // Nothing to change
00212 
00213         if (Render_HardwareMode == RENDER_DECAL_MODE)
00214                 grChromakeyMode(GR_CHROMAKEY_DISABLE);          // Restore chroma key mode
00215 
00216         // sets up hardware mode 
00217         switch (NewMode)
00218         {
00219                 case (RENDER_MISC_TEX_POLY_MODE):
00220                 {
00221                         grTexMipMapMode( TMU[0], GR_MIPMAP_NEAREST, FXFALSE);           // Bug fix thanks to Bobtree
00222 
00223                         Render_SetColorCombine(ColorCombine_TextureGouraud);
00224                         Render_SetTexCombine(TexCombine_SinglePassTexture);
00225 
00226                         grAlphaBlendFunction(GR_BLEND_SRC_ALPHA,  GR_BLEND_ONE_MINUS_SRC_ALPHA,
00227                                                                  GR_BLEND_SRC_ALPHA,  GR_BLEND_ONE_MINUS_SRC_ALPHA);
00228 
00229                         if (g_FogEnable)
00230                                 //grFogMode(GR_FOG_WITH_ITERATED_ALPHA); 
00231                                 grFogMode(GR_FOG_WITH_TABLE); 
00232 
00233                         break;
00234                 }
00235 
00236                 case (RENDER_MISC_GOURAD_POLY_MODE):
00237                 {
00238                         Render_SetColorCombine(ColorCombine_Gouraud);
00239                         Render_SetTexCombine(TexCombine_SinglePassGouraud);
00240 
00241                         grAlphaBlendFunction(GR_BLEND_SRC_ALPHA, GR_BLEND_ONE_MINUS_SRC_ALPHA,
00242                                                                  GR_BLEND_ONE, GR_BLEND_ONE);
00243 
00244                         if (g_FogEnable)
00245                                 //grFogMode(GR_FOG_WITH_ITERATED_ALPHA); 
00246                                 grFogMode(GR_FOG_WITH_TABLE); 
00247 
00248                         break;
00249                 }
00250 
00251                 case (RENDER_LINES_POLY_MODE):
00252                 {       
00253                         Render_SetColorCombine(ColorCombine_Gouraud);
00254                         Render_SetTexCombine(TexCombine_SinglePassGouraud);
00255                         
00256                         grAlphaBlendFunction(GR_BLEND_SRC_ALPHA, GR_BLEND_ONE_MINUS_SRC_ALPHA,
00257                                                                  GR_BLEND_ONE, GR_BLEND_ONE);
00258 
00259                         if (g_FogEnable)
00260                                 //grFogMode(GR_FOG_WITH_ITERATED_ALPHA); 
00261                                 grFogMode(GR_FOG_WITH_TABLE); 
00262 
00263                         break;
00264                 }
00265 
00266                 case (RENDER_WORLD_POLY_MODE_NO_LIGHTMAP):
00267                 {
00268                         Render_SetColorCombine(ColorCombine_TextureGouraud);
00269                         Render_SetTexCombine(TexCombine_SinglePassTexture);
00270                         
00271                         grTexMipMapMode( TMU[0], GR_MIPMAP_NEAREST, FXFALSE);
00272 
00273                         grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO,
00274                                                                  GR_BLEND_ONE, GR_BLEND_ZERO);
00275 
00276                         if (g_FogEnable)
00277                                 //grFogMode(GR_FOG_WITH_ITERATED_ALPHA); 
00278                                 grFogMode(GR_FOG_WITH_TABLE); 
00279 
00280                         break;
00281                 }
00282 
00283                 case (RENDER_WORLD_POLY_MODE):
00284                 {
00285                         Render_SetColorCombine(ColorCombine_TextureGouraud);
00286                         Render_SetTexCombine(TexCombine_SinglePassTexture);
00287                         
00288                         grTexMipMapMode( TMU[0], GR_MIPMAP_NEAREST, FXFALSE);
00289 
00290                         grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO,
00291                                                                  GR_BLEND_ONE, GR_BLEND_ZERO);
00292 
00293                         if (g_FogEnable)
00294                                 //grFogMode(GR_FOG_WITH_ITERATED_ALPHA | GR_FOG_ADD2); 
00295                                 grFogMode(GR_FOG_WITH_TABLE | GR_FOG_ADD2); 
00296 
00297                         break;
00298                 }
00299 
00300                 case (RENDER_WORLD_TRANSPARENT_POLY_MODE):
00301                 {
00302                         Render_SetColorCombine(ColorCombine_TextureGouraud);
00303                         Render_SetTexCombine(TexCombine_SinglePassTexture);
00304 
00305                         grTexMipMapMode( TMU[0], GR_MIPMAP_NEAREST, FXFALSE);           // Bug fix thanks to Bobtree
00306 
00307                         grAlphaBlendFunction(GR_BLEND_SRC_ALPHA, GR_BLEND_ONE_MINUS_SRC_ALPHA,
00308                                                                  GR_BLEND_SRC_COLOR, GR_BLEND_DST_COLOR);
00309 
00310                         if (g_FogEnable)
00311                                 //grFogMode(GR_FOG_WITH_ITERATED_ALPHA);
00312                                 grFogMode(GR_FOG_WITH_TABLE); 
00313 
00314                         break;
00315                 }
00316 
00317                 // NOTE - IF this card has 2 TMU's, world polys AND lightmap polys will be piped through here
00318                 //      Notice how Simultaneous mode is turned on when 2 TMU's are detected... -JP
00319                 case(RENDER_LIGHTMAP_POLY_MODE):
00320                 {
00321                         grTexMipMapMode( TMU[1], GR_MIPMAP_DISABLE, FXFALSE );
00322 
00323                 
00324                         if (g_BoardInfo.NumTMU >= 2)
00325                         {
00326                                 Render_SetColorCombine(ColorCombine_TextureGouraud);
00327 
00328                                 grAlphaBlendFunction(GR_BLEND_SRC_ALPHA, GR_BLEND_ONE_MINUS_SRC_ALPHA,
00329                                                                          GR_BLEND_SRC_COLOR, GR_BLEND_DST_COLOR);
00330 
00331                                 if (g_FogEnable)
00332                                         //grFogMode(GR_FOG_WITH_ITERATED_ALPHA);
00333                                         grFogMode(GR_FOG_WITH_TABLE); 
00334 
00335                                 Render_SetTexCombine(TexCombine_SimultaneousPass);
00336                         
00337                                 grTexMipMapMode( TMU[0], GR_MIPMAP_NEAREST, FXFALSE);
00338                         }
00339                         else
00340                         {
00341                                 Render_SetColorCombine(ColorCombine_TextureGouraud);
00342 
00343                                 // Singlepass mode if there is onle 1 TMU
00344                                 Render_SetTexCombine(TexCombine_SinglePassTexture);
00345                         
00346                                 // Modulate the texture with the framebuffer
00347                                 if (g_FogEnable)
00348                                 {
00349                                         //grFogMode(GR_FOG_WITH_ITERATED_ALPHA | GR_FOG_MULT2);
00350                                         grFogMode(GR_FOG_WITH_TABLE | GR_FOG_MULT2); 
00351 
00352                                         grAlphaBlendFunction(   GR_BLEND_ONE, GR_BLEND_PREFOG_COLOR,
00353                                                                                         GR_BLEND_ONE, GR_BLEND_ZERO);
00354                                 }
00355                                 else
00356                                 {
00357                                         grAlphaBlendFunction(   GR_BLEND_DST_COLOR, GR_BLEND_ZERO,
00358                                                                                         GR_BLEND_ONE, GR_BLEND_ZERO);
00359                                 }
00360 
00361                                 // Force clamping to be on if this card only has one TMU
00362                                 grTexClampMode(TMU[0], GR_TEXTURECLAMP_CLAMP,GR_TEXTURECLAMP_CLAMP);
00363                                 Render_HardwareFlags |= DRV_RENDER_CLAMP_UV;
00364                         }
00365 
00366                         break;
00367                 }
00368 
00369                 case(RENDER_LIGHTMAP_FOG_POLY_MODE):
00370                 {
00371                         grTexMipMapMode( TMU[1], GR_MIPMAP_DISABLE, FXFALSE );
00372 
00373                         Render_SetColorCombine(ColorCombine_TextureGouraud);
00374 
00375                         if (g_BoardInfo.NumTMU >= 2)
00376                         {
00377                                 Render_SetTexCombine(TexCombine_PassThrough);
00378                                 grTexMipMapMode(TMU[0], GR_MIPMAP_NEAREST, FXFALSE);
00379                         }
00380                         else
00381                         {
00382                                 Render_SetTexCombine(TexCombine_SinglePassTexture);
00383                         }
00384 
00385                         if (g_FogEnable)
00386                                 //grFogMode(GR_FOG_WITH_ITERATED_ALPHA); 
00387                                 grFogMode(GR_FOG_DISABLE); 
00388 
00389                         grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ONE,
00390                                                                  GR_BLEND_ONE, GR_BLEND_ONE);
00391 
00392                         break;
00393                 }
00394 
00395                 case (RENDER_DECAL_MODE):
00396                 {
00397                         grLfbConstantDepth(0xffff);
00398                         grLfbConstantAlpha(0xff);
00399                         grChromakeyMode(GR_CHROMAKEY_ENABLE);
00400                         grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO,
00401                                                                  GR_BLEND_ONE, GR_BLEND_ZERO);
00402 
00403                         break;
00404                 }
00405 
00406                 default:
00407                 {
00408                         assert(0);
00409                 }
00410         }
00411 
00412         Render_HardwareMode = NewMode;
00413 }

void Render_SetTexCombine Render_TexCombine  TexCombine  ) 
 

Definition at line 131 of file GlideDrv/Render.c.

References g_BoardInfo, GMain_BoardInfo::NumTMU, Render_OldTexCombine, TexCombine_PassThrough, TexCombine_SimultaneousPass, TexCombine_SinglePassGouraud, TexCombine_SinglePassTexture, and TMU.

Referenced by Render_SetHardwareMode().

00132 {
00133         if (Render_OldTexCombine == TexCombine)
00134                 return;         // Nothing to change
00135         
00136         switch(TexCombine)
00137         {
00138                 case TexCombine_SinglePassGouraud:
00139                 {
00140                         guTexCombineFunction( TMU[0], GR_TEXTURECOMBINE_ONE);
00141                         
00142                         if (g_BoardInfo.NumTMU >= 2)
00143                                 guTexCombineFunction( TMU[1], GR_TEXTURECOMBINE_ZERO);
00144                         break;
00145                 }
00146 
00147                 case TexCombine_SinglePassTexture:
00148                 {
00149                         guTexCombineFunction( TMU[0], GR_TEXTURECOMBINE_DECAL);
00150                         
00151                         if (g_BoardInfo.NumTMU >= 2)
00152                                 guTexCombineFunction( TMU[1], GR_TEXTURECOMBINE_ZERO);
00153                         break;
00154                 }
00155 
00156                 case TexCombine_SimultaneousPass:
00157                 {
00158                         assert(g_BoardInfo.NumTMU >= 2);
00159 
00160                         guTexCombineFunction( TMU[0], GR_TEXTURECOMBINE_MULTIPLY);
00161                         guTexCombineFunction( TMU[1], GR_TEXTURECOMBINE_DECAL);
00162                 
00163                         break;
00164                 }
00165         
00166                 case TexCombine_PassThrough:
00167                 {
00168                         assert(g_BoardInfo.NumTMU >= 2);
00169         
00170                         guTexCombineFunction( TMU[0], GR_TEXTURECOMBINE_OTHER);
00171                         guTexCombineFunction( TMU[1], GR_TEXTURECOMBINE_DECAL);
00172                 
00173                         break;
00174                 }
00175 
00176                 default:
00177                         assert(0);
00178         }
00179 
00180         Render_OldTexCombine = TexCombine;
00181 }

geBoolean DRIVERCC Render_WorldPoly DRV_TLVertex Pnts,
int32  NumPoints,
geRDriver_THandle THandle,
DRV_TexInfo TexInfo,
DRV_LInfo LInfo,
uint32  Flags
 

Definition at line 795 of file GlideDrv/Render.c.

00796 {
00797         GrVertex                Vrtx[RENDER_MAX_PNTS], *pVrtx;
00798         geFloat                 OneOverSize_255;
00799         geFloat                 ShiftU, ShiftV, ScaleU, ScaleV;
00800         DRV_TLVertex    *pPnts;
00801         int32                   i;
00802         geFloat                 Alpha;
00803 
00804         assert(Pnts);
00805         assert(TexInfo);
00806 
00807 #ifdef ENABLE_WIREFRAME 
00808         if ( DoWireFrame )
00809                 return (Render_LinesPoly(Pnts, NumPoints));
00810 #endif
00811 
00812 #if 0
00813         switch (PolyMode)
00814         {
00815                 case DRV_POLYMODE_NORMAL:
00816                         break;                                                  // Use this function
00817                 case DRV_POLYMODE_GOURAUD:
00818                         return (Render_GouraudPoly(Pnts, NumPoints, 0));
00819                 case DRV_POLYMODE_LINES:
00820                         return (Render_LinesPoly(Pnts, NumPoints));
00821         }
00822 #endif
00823         
00824         GLIDEDRV.NumRenderedPolys++;
00825 
00826         OneOverSize_255 = THandle->OneOverLogSize_255;
00827 
00828         // Get how much to shift U, and V for the Texture
00829         ShiftU = TexInfo->ShiftU;
00830         ShiftV = TexInfo->ShiftV;
00831         ScaleU = 1.0f/TexInfo->DrawScaleU;
00832         ScaleV = 1.0f/TexInfo->DrawScaleV;
00833 
00834         pPnts = Pnts;
00835 
00836         pVrtx = Vrtx;
00837 
00838 #if 0
00839         // Fix the uv's to be as close to the origin as possible, without affecting their appearance...
00840         //if (pPnts->u > 1000.0f || pPnts->v > 1000.0f)
00841         {
00842                 geFloat         OneOverLogSize;
00843 
00844                 OneOverLogSize = 1.0f / (geFloat)THandle->LogSize;
00845                 
00846                 ShiftU -= (geFloat)(((int32)(pPnts->u*ScaleU/THandle->Width))*THandle->Width);
00847                 ShiftV -= (geFloat)(((int32)(pPnts->v*ScaleV/THandle->Height))*THandle->Height);
00848         }
00849 #endif
00850 
00851         Alpha = Pnts->a;
00852 
00853         for (i = 0; i< NumPoints; i++)
00854         {
00855                 geFloat ZRecip;
00856                 
00857                 pVrtx->a = Alpha;
00858 
00859                 pVrtx->r = pPnts->r;
00860                 pVrtx->g = pPnts->g;
00861                 pVrtx->b = pPnts->b;
00862                 
00863                 ZRecip = (1.0f/(pPnts->z));
00864                 pVrtx->ooz = 65535.0f * ZRecip;
00865                 pVrtx->oow = ZRecip;
00866 
00867                 pVrtx->tmuvtx[0].oow = ZRecip;
00868                 pVrtx->tmuvtx[1].oow = ZRecip;
00869         
00870                 ZRecip *= OneOverSize_255;
00871 
00872                 pVrtx->tmuvtx[TMU[0]].sow = (pPnts->u*ScaleU + ShiftU) * ZRecip;
00873                 pVrtx->tmuvtx[TMU[0]].tow = (pPnts->v*ScaleV + ShiftV) * ZRecip;
00874 
00875                 pVrtx->x = SNAP_VERT(pPnts->x);
00876                 pVrtx->y = SNAP_VERT(pPnts->y);
00877 
00878                 pPnts++;
00879                 pVrtx++;
00880         }
00881         
00882 
00883         // Set the source texture for TMU 0
00884         SetupTexture(THandle);
00885         
00886         // If only 1 TMU (or no lightmap), then draw first pass poly now. 
00887         if (g_BoardInfo.NumTMU == 1 || !LInfo)          
00888         {                                                               // The lightmap will blend over it
00889                 if (Flags & DRV_RENDER_ALPHA)
00890                         Render_SetHardwareMode(RENDER_WORLD_TRANSPARENT_POLY_MODE, Flags);
00891                 else
00892                 {
00893                         if (LInfo)
00894                                 Render_SetHardwareMode(RENDER_WORLD_POLY_MODE, Flags);
00895                         else
00896                                 Render_SetHardwareMode(RENDER_WORLD_POLY_MODE_NO_LIGHTMAP, Flags);
00897                 }
00898 
00899                 grDrawPolygonVertexList( NumPoints, Vrtx); 
00900         }
00901 
00902         if (LInfo)                                      // If there is a lightmap, render it now, on top of the first pass poly
00903         {
00904                 geBoolean  Dynamic;
00905 
00906                 // How much to shift u'vs back into lightmap space
00907                 ShiftU = (geFloat)LInfo->MinU-8.0f;
00908                 ShiftV = (geFloat)LInfo->MinV-8.0f;
00909                 
00910                 pPnts = Pnts;
00911 
00912                 // Call the engine to set this sucker up, because it's visible...
00913                 GLIDEDRV.SetupLightmap(LInfo, &Dynamic);
00914                 
00915                 OneOverSize_255 = LInfo->THandle->OneOverLogSize_255;
00916 
00917                 pVrtx = Vrtx;
00918 
00919                 for (i = 0; i< NumPoints; i++)
00920                 {
00921                         geFloat u = pPnts->u-ShiftU;
00922                         geFloat v = pPnts->v-ShiftV;
00923                         geFloat ZRecip = pVrtx->oow * OneOverSize_255;
00924 
00925                         pVrtx->tmuvtx[TMU[1]].sow = u*ZRecip;
00926                         pVrtx->tmuvtx[TMU[1]].tow = v*ZRecip;
00927                         pPnts++;
00928                         pVrtx++;
00929                 }
00930                 
00931                 RenderLightmapPoly(Vrtx, NumPoints, LInfo, (geBoolean)Dynamic, Flags);
00932         }
00933 
00934         return TRUE;
00935 }

void RenderLightmapPoly GrVertex *  vrtx,
int32  NumPoints,
DRV_LInfo LInfo,
geBoolean  Dynamic,
uint32  Flags
 

Definition at line 937 of file GlideDrv/Render.c.

References CurrentLRU, DownloadLightmap(), GCache_SlotGetInfo(), GCache_SlotGetMemAddress(), GCache_SlotSetLRU(), int32, LMAP_TYPE_FOG, LMAP_TYPE_LIGHT, geRDriver_THandle::LogSize, RENDER_LIGHTMAP_FOG_POLY_MODE, RENDER_LIGHTMAP_POLY_MODE, Render_SetHardwareMode(), DRV_LInfo::RGBLight, SetupLMapTexture(), TextureSource(), DRV_LInfo::THandle, and TMU.

Referenced by Render_WorldPoly().

00938 {
00939         geRDriver_THandle       *THandle;
00940         int32                           l;
00941         GCache_Slot                     *Slot;
00942 
00943         THandle = LInfo->THandle;
00944 
00945         Slot = SetupLMapTexture(THandle, LInfo, Dynamic, 0);
00946         
00947         GCache_SlotSetLRU(Slot, CurrentLRU);
00948         TextureSource(TMU[1], GCache_SlotGetMemAddress(Slot), GR_MIPMAPLEVELMASK_BOTH, GCache_SlotGetInfo(Slot));
00949 
00950         Render_SetHardwareMode(RENDER_LIGHTMAP_POLY_MODE, Flags);
00951 
00952         grDrawPolygonVertexList( NumPoints, vrtx); 
00953 
00954         // Render special maps
00955         for (l=1; l< 2; l++)
00956         {
00957                 if (!LInfo->RGBLight[l])
00958                         continue;
00959                 
00960                 switch(l)
00961                 {
00962                         case LMAP_TYPE_LIGHT:
00963                                 DownloadLightmap(LInfo, THandle->LogSize, Slot, 0);
00964                                 TextureSource(TMU[1], GCache_SlotGetMemAddress(Slot), GR_MIPMAPLEVELMASK_BOTH, GCache_SlotGetInfo(Slot));
00965                                 Render_SetHardwareMode(RENDER_LIGHTMAP_POLY_MODE, Flags);
00966                                 break;
00967 
00968                         case LMAP_TYPE_FOG:
00969                                 DownloadLightmap(LInfo, THandle->LogSize, Slot, l);
00970                                 TextureSource(TMU[1], GCache_SlotGetMemAddress(Slot), GR_MIPMAPLEVELMASK_BOTH, GCache_SlotGetInfo(Slot));
00971                                 Render_SetHardwareMode(RENDER_LIGHTMAP_FOG_POLY_MODE, Flags);
00972                                 break;
00973                 }
00974                 
00975                 grDrawPolygonVertexList( NumPoints, vrtx); 
00976         }
00977 }

GCache_Slot* SetupLMapTexture geRDriver_THandle THandle,
DRV_LInfo LInfo,
geBoolean  Dynamic,
int32  LMapNum
 

Definition at line 1144 of file GlideDrv/Render.c.

References CacheInfo, geRDriver_THandle::CacheType, CurrentLRU, DownloadLightmap(), geRDriver_THandle::Flags, GCache_SlotGetUserData(), GCache_SlotSetLRU(), GCache_SlotSetUserData(), GCache_TypeFindSlot(), GTHandle_CheckTextures(), DRV_CacheInfo::LMapMisses, geRDriver_THandle::LogSize, geRDriver_THandle::Slot, and THANDLE_UPDATE.

Referenced by RenderLightmapPoly().

01145 {
01146         GTHandle_CheckTextures();
01147 
01148         if (Dynamic)
01149                 THandle->Flags |= THANDLE_UPDATE;
01150 
01151         if (!THandle->Slot || GCache_SlotGetUserData(THandle->Slot) != THandle)
01152         {
01153                 THandle->Slot = GCache_TypeFindSlot(THandle->CacheType);
01154                 assert(THandle->Slot);
01155 
01156                 GCache_SlotSetUserData(THandle->Slot, THandle);
01157                 THandle->Flags |= THANDLE_UPDATE;
01158 
01159                 CacheInfo.LMapMisses++;
01160         }
01161 
01162         if (THandle->Flags & THANDLE_UPDATE)
01163         {
01164                 DownloadLightmap(LInfo, THandle->LogSize, THandle->Slot, LMapNum);
01165         }
01166         
01167         if (Dynamic)
01168                 THandle->Flags |= THANDLE_UPDATE;
01169         else
01170                 THandle->Flags &= ~THANDLE_UPDATE;
01171 
01172         GCache_SlotSetLRU(THandle->Slot, CurrentLRU);
01173 
01174         return THandle->Slot;
01175 }

void SetupTexture geRDriver_THandle THandle  ) 
 

Definition at line 1090 of file GlideDrv/Render.c.

01091 {
01092         GTHandle_CheckTextures();
01093 
01094         // Setup the palette
01095         if (THandle->PixelFormat.PixelFormat == GE_PIXELFORMAT_8BIT)
01096         {
01097                 assert(THandle->PalHandle);
01098                 assert(THandle->PalHandle->Data);
01099 
01100                 // CB <> one shared palette in glide; added _UPDATE check
01101                 if ((OldPalHandle != THandle->PalHandle) || (THandle->PalHandle->Flags & THANDLE_UPDATE))
01102                 {
01103                         grTexDownloadTable(TMU[0], GR_TEXTABLE_PALETTE, THandle->PalHandle->Data);
01104                         OldPalHandle = THandle->PalHandle;
01105                         THandle->PalHandle->Flags &= ~THANDLE_UPDATE;
01106                 }
01107         }
01108 
01109         if (!THandle->Slot || GCache_SlotGetUserData(THandle->Slot) != THandle)
01110         {
01111                 THandle->Slot = GCache_TypeFindSlot(THandle->CacheType);
01112                 assert(THandle->Slot);
01113 
01114                 GCache_SlotSetUserData(THandle->Slot, THandle);
01115                 THandle->Flags |= THANDLE_UPDATE;
01116                 
01117                 CacheInfo.TexMisses++;
01118         }
01119         
01120         if (THandle->Flags & THANDLE_UPDATE)
01121         {
01122                 GrTexInfo               *Info;
01123 
01124                 Info = GCache_SlotGetInfo(THandle->Slot);
01125         
01126                 // Set the data to the correct bits
01127                 Info->data = THandle->Data;
01128         
01129                 // We must make sure the textures formats and the caches format match (formats can change on the fly)
01130                 GlideFormatFromGenesisFormat(THandle->PixelFormat.PixelFormat, &Info->format);
01131 
01132                 GCache_UpdateSlot(TextureCache, THandle->Slot, Info);
01133 
01134                 THandle->Flags &= ~THANDLE_UPDATE;
01135         }
01136 
01137         GCache_SlotSetLRU(THandle->Slot, CurrentLRU);
01138         TextureSource(TMU[0], GCache_SlotGetMemAddress(THandle->Slot), GR_MIPMAPLEVELMASK_BOTH, GCache_SlotGetInfo(THandle->Slot));
01139 }

void TextureSource GrChipID_t  Tmu,
FxU32  startAddress,
FxU32  evenOdd,
GrTexInfo *  info
 

Definition at line 80 of file GlideDrv/Render.c.

References LastTextureAddr.

Referenced by RenderLightmapPoly(), and SetupTexture().

00081 {
00082         if (LastTextureAddr[Tmu] == startAddress)
00083                 return;
00084 
00085         grTexSource(Tmu, startAddress, evenOdd, info);
00086 
00087         LastTextureAddr[Tmu] = startAddress;
00088 }


Variable Documentation

DRV_CacheInfo CacheInfo
 

Definition at line 69 of file GlideDrv/Render.c.

uint32 CurrentLRU
 

Definition at line 71 of file GlideDrv/Render.c.

int DoWireFrame = 0 [static]
 

Definition at line 34 of file GlideDrv/Render.c.

Referenced by BeginScene(), Render_MiscTexturePoly(), and Render_WorldPoly().

g_FogEnable
 

Definition at line 73 of file GlideDrv/Render.c.

Referenced by BeginScene(), GMain_SetFogEnable(), and Render_SetHardwareMode().

FxU32 LastTextureAddr[2] = {(FxU32)-1, (FxU32)-1} [static]
 

Definition at line 75 of file GlideDrv/Render.c.

Referenced by TextureSource().

geRDriver_THandle* OldPalHandle
 

Definition at line 1085 of file GlideDrv/Render.c.

Referenced by SetupTexture().

uint32 PolyMode = DRV_POLYMODE_NORMAL
 

Definition at line 67 of file GlideDrv/Render.c.

Referenced by Render_WorldPoly(), and RenderMiscTexturePoly().

uint32 Render_HardwareFlags = 0
 

Definition at line 65 of file GlideDrv/Render.c.

Referenced by EndScene(), and Render_SetHardwareMode().

int32 Render_HardwareMode = RENDER_UNKNOWN_MODE
 

Definition at line 64 of file GlideDrv/Render.c.

Referenced by Render_SetHardwareMode().

Render_ColorCombine Render_OldColorCombine = ColorCombine_Undefined
 

Definition at line 62 of file GlideDrv/Render.c.

Referenced by Render_SetColorCombine().

Render_TexCombine Render_OldTexCombine = TexCombine_Undefined
 

Definition at line 63 of file GlideDrv/Render.c.

Referenced by Render_SetTexCombine().

DRV_RENDER_MODE RenderMode = RENDER_NONE
 

Definition at line 61 of file GlideDrv/Render.c.


Generated on Tue Sep 30 12:38:01 2003 for GTestAndEngine by doxygen 1.3.2