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

scene.c File Reference

#include <Windows.h>
#include <stdio.h>
#include <assert.h>
#include "SoftDrv.h"
#include "DCommon.h"
#include "Render.h"
#include "Scene.h"
#include "Span.h"
#include "System.h"
#include "Sal.h"
#include "dmodes.h"

Go to the source code of this file.

Functions

void SetFPU24 (void)
void RestoreFPU (void)
BOOL DRIVERCC BeginScene (BOOL Clear, BOOL ClearZ, RECT *pWorldRect)
BOOL DRIVERCC EndScene (void)
BOOL DRIVERCC BeginWorld (void)
BOOL DRIVERCC EndWorld (void)
BOOL DRIVERCC BeginMeshes (void)
BOOL DRIVERCC EndMeshes (void)
BOOL DRIVERCC BeginModels (void)
BOOL DRIVERCC EndModels (void)

Variables

S32 RenderMode = RENDER_NONE
VidModeListcmode = NULL
RECT WorldRect
RECT FrontRect
U16 FPUCW
U16 OldFPUCW
CPUInfo ProcessorInfo
U32 OldFlags = 0


Function Documentation

BOOL DRIVERCC BeginMeshes void   ) 
 

Definition at line 210 of file scene.c.

References ClientWindow, DRIVERCC, DRV_ERROR_GENERIC, FALSE, DRV_Window::Height, NumPixels, RENDER_MESHES, RENDER_NONE, RenderMode, ResetSpans(), SetLastDrvError(), and TRUE.

00211 {
00212         if (RenderMode != RENDER_NONE)
00213         {
00214                 SetLastDrvError(DRV_ERROR_GENERIC, "Still in some other render mode.");
00215                 return FALSE;
00216         }
00217 
00218         ResetSpans(ClientWindow.Height);
00219         NumPixels = 0;
00220         RenderMode = RENDER_MESHES;
00221 
00222         return TRUE;
00223 }

BOOL DRIVERCC BeginModels void   ) 
 

Definition at line 232 of file scene.c.

References ClientWindow, DRIVERCC, DRV_ERROR_GENERIC, FALSE, DRV_Window::Height, NumPixels, RENDER_MODELS, RENDER_NONE, RenderMode, ResetSpans(), SetLastDrvError(), and TRUE.

00233 {
00234         if (RenderMode != RENDER_NONE)
00235         {
00236                 SetLastDrvError(DRV_ERROR_GENERIC, "Still in some other render mode.");
00237                 return FALSE;
00238         }
00239         ResetSpans(ClientWindow.Height);
00240         NumPixels = 0;
00241 
00242         RenderMode = RENDER_MODELS;
00243 
00244         return TRUE;
00245 }

BOOL DRIVERCC BeginScene BOOL  Clear,
BOOL  ClearZ,
RECT pWorldRect
 

Definition at line 64 of file scene.c.

References tagRECT::bottom, DRV_Window::Buffer, bWindowed, ClearBackBuffer(), ClearZBuffer(), ClientWindow, cmode, DRIVERCC, DRV_ERROR_GENERIC, DRV_ERROR_INVALID_PARMS, DumpErrorLogToFile(), FALSE, VidModeListTag::flags, FrontRect, geFloat, CPUInfoTag::Has3DNow, DRV_Window::Height, tagRECT::left, LockDDrawBackBuffer(), NumPixels, DRV_Window::PixelPitch, ProcessorInfo, RENDER_NONE, RenderMode, tagRECT::right, SAL_BACK_SURFACE, SAL_lock_surface(), SAL_wipe_surface(), SetFPU24(), SetLastDrvError(), STRETCHMODE, tagRECT::top, TRUE, DRV_Window::Width, and WorldRect.

00065 {
00066         if(ProcessorInfo.Has3DNow)
00067         {
00068                 SetFPU24();
00069         }
00070 
00071         if (RenderMode != RENDER_NONE)
00072         {
00073                 SetLastDrvError(DRV_ERROR_GENERIC, "Still in some other render mode.");
00074                 return FALSE;
00075         }
00076 
00077         if(0 && pWorldRect)     //offsets still relative to the top of the screen
00078         {
00079                 WorldRect       =*pWorldRect;
00080                 WorldRect.right;
00081                 WorldRect.bottom;
00082         }
00083         else    //use full screen
00084         {
00085                 WorldRect.left  =WorldRect.top          =0;
00086                 WorldRect.right =ClientWindow.Width - 1;
00087                 WorldRect.bottom=ClientWindow.Height - 1;
00088         }
00089 
00090         if(!bWindowed)
00091         {
00092                 if(cmode->flags & STRETCHMODE)
00093                 {
00094                         geFloat xstrch, ystrch;
00095 
00096                         xstrch                  =640.0f / ((geFloat)ClientWindow.Width);
00097                         ystrch                  =480.0f / ((geFloat)ClientWindow.Height);
00098                         FrontRect.left  =(int)(xstrch * (geFloat)WorldRect.left);
00099                         FrontRect.right =(int)(xstrch * (geFloat)WorldRect.right);
00100                         FrontRect.bottom=(int)(ystrch * (geFloat)WorldRect.bottom);
00101                         FrontRect.top   =(int)(ystrch * (geFloat)WorldRect.top);
00102                 }
00103         }
00104 
00105         NumPixels = 0;
00106 
00107         if(ClearZ)
00108         {
00109                 ClearZBuffer(&ClientWindow);
00110         }
00111         if(Clear)
00112         {
00113                 if(bWindowed)
00114                 {
00115                         SAL_wipe_surface(SAL_BACK_SURFACE, 0);
00116                 }
00117                 else
00118                 {
00119                         ClearBackBuffer(&ClientWindow);
00120                 }
00121         }
00122 
00123         if(bWindowed)
00124         {
00125                 SAL_lock_surface(SAL_BACK_SURFACE, &ClientWindow.Buffer, &ClientWindow.PixelPitch);
00126         }
00127         else
00128         {
00129                 if(!LockDDrawBackBuffer(&ClientWindow, &WorldRect))
00130                 {
00131                         SetLastDrvError(DRV_ERROR_INVALID_PARMS, "World rect invalid.");
00132                         DumpErrorLogToFile("softdrv.log");
00133                         return  FALSE;
00134                 }
00135         }
00136         assert(ClientWindow.Buffer);
00137 
00138         return TRUE;
00139 }

BOOL DRIVERCC BeginWorld void   ) 
 

Definition at line 174 of file scene.c.

References ClientWindow, DRIVERCC, DRV_ERROR_GENERIC, FALSE, DRV_Window::Height, RENDER_NONE, RENDER_WORLD, RenderMode, ResetSpans(), SetLastDrvError(), and TRUE.

00175 {
00176         if (RenderMode != RENDER_NONE && RenderMode != RENDER_WORLD)
00177         {
00178                 SetLastDrvError(DRV_ERROR_GENERIC, "Still in some other render mode.");
00179                 return FALSE;
00180         }
00181 
00182         ResetSpans(ClientWindow.Height);
00183         
00184         RenderMode = RENDER_WORLD;
00185 
00186 //      if(!VirtualProtect((U8 *)ZBuffer,
00187 //              (ClientWindow.Width * ClientWindow.Height)*2,
00188 //              PAGE_READWRITE | PAGE_NOCACHE,
00189 //              &OldFlags))
00190 //      {
00191 //              ErrorPrintf("Failed to set zbuffer page uncacheable\n");
00192 //      }
00193 
00194         return TRUE;
00195 }

BOOL DRIVERCC EndMeshes void   ) 
 

Definition at line 225 of file scene.c.

References DRIVERCC, RENDER_NONE, RenderMode, and TRUE.

00226 {
00227         RenderMode = RENDER_NONE;
00228 
00229         return TRUE;
00230 }

BOOL DRIVERCC EndModels void   ) 
 

Definition at line 247 of file scene.c.

References DRIVERCC, RENDER_NONE, RenderMode, and TRUE.

00248 {
00249         RenderMode = RENDER_NONE;
00250         return TRUE;
00251 }

BOOL DRIVERCC EndScene void   ) 
 

Definition at line 141 of file scene.c.

References bWindowed, ClientWindow, cmode, DRIVERCC, DRV_ERROR_GENERIC, FALSE, FrontRect, CPUInfoTag::Has3DNow, ProcessorInfo, RefreshDDraw(), RENDER_NONE, RenderMode, RestoreFPU(), SAL_BACK_SURFACE, SAL_blit_surface(), SAL_release_surface(), SAL_serve_message_queue(), SetLastDrvError(), TRUE, UnlockDDrawBackBuffer(), and WorldRect.

00142 {
00143         if (RenderMode != RENDER_NONE)
00144         {
00145                 SetLastDrvError(DRV_ERROR_GENERIC, "Still in some other render mode.");
00146                 return FALSE;
00147         }
00148         if(bWindowed)
00149         {
00150                 SAL_release_surface(SAL_BACK_SURFACE, FALSE);
00151 //              SAL_flip_surface();
00152                 SAL_blit_surface();
00153                 SAL_serve_message_queue();
00154         }
00155         else
00156         {
00157                 UnlockDDrawBackBuffer(&ClientWindow, &WorldRect);
00158                 RefreshDDraw(&ClientWindow, cmode, &WorldRect, &FrontRect);
00159         }
00160 
00161 //      SOFTDRV.NumWorldSpans = RegPixels;
00162 //      SOFTDRV.NumRenderedPolys = RGBPixels;
00163 
00164         if(ProcessorInfo.Has3DNow)
00165         {
00166                 RestoreFPU();
00167         }
00168 
00169         return TRUE;
00170 }

BOOL DRIVERCC EndWorld void   ) 
 

Definition at line 197 of file scene.c.

References DRIVERCC, RENDER_NONE, RenderMode, and TRUE.

00198 {
00199         RenderMode = RENDER_NONE;
00200 
00201 //      if(!VirtualProtect((U8 *)ZBuffer,
00202 //              (ClientWindow.Width * ClientWindow.Height)*2,
00203 //              OldFlags,       &OldFlags))
00204 //      {
00205 //              ErrorPrintf("Failed to set zbuffer page cacheable\n");
00206 //      }
00207         return TRUE;
00208 }

void RestoreFPU void   ) 
 

Definition at line 59 of file scene.c.

References OldFPUCW.

Referenced by EndScene().

00060 {
00061         _asm    fldcw   [OldFPUCW]      ; restore the FPU
00062 }

void SetFPU24 void   ) 
 

Definition at line 46 of file scene.c.

References FPUCW, and OldFPUCW.

Referenced by BeginScene().

00047 {
00048         _asm
00049         {
00050                 fstcw   [OldFPUCW]              ; store copy of CW
00051                 mov             ax, OldFPUCW    ; get it in ax
00052                 and             eax,0xFFFFFCFF
00053 //              or              eax,0x0000600
00054                 mov             [FPUCW],ax              ; store it
00055                 fldcw   [FPUCW]                 ; load the FPU
00056         }
00057 }


Variable Documentation

VidModeList* cmode = NULL
 

Definition at line 37 of file scene.c.

U16 FPUCW
 

Definition at line 42 of file scene.c.

Referenced by SetFPU24().

RECT FrontRect
 

Definition at line 41 of file scene.c.

Referenced by BeginScene(), and EndScene().

U32 OldFlags = 0 [static]
 

Definition at line 172 of file scene.c.

U16 OldFPUCW
 

Definition at line 42 of file scene.c.

Referenced by RestoreFPU(), and SetFPU24().

CPUInfo ProcessorInfo
 

Definition at line 44 of file scene.c.

S32 RenderMode = RENDER_NONE
 

Definition at line 35 of file scene.c.

RECT WorldRect
 

Definition at line 40 of file scene.c.

Referenced by BeginScene(), and EndScene().


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