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

softdrv.c File Reference

#include <windows.h>
#include <stdio.h>
#include <Assert.h>
#include "SoftDrv.h"
#include "CPUInfo.h"
#include "DCommon.h"
#include "SpanBuffer.h"
#include "Span.h"
#include "ram.h"
#include "SWTHandle.h"
#include "Display.h"
#include "TRaster.h"
#include "DrawDecal.h"

Go to the source code of this file.

Compounds

struct  SoftDrv
struct  SoftDrv_DisplayInfo

Defines

#define geErrorLog_AddString(Error, xx, yy)
#define SOFTDRV_MAX_AVG_SPANS_PER_LINE   (22)
#define SOFTDRV_DESCRIPTION_LENGTH   256

Typedefs

typedef SoftDrv SoftDrv

Functions

void SoftDrv_LightMapSetupCallback (TRaster_Lightmap *LM)
void SoftDrv_ClearZBuffer (DRV_Window *Window)
void SoftDrv_DisplayInfoTable_Destroy (SoftDrv *S)
geBoolean SoftDrv_DisplayInfoTable_Create (SoftDrv *S, geBoolean FillOutModes)
geBoolean DRIVERCC SoftDrv_SetActive (geBoolean Active)
geBoolean DRIVERCC SoftDrv_Init (DRV_DriverHook *Hook)
geBoolean DRIVERCC SoftDrv_Shutdown (void)
geBoolean DRIVERCC SoftDrv_SetGamma (geFloat Gamma)
geBoolean DRIVERCC SoftDrv_GetGamma (geFloat *Gamma)
geBoolean DRIVERCC SoftDrv_SetRenderWindowRect (void)
geBoolean DRIVERCC SoftDrv_BeginScene (geBoolean Clear, geBoolean ClearZ, RECT *pWorldRect)
geBoolean DRIVERCC SoftDrv_EndScene (void)
geBoolean DRIVERCC SoftDrv_BeginWorld (void)
geBoolean DRIVERCC SoftDrv_EndRenderMode (void)
geBoolean DRIVERCC SoftDrv_BeginMeshes (void)
geBoolean DRIVERCC SoftDrv_BeginModels (void)
DllExport geBoolean DriverHook (DRV_Driver **Driver)
GENESISAPI void * geEngine_SoftwareDriver (void)
geBoolean DRIVERCC SoftDrv_ScreenShot (const char *Name)
geBoolean DRIVERCC SoftDrv_EnumSubDrivers (DRV_ENUM_DRV_CB *Cb, void *Context)
geBoolean DRIVERCC SoftDrv_EnumModes (S32 Driver, char *DriverName, DRV_ENUM_MODES_CB *Cb, void *Context)
int SoftDrv_ComputeMipLevel (const DRV_TLVertex *Pnts, geFloat ScaleU, geFloat ScaleV, int MipCount, int NumPoints)
geBoolean DRIVERCC SoftDrv_RenderGouraudPoly (DRV_TLVertex *Pnts, S32 NumPoints, U32 Flags)
geBoolean DRIVERCC SoftDrv_RenderWorldPoly (DRV_TLVertex *Pnts, S32 NumPoints, geRDriver_THandle *THandle, DRV_TexInfo *TexInfo, DRV_LInfo *LInfo, U32 Flags)
geBoolean DRIVERCC SoftDrv_RenderMiscTexturePoly (DRV_TLVertex *Pnts, S32 NumPoints, geRDriver_THandle *THandle, U32 Flags)
geBoolean DRIVERCC SoftDrv_ResetAll (void)
geBoolean DRIVERCC SoftDrv_SetFogEnable (geBoolean Enable, geFloat r, geFloat g, geFloat b, geFloat Start, geFloat End)

Variables

SoftDrv SoftDrv_Internals = {GE_FALSE}
int32 RenderMode = RENDER_NONE
DRV_Window ClientWindow = { 0 }
DisplaySD_Display = NULL
geBoolean SD_ProcessorHas3DNow
geBoolean SD_ProcessorHasMMX
geBoolean SD_DIBDisplayMode = GE_FALSE
geBoolean SD_Active = FALSE
DRV_EngineSettings SD_EngineSettings
DRV_CacheInfo SoftDrv_CacheInfo
S32 LastError
char LastErrorStr [200]
geROP SoftDrv_GouraudFlagsToRop [16]
geROP SoftDrv_MiscFlagsToRop [16][2]
DRV_LInfoSoftDrv_TempLInfo
DRV_TexInfoSoftDrv_TempTexInfo
DRV_Driver SOFTDRV


Define Documentation

#define geErrorLog_AddString Error,
xx,
yy   ) 
 

Definition at line 45 of file /softdrv.c.

#define SOFTDRV_DESCRIPTION_LENGTH   256
 

Definition at line 51 of file /softdrv.c.

Referenced by SoftDrv_DisplayInfoTable_Create().

#define SOFTDRV_MAX_AVG_SPANS_PER_LINE   (22)
 

Definition at line 49 of file /softdrv.c.

Referenced by SoftDrv_Init().


Typedef Documentation

typedef struct SoftDrv SoftDrv
 


Function Documentation

DllExport geBoolean DriverHook DRV_Driver **  Driver  ) 
 

Definition at line 495 of file /softdrv.c.

References DllExport, geBoolean, LastErrorStr, DRV_Driver::LastErrorStr, SOFTDRV, and TRUE.

00496 {
00497 
00498         *Driver = &SOFTDRV;
00499 
00500         // Make sure the error string ptr is not null, or invalid!!!
00501         SOFTDRV.LastErrorStr = LastErrorStr;
00502 
00503 
00504         return TRUE;
00505 }

GENESISAPI void* geEngine_SoftwareDriver void   ) 
 

Definition at line 507 of file /softdrv.c.

References DriverHook(), and GENESISAPI.

00508 {
00509         return (void *)DriverHook;
00510 }

geBoolean DRIVERCC SoftDrv_BeginMeshes void   ) 
 

Definition at line 480 of file /softdrv.c.

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

00481 {
00482         assert( RenderMode == RENDER_NONE);
00483         RenderMode = RENDER_MESHES;
00484         return TRUE;
00485 }

geBoolean DRIVERCC SoftDrv_BeginModels void   ) 
 

Definition at line 487 of file /softdrv.c.

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

00488 {
00489         assert( RenderMode == RENDER_NONE);
00490         RenderMode = RENDER_MODELS;
00491         return TRUE;
00492 }

geBoolean DRIVERCC SoftDrv_BeginScene geBoolean  Clear,
geBoolean  ClearZ,
RECT pWorldRect
 

Definition at line 389 of file /softdrv.c.

References geRDriver_THandle::BitPtr, DRV_Window::Buffer, ClientWindow, Display_Lock(), Display_Wipe(), SoftDrv::DrawBuffer, DRIVERCC, FALSE, GE_ERR_INTERNAL_RESOURCE, geBoolean, geErrorLog_AddString, NULL, DRV_Window::PixelPitch, RENDER_NONE, RenderMode, SD_Display, SoftDrv_CacheInfo, SoftDrv_ClearZBuffer(), SoftDrv_Internals, TRUE, and U16.

00390 {
00391 
00392         pWorldRect;             // unused.
00393 
00394         if (RenderMode != RENDER_NONE)
00395                 {
00396                         geErrorLog_AddString(GE_ERR_INTERNAL_RESOURCE,"SoftDrv_BeginScene: still in a render mode",geErrorLog_IntToString(RenderMode));
00397                         return FALSE;
00398                 }
00399 
00400         memset(&SoftDrv_CacheInfo, 0, sizeof(DRV_CacheInfo));
00401 
00402 
00403         if (ClearZ)
00404                 {
00405                         SoftDrv_ClearZBuffer(&ClientWindow);
00406                 }
00407         
00408         
00409         if(!Display_Lock(SD_Display,&(ClientWindow.Buffer), &(ClientWindow.PixelPitch)))
00410                 {
00411                         geErrorLog_AddString(GE_ERR_SUBSYSTEM_FAILURE ,"SoftDrv_BeginScene: failed to lock display buffer",NULL );
00412                         return  FALSE;
00413                 }
00414 
00415         if (Clear)
00416                 {
00417                         if (!Display_Wipe(SD_Display,0))
00418                                 {
00419                                         geErrorLog_AddString( GE_ERR_SUBSYSTEM_FAILURE,"SoftDrv_BeginScene: failed to wipe display buffer",NULL );
00420                                         return  FALSE;
00421                                 }
00422                 }
00423         SoftDrv_Internals.DrawBuffer.BitPtr[0] = (U16 *)(ClientWindow.Buffer);
00424         return TRUE;
00425 }

geBoolean DRIVERCC SoftDrv_BeginWorld void   ) 
 

Definition at line 465 of file /softdrv.c.

References DRIVERCC, geBoolean, RENDER_NONE, RENDER_WORLD, RenderMode, SpanBuffer_Clear(), and TRUE.

00466 {
00467         assert( RenderMode == RENDER_NONE );  // or RENDER_WORLD?
00468         SpanBuffer_Clear();
00469         RenderMode = RENDER_WORLD;
00470         return TRUE;
00471 }

void SoftDrv_ClearZBuffer DRV_Window Window  ) 
 

Definition at line 92 of file /softdrv.c.

References geRDriver_THandle::BitPtr, DRV_Window::Height, int32, SoftDrv_Internals, DRV_Window::Width, and SoftDrv::ZBuffer.

Referenced by SoftDrv_BeginScene().

00093 {
00094         int32   ZBSize;
00095 
00096         ZBSize = (Window->Width*Window->Height)<<1;
00097 
00098 
00099 #pragma message ("clear z buffer to biggest z.  was 0.")
00100         memset(SoftDrv_Internals.ZBuffer.BitPtr[0], 0xFF, ZBSize);
00101 
00102 }

int SoftDrv_ComputeMipLevel const DRV_TLVertex Pnts,
geFloat  ScaleU,
geFloat  ScaleV,
int  MipCount,
int  NumPoints
[static]
 

Definition at line 632 of file /softdrv.c.

References geFloat, and DRV_TLVertex::u.

Referenced by SoftDrv_RenderMiscTexturePoly(), and SoftDrv_RenderWorldPoly().

00637 {
00638         geFloat du, dv, dx, dy, MipScale;
00639         int MipLevel;
00640         int i;
00641 
00642         
00643         MipScale= 999999.999f;
00644         for (i=0; i<NumPoints; i++)
00645         {
00646                 geFloat MipScaleT;
00647                 int Nexti=  (i+1)%NumPoints;
00648                 du      =Pnts[Nexti].u - Pnts[i].u;
00649                 dv      =Pnts[Nexti].v - Pnts[i].v;
00650                 dx      =Pnts[Nexti].x - Pnts[i].x;
00651                 dy      =Pnts[Nexti].y - Pnts[i].y;
00652 
00653                 du      /= ScaleU;
00654                 dv      /= ScaleV;
00655 
00656                 MipScaleT       =((du*du)+(dv*dv)) / ((dx*dx)+(dy*dy));
00657                 if (MipScaleT < MipScale)
00658                         MipScale = MipScaleT;
00659 
00660         }
00661 
00662         if(MipScale <= 3) //5)          // 2, 6, 12
00663                 {
00664                         MipLevel        =0;
00665                 }
00666         else if(MipScale <= 15)   //20)
00667                 {
00668                         MipLevel        =1;
00669                 }
00670         else if(MipScale <= 35)    // 45)
00671                 {
00672                         MipLevel        =2;
00673                 }
00674         else
00675                 {
00676                         MipLevel        =3;
00677                 }
00678         if(MipLevel >= MipCount)
00679                 {
00680                         MipLevel        =MipCount-1;
00681                 }
00682         return MipLevel;
00683 }

geBoolean SoftDrv_DisplayInfoTable_Create SoftDrv S,
geBoolean  FillOutModes
[static]
 

Definition at line 124 of file /softdrv.c.

References SoftDrv_DisplayInfo::Description, SoftDrv::Display, DISPLAY_COUNT, Display_GetDisplayInfo(), SoftDrv::DisplayCount, DisplayModeInfo_Create(), DisplayModeInfo_Destroy(), SoftDrv_DisplayInfo::DisplayType, DRV_VMAJS, DRV_VMINS, GE_ERR_MEMORY_RESOURCE, GE_FALSE, GE_TRUE, geBoolean, geErrorLog_AddString, SoftDrv_DisplayInfo::Info, NULL, SoftDrv::RefCount, SOFTDRV_DESCRIPTION_LENGTH, and SoftDrv_DisplayInfoTable_Destroy().

Referenced by SoftDrv_EnumModes(), SoftDrv_EnumSubDrivers(), and SoftDrv_Init().

00125 {
00126         char VersionString[SOFTDRV_DESCRIPTION_LENGTH]="v"DRV_VMAJS"."DRV_VMINS".";
00127         int i;
00128         FillOutModes;           // avoid unreference parameter warning
00129         
00130         assert( S != NULL );
00131         if (S->RefCount>0)
00132                 {
00133                         S->RefCount++;
00134                         return GE_TRUE;
00135                 }
00136         else
00137                 S->RefCount=1;
00138         
00139                         
00140         S->DisplayCount = 0;
00141         for (i=0; i<DISPLAY_COUNT; i++)
00142                 {
00143                         S->Display[i].Info = DisplayModeInfo_Create();
00144                         if (S->Display[i].Info == NULL)
00145                                 {
00146                                         SoftDrv_DisplayInfoTable_Destroy( S );
00147                                         geErrorLog_AddString(GE_ERR_MEMORY_RESOURCE,"SoftDrv_DisplayInfoTableCreate: unable to create table",NULL);
00148                                         return GE_FALSE;
00149                                 }
00150                         if (Display_GetDisplayInfo(             i,
00151                                                                                         S->Display[i].Description, 
00152                                                                                         SOFTDRV_DESCRIPTION_LENGTH-strlen(VersionString),
00153                                                                                         S->Display[i].Info) == GE_FALSE)
00154                                 {
00155                                         DisplayModeInfo_Destroy( &(S->Display[i].Info) );
00156                                         geErrorLog_AddString(GE_ERR_MEMORY_RESOURCE,"SoftDrv_DisplayInfoTableCreate: problem filling table. (continuing)",NULL);
00157                                         S->Display[i].Info=NULL;
00158                                 }
00159                         else
00160                                 {
00161                                         strcat(S->Display[i].Description,VersionString);
00162                                         S->Display[i].DisplayType = i;
00163                                         S->DisplayCount++;
00164                                 }
00165                 }
00166         return GE_TRUE;
00167 }

void SoftDrv_DisplayInfoTable_Destroy SoftDrv S  )  [static]
 

Definition at line 105 of file /softdrv.c.

References SoftDrv::Display, SoftDrv::DisplayCount, DisplayModeInfo_Destroy(), SoftDrv_DisplayInfo::Info, NULL, and SoftDrv::RefCount.

Referenced by SoftDrv_DisplayInfoTable_Create(), SoftDrv_EnumModes(), SoftDrv_EnumSubDrivers(), SoftDrv_Init(), and SoftDrv_Shutdown().

00106 {
00107         int i;
00108 
00109         S->RefCount--;
00110         if (S->RefCount>0)
00111                 return;
00112         
00113         for (i=0; i<S->DisplayCount; i++)
00114                 {
00115                         if (S->Display[i].Info != NULL)
00116                                 {
00117                                         DisplayModeInfo_Destroy( &(S->Display[i].Info) );
00118                                         S->Display[i].Info=NULL;
00119                                 }
00120                 }
00121         S->DisplayCount = 0;
00122 }

geBoolean DRIVERCC SoftDrv_EndRenderMode void   ) 
 

Definition at line 473 of file /softdrv.c.

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

00474 {
00475         assert( RenderMode != RENDER_NONE );
00476         RenderMode = RENDER_NONE;
00477         return TRUE;
00478 }

geBoolean DRIVERCC SoftDrv_EndScene void   ) 
 

Definition at line 428 of file /softdrv.c.

References DRV_Window::Buffer, ClientWindow, Display_Blit(), Display_Unlock(), DRIVERCC, FALSE, geBoolean, geErrorLog_AddString, DRV_Window::Height, NULL, RENDER_NONE, RenderMode, SD_Display, TRUE, DRV_Window::Width, and ZBuffer.

00429 {
00430         assert( RenderMode == RENDER_NONE );
00431 
00432 
00433         #if 0
00434                 // useful to examine the zbuffer
00435                 {
00436                         int i;
00437                         unsigned short *b,*z;
00438                         b = (unsigned short *)ClientWindow.Buffer;
00439                         z = (unsigned short *)ZBuffer;
00440                         for (i=ClientWindow.Height * ClientWindow.Width; i>0; i--,b++,z++)
00441                                 {
00442                                         *b = *z;
00443                                 }
00444                 }
00445         #endif
00446 
00447         if (!Display_Unlock(SD_Display))
00448                 {
00449                         geErrorLog_AddString( GE_ERR_SUBSYSTEM_FAILURE,"SoftDrv_EndScene: failed to unlock display buffer",NULL );
00450                         return  FALSE;
00451                 }
00452         if (!Display_Blit(SD_Display))
00453                 {
00454                         geErrorLog_AddString( GE_ERR_SUBSYSTEM_FAILURE,"SoftDrv_EndScene: failed to blit display buffer",NULL );
00455                         return  FALSE;
00456                 }
00457                 
00458         //      SOFTDRV.NumWorldSpans = RegPixels;
00459         //      SOFTDRV.NumRenderedPolys = RGBPixels;
00460 
00461         return TRUE;
00462 }

geBoolean DRIVERCC SoftDrv_EnumModes S32  Driver,
char *  DriverName,
DRV_ENUM_MODES_CB Cb,
void *  Context
 

Definition at line 542 of file /softdrv.c.

References SoftDrv::Display, SoftDrv::DisplayCount, DisplayModeInfo_GetModeCount(), DisplayModeInfo_GetNth(), DRIVERCC, FALSE, GE_FALSE, GE_TRUE, geBoolean, geErrorLog_AddString, SoftDrv_DisplayInfo::Info, MODEXMODE, NULL, SD_ProcessorHas3DNow, SoftDrv_DisplayInfoTable_Create(), SoftDrv_DisplayInfoTable_Destroy(), SoftDrv_Internals, TRUE, and uint32.

00543 {
00544         int             i,Count;
00545         DriverName;             // avoid unused parameter;
00546 
00547         if (SoftDrv_DisplayInfoTable_Create(&(SoftDrv_Internals), GE_TRUE)==GE_FALSE)
00548                 {
00549                         geErrorLog_AddString(GE_ERR_SUBSYSTEM_FAILURE,"SoftDrv_EnumModes: failed to get mode info",NULL);
00550                         return FALSE;
00551                 }
00552         
00553         if ((Driver < 0) || (Driver>=SoftDrv_Internals.DisplayCount))
00554                 {
00555                         geErrorLog_AddString(GE_ERR_BAD_PARAMETER,"SoftDrv_EnumModes: bad driver index",NULL);
00556                         SoftDrv_DisplayInfoTable_Destroy(&(SoftDrv_Internals));
00557                         return FALSE;
00558                 }
00559         
00560 
00561         Count = DisplayModeInfo_GetModeCount( SoftDrv_Internals.Display[Driver].Info );
00562 
00563         for (i=0; i<Count; i++)
00564                 {
00565                         int Width,Height,BitsPerPixel;
00566                         uint32 Flags;
00567 
00568                         if (DisplayModeInfo_GetNth(SoftDrv_Internals.Display[Driver].Info,i,
00569                                                                         &Width,&Height,&BitsPerPixel,&Flags) != GE_FALSE)
00570                                 {
00571                                         char Description[256];
00572                                         if (Width<0 && Height<0)
00573                                                 {
00574                                                         sprintf(Description,"Window Mode");
00575                                                 }
00576                                         else
00577                                                 {
00578                                                         sprintf(Description,"%dx%dx%d",Width, Height, BitsPerPixel);
00579                                                 }
00580                                         if(Flags & MODEXMODE)
00581                                                 strcat(Description," ModeX");
00582                                         if (SD_ProcessorHas3DNow)
00583                                                 strcat(Description," 3DNow!");
00584                 
00585                                         Cb(i,Description,Width,Height,Context);
00586                                 }
00587                 }
00588         SoftDrv_DisplayInfoTable_Destroy(&SoftDrv_Internals);
00589         return TRUE;
00590 }

geBoolean DRIVERCC SoftDrv_EnumSubDrivers DRV_ENUM_DRV_CB Cb,
void *  Context
 

Definition at line 519 of file /softdrv.c.

References SoftDrv_DisplayInfo::Description, SoftDrv::Display, SoftDrv::DisplayCount, DRIVERCC, FALSE, GE_FALSE, geBoolean, geErrorLog_AddString, NULL, SoftDrv_DisplayInfoTable_Create(), SoftDrv_DisplayInfoTable_Destroy(), SoftDrv_Internals, and TRUE.

00520 {
00521         int i;
00522         
00523         if (SoftDrv_DisplayInfoTable_Create(&(SoftDrv_Internals), GE_FALSE)==GE_FALSE)
00524                 {
00525                         geErrorLog_AddString(GE_ERR_SUBSYSTEM_FAILURE,"SoftDrv_EnumSubDrivers: failed to get mode info",NULL);
00526                         return FALSE;
00527                 }
00528 
00529         for (i=0; i<SoftDrv_Internals.DisplayCount; i++)
00530                 {
00531                         if(!Cb(i, SoftDrv_Internals.Display[i].Description, Context))
00532                         {
00533                                 break;
00534                         }
00535                 }
00536 
00537         SoftDrv_DisplayInfoTable_Destroy(&SoftDrv_Internals);
00538         return  TRUE;
00539 }

geBoolean DRIVERCC SoftDrv_GetGamma geFloat Gamma  ) 
 

Definition at line 373 of file /softdrv.c.

References DRIVERCC, geBoolean, and TRUE.

00374 {
00375         assert(Gamma);
00376 
00377         *Gamma = 1.0f;
00378 
00379         return TRUE;
00380 }

geBoolean DRIVERCC SoftDrv_Init DRV_DriverHook Hook  ) 
 

Definition at line 178 of file /softdrv.c.

References geRDriver_THandle::Active, geRDriver_THandle::AlphaHandle, DRV_Window::B_mask, DRV_Window::B_shift, DRV_Window::B_width, geRDriver_THandle::BitPtr, DRV_Window::BytesPerPixel, ClientWindow, CPUInfo_TestFor3DNow(), CPUInfo_TestForMMX(), SoftDrv::Display, Display_Create(), Display_Destroy(), Display_GetDisplayFormat(), Display_GetPixelFormat(), Display_Type, SoftDrv::DisplayCount, DisplayModeInfo_GetNth(), SoftDrv::DrawBuffer, DRV_DriverHook::Driver, DRIVERCC, FALSE, geRDriver_THandle::Flags, DRV_Window::G_mask, DRV_Window::G_shift, DRV_Window::G_width, GE_ERR_MEMORY_RESOURCE, GE_FALSE, GE_SPAN_DESTINATION_FORMAT_555, GE_SPAN_DESTINATION_FORMAT_565, GE_SPAN_HARDWARE_INTEL, GE_TRUE, geBoolean, geErrorLog_AddString, geRam_Allocate, geSpan_DestinationFormat, geRDriver_THandle::Height, DRV_Window::Height, DRV_DriverHook::hWnd, int32, geRDriver_THandle::MipLevels, DRV_DriverHook::Mode, NULL, geRDriver_THandle::PalHandle, DRV_Window::R_mask, DRV_Window::R_shift, DRV_Window::R_width, SD_Display, SD_ProcessorHas3DNow, SD_ProcessorHasMMX, SoftDrv_DisplayInfoTable_Create(), SoftDrv_DisplayInfoTable_Destroy(), SoftDrv_Internals, SoftDrv_LightMapSetupCallback(), SOFTDRV_MAX_AVG_SPANS_PER_LINE, SoftDrv_SetActive(), Span_SetOutputMode(), SpanBuffer_Create(), TRaster_Setup(), TRUE, U16, U32, U8, uint16, uint32, geRDriver_THandle::Width, DRV_Window::Width, SoftDrv::ZBuffer, and ZBuffer.

00179 {
00180         // hook->width, hook->height are ignored...
00181         uint16  *ZBuffer=NULL;
00182 
00183         #pragma message ("fix to:") //geBoolean DRIVERCC SoftDrv_Init(Hwnd, char *DriverString, int Height, int Width, int BitsPerPixel, uint32 Flags)
00184 
00185         if (SoftDrv_DisplayInfoTable_Create(&(SoftDrv_Internals), GE_TRUE)==GE_FALSE)
00186                 {
00187                         geErrorLog_AddString(GE_ERR_SUBSYSTEM_FAILURE,"SoftDrv_Init: failed to get mode info",NULL);
00188                         return FALSE;
00189                 }
00190 
00191         if ((Hook->Driver<0) || (Hook->Driver>=SoftDrv_Internals.DisplayCount))
00192                 {
00193                         geErrorLog_AddString(GE_ERR_BAD_PARAMETER,"SoftDrv_Init: bad driver index",NULL);
00194                         SoftDrv_DisplayInfoTable_Destroy(&(SoftDrv_Internals));
00195                         return FALSE;
00196                 }
00197 
00198         
00199 //      VInfo           =&(SoftDrv->VideoModeInfo[Hook->Driver]);
00200         //VInfo->bpp    =16;
00201 
00202         SD_ProcessorHas3DNow = CPUInfo_TestFor3DNow();
00203         SD_ProcessorHasMMX   = CPUInfo_TestForMMX();
00204   
00205         {
00206                 int Height, Width, BitsPerPixel;
00207                 uint32 Flags;
00208                 
00209                 if (DisplayModeInfo_GetNth(     SoftDrv_Internals.Display[Hook->Driver].Info, 
00210                                                                         Hook->Mode,
00211                                                                         &Width,
00212                                                                         &Height,
00213                                                                         &BitsPerPixel,
00214                                                                         &Flags ) == GE_FALSE)
00215                         {
00216                                 geErrorLog_AddString(GE_ERR_BAD_PARAMETER,"SoftDrv_Init: unable to get mode info: bad mode index",NULL);
00217                                 SoftDrv_DisplayInfoTable_Destroy(&(SoftDrv_Internals));
00218                                 return FALSE;
00219                         }
00220 
00221     SD_Display = Display_Create(        Hook->hWnd,
00222                                                                                 SoftDrv_Internals.Display[Hook->Driver].DisplayType,
00223                                                                                 Width,
00224                                                                                 Height,
00225                                                                                 BitsPerPixel,
00226                                                                                 Flags);
00227                 if (SD_Display == NULL)
00228                         {
00229                                 geErrorLog_AddString(GE_ERR_SUBSYSTEM_FAILURE, "SoftDrv_Init: Could not initialize display",NULL);
00230                                 SoftDrv_DisplayInfoTable_Destroy(&(SoftDrv_Internals));
00231                                 return  FALSE;
00232                         }                                               
00233         
00234     if( 1 )
00235                 {
00236                         int32 BitsPerPixel;
00237                         Display_Type DisplayType;
00238                         uint32 Flags;                   
00239                 
00240                         Display_GetDisplayFormat(       SD_Display, 
00241                                                                                 &DisplayType, 
00242                                                                                 &(ClientWindow.Width),
00243                                                                                 &(ClientWindow.Height),
00244                                                                                 &BitsPerPixel,
00245                                                                                 &Flags);
00246 
00247                 }
00248 
00249         }
00250 
00251         if (SpanBuffer_Create(ClientWindow.Width,ClientWindow.Height, ClientWindow.Height * SOFTDRV_MAX_AVG_SPANS_PER_LINE)==GE_FALSE)
00252                 {
00253                         geErrorLog_AddString(GE_ERR_SUBSYSTEM_FAILURE, "SoftDrv_Init:  Could not create span buffer",NULL);
00254                         Display_Destroy(&SD_Display);
00255                         SoftDrv_DisplayInfoTable_Destroy(&(SoftDrv_Internals));
00256                         return  FALSE;
00257                 }
00258 
00259         if (Display_GetPixelFormat(     SD_Display,
00260                                                                 //&ClientWindow.PixelPitch,
00261                                                                 &ClientWindow.BytesPerPixel,
00262                                                                 &ClientWindow.R_shift,
00263                                                                 &ClientWindow.R_mask,
00264                                                                 &ClientWindow.R_width,
00265                                                                 &ClientWindow.G_shift,
00266                                                                 &ClientWindow.G_mask,
00267                                                                 &ClientWindow.G_width,
00268                                                                 &ClientWindow.B_shift,
00269                                                                 &ClientWindow.B_mask,
00270                                                                 &ClientWindow.B_width)==GE_FALSE)
00271                 {
00272                         geErrorLog_AddString(GE_ERR_SUBSYSTEM_FAILURE, "SoftDrv_Init:  Could not get display pixel format",NULL);
00273                         Display_Destroy(&SD_Display);
00274                         SoftDrv_DisplayInfoTable_Destroy(&(SoftDrv_Internals));
00275                         return  FALSE;
00276                 }
00277 
00278   {     
00279   geSpan_DestinationFormat DestFormat;
00280   switch( ClientWindow.R_width + ClientWindow.G_width + ClientWindow.B_width )
00281     {
00282     case 15: DestFormat = GE_SPAN_DESTINATION_FORMAT_555;
00283              break;
00284     case 16: DestFormat = GE_SPAN_DESTINATION_FORMAT_565;
00285              break;
00286     default: 
00287                         geErrorLog_AddString(GE_ERR_BAD_PARAMETER,"SoftDrv_Init: unsupported destination format",NULL);
00288                         SoftDrv_DisplayInfoTable_Destroy(&(SoftDrv_Internals));
00289                         return FALSE;
00290     }
00291 
00292         if (Span_SetOutputMode( DestFormat, GE_SPAN_HARDWARE_INTEL ) == GE_FALSE)
00293                 {
00294                         geErrorLog_AddString(GE_ERR_SUBSYSTEM_FAILURE,"SoftDrv_Init: unable to set span drawing mode",NULL);
00295                         SoftDrv_DisplayInfoTable_Destroy(&(SoftDrv_Internals));
00296                         return FALSE;
00297                 }
00298   }
00299 
00300 
00301         {
00302                 U32     OldFlags        =0;
00303 
00304                 ZBuffer =(U16 *)geRam_Allocate(ClientWindow.Width * ClientWindow.Height * 2);
00305                 
00306                 if(!ZBuffer)
00307                 {
00308                         geErrorLog_AddString(GE_ERR_MEMORY_RESOURCE,"SoftDrv_Init:  Not enought memory for ZBuffer",NULL);
00309                         Display_Destroy(&SD_Display);
00310                         SoftDrv_DisplayInfoTable_Destroy(&(SoftDrv_Internals));
00311                         return FALSE;
00312                 }
00313 
00314                 if(!VirtualProtect((U8 *)ZBuffer,
00315                         (ClientWindow.Width * ClientWindow.Height)*2,
00316                         PAGE_READWRITE | PAGE_NOCACHE,
00317                         &OldFlags))
00318                 {
00319                         // nothing to do on failure...
00320                 }
00321         }
00322         
00323 #pragma message ("set up DRV_TLHandle for display and zbuffer")
00324 
00325         
00326         // assume the window is active:
00327         SoftDrv_SetActive(GE_TRUE);
00328 
00329         SoftDrv_Internals.DrawBuffer.Active=1;
00330         SoftDrv_Internals.DrawBuffer.Width  = ClientWindow.Width;
00331         SoftDrv_Internals.DrawBuffer.Height = ClientWindow.Height;
00332         SoftDrv_Internals.DrawBuffer.MipLevels = 1;
00333         SoftDrv_Internals.DrawBuffer.BitPtr[0] = NULL; // not locked yet. (U16 *)(ClientWindow.Buffer);
00334         SoftDrv_Internals.DrawBuffer.PalHandle = NULL;
00335         SoftDrv_Internals.DrawBuffer.AlphaHandle = NULL;
00336         SoftDrv_Internals.DrawBuffer.Flags = 0;
00337 
00338         SoftDrv_Internals.ZBuffer.Active=1;
00339         SoftDrv_Internals.ZBuffer.Width  = ClientWindow.Width;
00340         SoftDrv_Internals.ZBuffer.Height = ClientWindow.Height;
00341         SoftDrv_Internals.ZBuffer.MipLevels = 1;
00342         SoftDrv_Internals.ZBuffer.BitPtr[0] = (U16 *)(ZBuffer);
00343         SoftDrv_Internals.ZBuffer.PalHandle = NULL;
00344         SoftDrv_Internals.ZBuffer.AlphaHandle = NULL;
00345         SoftDrv_Internals.ZBuffer.Flags = 0;
00346 
00347         TRaster_Setup(32,&(SoftDrv_Internals.DrawBuffer),&(SoftDrv_Internals.ZBuffer),SoftDrv_LightMapSetupCallback);
00348 
00349         return  TRUE;
00350 }

void SoftDrv_LightMapSetupCallback TRaster_Lightmap LM  ) 
 

Definition at line 760 of file /softdrv.c.

References TRaster_Lightmap::BitPtr, DRV_TexInfo::DrawScaleU, DRV_TexInfo::DrawScaleV, geBoolean, geFloat, DRV_LInfo::Height, TRaster_Lightmap::Height, TRaster_Lightmap::LightMapScaleU, TRaster_Lightmap::LightMapScaleV, TRaster_Lightmap::LightMapShiftU, TRaster_Lightmap::LightMapShiftV, DRV_LInfo::MinU, DRV_LInfo::MinV, TRaster_Lightmap::MipIndex, DRV_LInfo::RGBLight, DRV_Driver::SetupLightmap, DRV_TexInfo::ShiftU, DRV_TexInfo::ShiftV, SOFTDRV, SoftDrv_TempLInfo, SoftDrv_TempTexInfo, DRV_LInfo::Width, and TRaster_Lightmap::Width.

Referenced by SoftDrv_Init().

00761 {
00762         geBoolean Dynamic;
00763         SOFTDRV.SetupLightmap(SoftDrv_TempLInfo, &Dynamic);
00764         #pragma message ("SetupLightmap callback: can it fail?")
00765 
00766         {
00767                 geFloat MipScale;
00768                 geFloat ShiftU,ShiftV;
00769                 geFloat ScaleU,ScaleV;
00770                 geFloat LightMapShiftU,LightMapShiftV;
00771         
00772                 ShiftU = SoftDrv_TempTexInfo->ShiftU;
00773                 ShiftV = SoftDrv_TempTexInfo->ShiftV;
00774                 MipScale = (geFloat)( 1<<LM->MipIndex);
00775                 ScaleU = (1.0f/SoftDrv_TempTexInfo->DrawScaleU);
00776                 ScaleV = (1.0f/SoftDrv_TempTexInfo->DrawScaleV);
00777                 
00778                 LightMapShiftU = ((geFloat)(SoftDrv_TempLInfo->MinU));// - 8.0f?;
00779                 LightMapShiftV = ((geFloat)(SoftDrv_TempLInfo->MinV));// - 8.0f?;
00780 
00781                 LM->LightMapShiftU = (ShiftU+LightMapShiftU*ScaleU)/MipScale;
00782                 LM->LightMapScaleU = (1.0f/(16.0f * /*LogSize? */ ScaleU )) * MipScale;
00783                 
00784                 LM->LightMapShiftV = (ShiftV+LightMapShiftV*ScaleV)/MipScale;
00785                 LM->LightMapScaleV = (1.0f/(16.0f * /*LogSize? */ ScaleV )) *MipScale;
00786                 
00787 
00788                 LM->BitPtr = (unsigned short *)SoftDrv_TempLInfo->RGBLight[0];
00789                 LM->Height = SoftDrv_TempLInfo->Height;
00790                 LM->Width  = SoftDrv_TempLInfo->Width;
00791         }
00792                 
00793 
00794 }

geBoolean DRIVERCC SoftDrv_RenderGouraudPoly DRV_TLVertex Pnts,
S32  NumPoints,
U32  Flags
 

Definition at line 686 of file /softdrv.c.

References DRV_TLVertex::a, ClientWindow, DRIVERCC, GE_TRUE, geBoolean, geROP, DRV_Window::Height, NULL, SD_Active, SoftDrv_GouraudFlagsToRop, TRaster_Rasterize(), DRV_Window::Width, DRV_TLVertex::x, y, and DRV_TLVertex::y.

00687 {
00688         int             i;
00689         geROP   ROP;
00690         
00691         if(!SD_Active)
00692         {
00693                 return  GE_TRUE;
00694         }
00695 
00696         assert(Pnts != NULL);
00697         assert(NumPoints > 2);
00698 
00699         ROP = SoftDrv_GouraudFlagsToRop[Flags & 0xF];
00700         for(i=0;i < NumPoints-2;i++)
00701                 {
00702                         DRV_TLVertex Pnts2[3];
00703                         
00704                         if (  (((Pnts[i+1].x-Pnts[0].x) * (Pnts[i+2].y-Pnts[0].y)) - ((Pnts[i+1].y-Pnts[0].y)*(Pnts[i+2].x-Pnts[0].x)))<0.0f)
00705                                 {
00706                                         Pnts2[0] = Pnts[i+2];
00707                                         Pnts2[1] = Pnts[i+1];
00708                                         Pnts2[2] = Pnts[0];
00709                                 }
00710                         else
00711                                 {
00712                                         Pnts2[0] = Pnts[0];
00713                                         Pnts2[1] = Pnts[i+1];
00714                                         Pnts2[2] = Pnts[i+2];
00715                                 }
00716                         Pnts2[0].a = Pnts[0].a;
00717                         #ifdef GENESIS_VERSION_2
00718                                 #pragma message ("temporary:")
00719                                 if( Pnts2[0].x < 0 )    Pnts2[0].x = 0 ;
00720                                 if( Pnts2[1].x < 0 )    Pnts2[1].x = 0 ;
00721                                 if( Pnts2[2].x < 0 )    Pnts2[2].x = 0 ;
00722                                 if( Pnts2[0].y < 0 )    Pnts2[0].y = 0 ;
00723                                 if( Pnts2[1].y < 0 )    Pnts2[1].y = 0 ;
00724                                 if( Pnts2[2].y < 0 )    Pnts2[2].y = 0 ;
00725 
00726                                 if( Pnts2[0].x >= ClientWindow.Width )  Pnts2[0].x = ClientWindow.Width-1 ;
00727                                 if( Pnts2[1].x >= ClientWindow.Width )  Pnts2[1].x = ClientWindow.Width-1 ;
00728                                 if( Pnts2[2].x >= ClientWindow.Width )  Pnts2[2].x = ClientWindow.Width-1 ;
00729                                 if( Pnts2[0].y >= ClientWindow.Height ) Pnts2[0].y = ClientWindow.Height-1 ;
00730                                 if( Pnts2[1].y >= ClientWindow.Height ) Pnts2[1].y = ClientWindow.Height-1 ;
00731                                 if( Pnts2[2].y >= ClientWindow.Height ) Pnts2[2].y = ClientWindow.Height-1 ;
00732                         #else
00733                                 assert( Pnts2[0].x >= 0 ) ;
00734                                 assert( Pnts2[1].x >= 0 ) ;
00735                                 assert( Pnts2[2].x >= 0 ) ;
00736                                 assert( Pnts2[0].y >= 0 ) ;
00737                                 assert( Pnts2[1].y >= 0 ) ;
00738                                 assert( Pnts2[2].y >= 0 ) ;
00739 
00740                                 assert( Pnts2[0].x < ClientWindow.Width ) ;
00741                                 assert( Pnts2[1].x < ClientWindow.Width ) ;
00742                                 assert( Pnts2[2].x < ClientWindow.Width ) ;
00743                                 assert( Pnts2[0].y < ClientWindow.Height ) ;
00744                                 assert( Pnts2[1].y < ClientWindow.Height ) ;
00745                                 assert( Pnts2[2].y < ClientWindow.Height ) ;
00746                         #endif
00747 
00748 
00749                         TRaster_Rasterize( ROP ,NULL, 0, Pnts2 );
00750                 }
00751 
00752 
00753         return GE_TRUE;
00754 }

geBoolean DRIVERCC SoftDrv_RenderMiscTexturePoly DRV_TLVertex Pnts,
S32  NumPoints,
geRDriver_THandle THandle,
U32  Flags
 

Definition at line 936 of file /softdrv.c.

References DRV_TLVertex::a, ClientWindow, DRIVERCC, GE_PIXELFORMAT_16BIT_4444_ARGB, GE_TRUE, geBoolean, geROP, DRV_Window::Height, geRDriver_THandle::MipLevels, NULL, geRDriver_PixelFormat::PixelFormat, geRDriver_THandle::PixelFormat, SD_Active, SoftDrv_ComputeMipLevel(), SoftDrv_MiscFlagsToRop, TRaster_Rasterize(), DRV_Window::Width, DRV_TLVertex::x, y, and DRV_TLVertex::y.

00937 {
00938         int             i;
00939         geROP   ROP;
00940         int MipLevel;
00941 
00942         if(!SD_Active)
00943         {
00944                 return  GE_TRUE;
00945         }
00946 
00947         assert(Pnts != NULL);
00948         assert(NumPoints > 2);
00949         ROP = SoftDrv_MiscFlagsToRop[Flags & 0xF][(THandle->PixelFormat.PixelFormat==GE_PIXELFORMAT_16BIT_4444_ARGB)?1:0];
00950         // message ("Automatically make a 4444 from other formats?")
00951 
00952         for(i=0;i < NumPoints-2;i++)
00953                 {
00954                         DRV_TLVertex Pnts2[3];
00955 
00956                         if (  (((Pnts[i+1].x-Pnts[0].x) * (Pnts[i+2].y-Pnts[0].y)) - ((Pnts[i+1].y-Pnts[0].y)*(Pnts[i+2].x-Pnts[0].x)))<0.0f)
00957                                 {
00958                                         Pnts2[0] = Pnts[i+2];
00959                                         Pnts2[1] = Pnts[i+1];
00960                                         Pnts2[2] = Pnts[0];
00961                                 }
00962                         else
00963                                 {
00964                                         Pnts2[0] = Pnts[0];
00965                                         Pnts2[1] = Pnts[i+1];
00966                                         Pnts2[2] = Pnts[i+2];
00967                                 }
00968                         Pnts2[0].a = Pnts[0].a;
00969                         #ifdef GENESIS_VERSION_2
00970                                 #pragma message ("temporary:")
00971                                 if( Pnts2[0].x < 0 )    Pnts2[0].x = 0 ;
00972                                 if( Pnts2[1].x < 0 )    Pnts2[1].x = 0 ;
00973                                 if( Pnts2[2].x < 0 )    Pnts2[2].x = 0 ;
00974                                 if( Pnts2[0].y < 0 )    Pnts2[0].y = 0 ;
00975                                 if( Pnts2[1].y < 0 )    Pnts2[1].y = 0 ;
00976                                 if( Pnts2[2].y < 0 )    Pnts2[2].y = 0 ;
00977 
00978                                 if( Pnts2[0].x >= ClientWindow.Width )  Pnts2[0].x = ClientWindow.Width-1 ;
00979                                 if( Pnts2[1].x >= ClientWindow.Width )  Pnts2[1].x = ClientWindow.Width-1 ;
00980                                 if( Pnts2[2].x >= ClientWindow.Width )  Pnts2[2].x = ClientWindow.Width-1 ;
00981                                 if( Pnts2[0].y >= ClientWindow.Height ) Pnts2[0].y = ClientWindow.Height-1 ;
00982                                 if( Pnts2[1].y >= ClientWindow.Height ) Pnts2[1].y = ClientWindow.Height-1 ;
00983                                 if( Pnts2[2].y >= ClientWindow.Height ) Pnts2[2].y = ClientWindow.Height-1 ;
00984                         #else
00985                                 assert( Pnts2[0].x >= 0 ) ;
00986                                 assert( Pnts2[1].x >= 0 ) ;
00987                                 assert( Pnts2[2].x >= 0 ) ;
00988                                 assert( Pnts2[0].y >= 0 ) ;
00989                                 assert( Pnts2[1].y >= 0 ) ;
00990                                 assert( Pnts2[2].y >= 0 ) ;
00991 
00992                                 assert( Pnts2[0].x < ClientWindow.Width ) ;
00993                                 assert( Pnts2[1].x < ClientWindow.Width ) ;
00994                                 assert( Pnts2[2].x < ClientWindow.Width ) ;
00995                                 assert( Pnts2[0].y < ClientWindow.Height ) ;
00996                                 assert( Pnts2[1].y < ClientWindow.Height ) ;
00997                                 assert( Pnts2[2].y < ClientWindow.Height ) ;
00998                         #endif
00999 
01000                         
01001                         if (THandle->MipLevels>1)
01002                                 MipLevel = SoftDrv_ComputeMipLevel(Pnts,1.0f,1.0f,THandle->MipLevels,NumPoints);
01003                         else
01004                                 MipLevel =0;
01005                         TRaster_Rasterize(  ROP,THandle,MipLevel, Pnts2 );
01006                 }
01007 
01008 
01009         return GE_TRUE;
01010 }

geBoolean DRIVERCC SoftDrv_RenderWorldPoly DRV_TLVertex Pnts,
S32  NumPoints,
geRDriver_THandle THandle,
DRV_TexInfo TexInfo,
DRV_LInfo LInfo,
U32  Flags
 

Definition at line 798 of file /softdrv.c.

References ClientWindow, DRV_TexInfo::DrawScaleU, DRV_TexInfo::DrawScaleV, DRIVERCC, DRV_RENDER_ALPHA, GE_PIXELFORMAT_16BIT_4444_ARGB, GE_ROP_TMAP_LMAP_AFLAT_ZTESTSET, GE_ROP_TMAP_LMAP_AMAP_ZTESTSET, GE_ROP_TMAP_LMAP_ZSET_SBUF, GE_ROP_TMAP_LMAP_ZTESTSET, GE_ROP_TMAP_LSHADE_AFLAT_ZTESTSET, GE_ROP_TMAP_LSHADE_AMAP_ZTESTSET, GE_ROP_TMAP_LSHADE_ZSET_SBUF, GE_ROP_TMAP_LSHADE_ZTESTSET, GE_TRUE, geBoolean, geFloat, geROP, DRV_Window::Height, geRDriver_THandle::Height, int32, geRDriver_THandle::MipLevels, NULL, geRDriver_PixelFormat::PixelFormat, geRDriver_THandle::PixelFormat, RENDER_WORLD, RenderMode, SD_Active, DRV_TexInfo::ShiftU, DRV_TexInfo::ShiftV, SoftDrv_ComputeMipLevel(), SoftDrv_TempLInfo, SoftDrv_TempTexInfo, TRaster_Rasterize(), DRV_TLVertex::u, DRV_TLVertex::v, DRV_Window::Width, geRDriver_THandle::Width, DRV_TLVertex::x, y, and DRV_TLVertex::y.

00804 {
00805         int32   i;
00806         geROP   ROP;
00807         int MipLevel;
00808 
00809         if(!SD_Active)
00810         {
00811                 return  GE_TRUE;
00812         }
00813 
00814         // figure out which rop.  Based on lightmap, pixel format, alpha, and RenderMode.  Ick.
00815         if (RenderMode==RENDER_WORLD )//&& (THandle->PixelFormat.PixelFormat !=GE_PIXELFORMAT_16BIT_4444_ARGB))
00816                 {
00817                         // always z set but not test.
00818                         assert( !(Flags & DRV_RENDER_ALPHA) );
00819                         assert( !(THandle->PixelFormat.PixelFormat ==GE_PIXELFORMAT_16BIT_4444_ARGB));
00820 
00821                         if (LInfo)
00822                                 {
00823                                         ROP = GE_ROP_TMAP_LMAP_ZSET_SBUF;
00824                                 }
00825                         else
00826                                 {
00827                                         ROP = GE_ROP_TMAP_LSHADE_ZSET_SBUF;     
00828                                 }
00829                 }
00830         else
00831                 {
00832                         if (LInfo)
00833                                 {
00834                                         if (THandle->PixelFormat.PixelFormat ==GE_PIXELFORMAT_16BIT_4444_ARGB)
00835                                                 {
00836                                                         ROP = GE_ROP_TMAP_LMAP_AMAP_ZTESTSET;
00837                                                 }
00838                                         else if (Flags & DRV_RENDER_ALPHA)
00839                                                 {
00840                                                         ROP = GE_ROP_TMAP_LMAP_AFLAT_ZTESTSET;
00841                                                 }
00842                                         else 
00843                                                 {       
00844                                                         // assert( Pnts.a == 255.0f );
00845                                                         ROP = GE_ROP_TMAP_LMAP_ZTESTSET;
00846                                                 }
00847                                 }
00848                         else
00849                                 {
00850                                         if (THandle->PixelFormat.PixelFormat ==GE_PIXELFORMAT_16BIT_4444_ARGB)
00851                                                 {
00852                                                         ROP = GE_ROP_TMAP_LSHADE_AMAP_ZTESTSET; 
00853                                                 }
00854                                         else if (Flags & DRV_RENDER_ALPHA)
00855                                                 {
00856                                                         ROP = GE_ROP_TMAP_LSHADE_AFLAT_ZTESTSET;
00857                                                 }
00858                                         else 
00859                                                 {       
00860                                                         // assert( Pnts.a == 255.0f );
00861                                                         ROP = GE_ROP_TMAP_LSHADE_ZTESTSET;
00862                                                 }
00863                                 }
00864                 }
00865 
00866         assert(THandle != NULL);
00867         assert(Pnts != NULL);
00868         assert(NumPoints > 2);
00869         {
00870                 DRV_TLVertex Pnts2[3];
00871                 geFloat OOW,OOH;
00872                 geFloat ShiftU,ShiftV,ScaleU,ScaleV;
00873                 // this scaling work can be done once at texture setup time
00874                 ShiftU = TexInfo->ShiftU;
00875                 ShiftV = TexInfo->ShiftV;
00876                 ScaleU = 1.0f/TexInfo->DrawScaleU;
00877                 ScaleV = 1.0f/TexInfo->DrawScaleV;
00878                 OOW = 1.0f / (geFloat)THandle->Width;
00879                 OOH = 1.0f / (geFloat)THandle->Height;
00880                 
00881                 SoftDrv_TempTexInfo = TexInfo;
00882                 SoftDrv_TempLInfo = LInfo;
00883 
00884                 Pnts2[0] = Pnts[0];
00885                 Pnts2[0].u = (Pnts2[0].u*ScaleU+ShiftU)*OOW;
00886                 Pnts2[0].v = (Pnts2[0].v*ScaleV+ShiftV)*OOH;
00887 
00888                 MipLevel = SoftDrv_ComputeMipLevel(Pnts,TexInfo->DrawScaleU,TexInfo->DrawScaleV,THandle->MipLevels,NumPoints);
00889 
00890                 for(i=0;i < NumPoints-2;i++)
00891                         {
00892                                 // these are all wound the same way (clockwise)
00893                                 Pnts2[1] = Pnts[i+1];
00894                                 Pnts2[2] = Pnts[i+2];
00895                                 Pnts2[1].u = (Pnts2[1].u*ScaleU+ShiftU)*OOW;
00896                                 Pnts2[1].v = (Pnts2[1].v*ScaleV+ShiftV)*OOH;
00897                                 Pnts2[2].u = (Pnts2[2].u*ScaleU+ShiftU)*OOW;
00898                                 Pnts2[2].v = (Pnts2[2].v*ScaleV+ShiftV)*OOH;
00899                                 #ifdef GENESIS_VERSION_2
00900                                         #pragma message ("temporary:")
00901                                         if( Pnts2[0].x < 0 )    Pnts2[0].x = 0 ;
00902                                         if( Pnts2[1].x < 0 )    Pnts2[1].x = 0 ;
00903                                         if( Pnts2[2].x < 0 )    Pnts2[2].x = 0 ;
00904                                         if( Pnts2[0].y < 0 )    Pnts2[0].y = 0 ;
00905                                         if( Pnts2[1].y < 0 )    Pnts2[1].y = 0 ;
00906                                         if( Pnts2[2].y < 0 )    Pnts2[2].y = 0 ;
00907 
00908                                         if( Pnts2[0].x >= ClientWindow.Width )  Pnts2[0].x = ClientWindow.Width-1 ;
00909                                         if( Pnts2[1].x >= ClientWindow.Width )  Pnts2[1].x = ClientWindow.Width-1 ;
00910                                         if( Pnts2[2].x >= ClientWindow.Width )  Pnts2[2].x = ClientWindow.Width-1 ;
00911                                         if( Pnts2[0].y >= ClientWindow.Height ) Pnts2[0].y = ClientWindow.Height-1 ;
00912                                         if( Pnts2[1].y >= ClientWindow.Height ) Pnts2[1].y = ClientWindow.Height-1 ;
00913                                         if( Pnts2[2].y >= ClientWindow.Height ) Pnts2[2].y = ClientWindow.Height-1 ;
00914                                 #else
00915                                         assert( Pnts2[0].x >= 0 ) ;
00916                                         assert( Pnts2[1].x >= 0 ) ;
00917                                         assert( Pnts2[2].x >= 0 ) ;
00918                                         assert( Pnts2[0].y >= 0 ) ;
00919                                         assert( Pnts2[1].y >= 0 ) ;
00920                                         assert( Pnts2[2].y >= 0 ) ;
00921 
00922                                         assert( Pnts2[0].x < ClientWindow.Width ) ;
00923                                         assert( Pnts2[1].x < ClientWindow.Width ) ;
00924                                         assert( Pnts2[2].x < ClientWindow.Width ) ;
00925                                         assert( Pnts2[0].y < ClientWindow.Height ) ;
00926                                         assert( Pnts2[1].y < ClientWindow.Height ) ;
00927                                         assert( Pnts2[2].y < ClientWindow.Height ) ;
00928                                 #endif
00929                                 
00930                                 TRaster_Rasterize(  ROP,THandle, MipLevel, Pnts2 );
00931                         }
00932         }
00933         return GE_TRUE;
00934 }

geBoolean DRIVERCC SoftDrv_ResetAll void   ) 
 

Definition at line 1013 of file /softdrv.c.

References DRIVERCC, geBoolean, and SWTHandle_FreeAllTextureHandles().

01014 {
01015         return SWTHandle_FreeAllTextureHandles();
01016 }

geBoolean DRIVERCC SoftDrv_ScreenShot const char *  Name  ) 
 

Definition at line 513 of file /softdrv.c.

References DRIVERCC, FALSE, and geBoolean.

00514 {
00515         Name;
00516         return FALSE;
00517 }

geBoolean DRIVERCC SoftDrv_SetActive geBoolean  Active  ) 
 

Definition at line 169 of file /softdrv.c.

References Display_SetActive(), DRIVERCC, geBoolean, SD_Active, SD_Display, and TRUE.

Referenced by SoftDrv_Init().

00170 {
00171         SD_Active = Active;
00172         Display_SetActive(SD_Display,Active);
00173         return TRUE;
00174 }

geBoolean DRIVERCC SoftDrv_SetFogEnable geBoolean  Enable,
geFloat  r,
geFloat  g,
geFloat  b,
geFloat  Start,
geFloat  End
 

Definition at line 1018 of file /softdrv.c.

References DRIVERCC, GE_FALSE, geBoolean, and r.

01019 {
01020         Enable,r,g,b,Start,End;
01021         return GE_FALSE;
01022 }

geBoolean DRIVERCC SoftDrv_SetGamma geFloat  Gamma  ) 
 

Definition at line 367 of file /softdrv.c.

References DRIVERCC, geBoolean, and TRUE.

00368 {
00369         Gamma;
00370         return TRUE;
00371 }

geBoolean DRIVERCC SoftDrv_SetRenderWindowRect void   ) 
 

Definition at line 383 of file /softdrv.c.

References DRIVERCC, GE_TRUE, and geBoolean.

00384 {
00385         return  GE_TRUE;
00386 }

geBoolean DRIVERCC SoftDrv_Shutdown void   ) 
 

Definition at line 352 of file /softdrv.c.

References geRDriver_THandle::BitPtr, Display_Destroy(), DRIVERCC, geBoolean, geRam_Free, NULL, SD_Display, SoftDrv_DisplayInfoTable_Destroy(), SoftDrv_Internals, SpanBuffer_Destroy(), TRUE, and SoftDrv::ZBuffer.

00353 {
00354         SoftDrv_DisplayInfoTable_Destroy(&(SoftDrv_Internals));
00355         
00356         if (SD_Display)
00357                 Display_Destroy(&SD_Display);
00358         SD_Display = NULL;
00359 
00360         if(SoftDrv_Internals.ZBuffer.BitPtr[0]!=NULL)
00361                 geRam_Free(SoftDrv_Internals.ZBuffer.BitPtr[0]);
00362         SoftDrv_Internals.ZBuffer.BitPtr[0]=NULL;
00363         SpanBuffer_Destroy();
00364         return  TRUE;
00365 }


Variable Documentation

DRV_Window ClientWindow = { 0 }
 

Definition at line 73 of file /softdrv.c.

S32 LastError
 

Definition at line 87 of file /softdrv.c.

char LastErrorStr[200]
 

Definition at line 88 of file /softdrv.c.

int32 RenderMode = RENDER_NONE
 

Definition at line 72 of file /softdrv.c.

geBoolean SD_Active = FALSE
 

Definition at line 78 of file /softdrv.c.

Referenced by DrawDecal(), SoftDrv_RenderGouraudPoly(), SoftDrv_RenderMiscTexturePoly(), SoftDrv_RenderWorldPoly(), and SoftDrv_SetActive().

geBoolean SD_DIBDisplayMode = GE_FALSE
 

Definition at line 77 of file /softdrv.c.

Display* SD_Display = NULL
 

Definition at line 74 of file /softdrv.c.

Referenced by SoftDrv_BeginScene(), SoftDrv_EndScene(), SoftDrv_Init(), SoftDrv_SetActive(), SoftDrv_Shutdown(), and SWTHandle_EnumPixelFormats().

DRV_EngineSettings SD_EngineSettings
 

Initial value:

Definition at line 79 of file /softdrv.c.

geBoolean SD_ProcessorHas3DNow
 

Definition at line 75 of file /softdrv.c.

Referenced by DrawDecal(), SoftDrv_EnumModes(), and SoftDrv_Init().

geBoolean SD_ProcessorHasMMX
 

Definition at line 76 of file /softdrv.c.

Referenced by SoftDrv_Init().

DRV_Driver SOFTDRV
 

Definition at line 1025 of file /softdrv.c.

DRV_CacheInfo SoftDrv_CacheInfo
 

Definition at line 85 of file /softdrv.c.

Referenced by SoftDrv_BeginScene().

geROP SoftDrv_GouraudFlagsToRop[16]
 

Initial value:

Definition at line 592 of file /softdrv.c.

Referenced by SoftDrv_RenderGouraudPoly().

SoftDrv SoftDrv_Internals = {GE_FALSE} [static]
 

Definition at line 69 of file /softdrv.c.

Referenced by SoftDrv_BeginScene(), SoftDrv_ClearZBuffer(), SoftDrv_EnumModes(), SoftDrv_EnumSubDrivers(), SoftDrv_Init(), and SoftDrv_Shutdown().

geROP SoftDrv_MiscFlagsToRop[16][2]
 

Initial value:

Definition at line 612 of file /softdrv.c.

Referenced by SoftDrv_RenderMiscTexturePoly().

DRV_LInfo* SoftDrv_TempLInfo
 

Definition at line 757 of file /softdrv.c.

Referenced by SoftDrv_LightMapSetupCallback(), and SoftDrv_RenderWorldPoly().

DRV_TexInfo* SoftDrv_TempTexInfo
 

Definition at line 758 of file /softdrv.c.

Referenced by SoftDrv_LightMapSetupCallback(), and SoftDrv_RenderWorldPoly().


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