#include <Windows.h>#include <stdio.h>#include "D3DDrv7x.h"#include "DCommon.h"#include "Scene.h"#include "Render.h"#include "D3DCache.h"#include "D3D_Main.h"#include "PCache.h"#include "THandle.h"Go to the source code of this file.
Defines | |
| #define | NUM_PIXEL_FORMATS (sizeof(PixelFormats)/sizeof(geRDriver_PixelFormat)) |
Functions | |
| geBoolean DRIVERCC | DrvShutdown (void) |
| geBoolean DRIVERCC | ScreenShot (const char *Name) |
| BOOL DRIVERCC | DrvInit (DRV_DriverHook *Hook) |
| geBoolean DRIVERCC | DrvResetAll (void) |
| geBoolean DRIVERCC | EnumPixelFormats (DRV_ENUM_PFORMAT_CB *Cb, void *Context) |
| geBoolean DRIVERCC | SetGamma (float Gamma) |
| geBoolean DRIVERCC | GetGamma (float *Gamma) |
| BOOL DRIVERCC | EnumSubDrivers2 (DRV_ENUM_DRV_CB *Cb, void *Context) |
| BOOL DRIVERCC | EnumModes2 (int32 Driver, char *DriverName, DRV_ENUM_MODES_CB *Cb, void *Context) |
| DllExport BOOL | DriverHook (DRV_Driver **Driver) |
| void | SetLastDrvError (int32 Error, char *ErrorStr) |
Variables | |
| DRV_Window | ClientWindow |
| BOOL | ExitHandlerActive = FALSE |
| int32 | LastError |
| char | LastErrorStr [200] |
| geRDriver_PixelFormat | PixelFormat [10] |
| DRV_Driver | D3DDRV |
| DRV_EngineSettings | EngineSettings |
|
|
Definition at line 96 of file D3ddrv7x.cpp. Referenced by EnumPixelFormats(). |
|
|
Definition at line 233 of file D3ddrv7x.cpp. References DRV_EngineSettings::CanSupportFlags, D3DDRV, DllExport, DRV_ERROR_NONE, DRV_SUPPORT_ALPHA, DRV_SUPPORT_COLORKEY, DRV_Driver::EngineSettings, EngineSettings, LastErrorStr, DRV_Driver::LastErrorStr, DRV_EngineSettings::PreferenceFlags, SetLastDrvError(), and TRUE. Referenced by Engine_InitDriver(), EnumSubDrivers(), and geEngine_SoftwareDriver().
00234 {
00235 EngineSettings.CanSupportFlags = (DRV_SUPPORT_ALPHA | DRV_SUPPORT_COLORKEY);
00236 EngineSettings.PreferenceFlags = 0;//DRV_PREFERENCE_NO_MIRRORS;
00237
00238 D3DDRV.EngineSettings = &EngineSettings;
00239
00240 *Driver = &D3DDRV;
00241
00242 // Make sure the error string ptr is not null, or invalid!!!
00243 D3DDRV.LastErrorStr = LastErrorStr;
00244
00245 SetLastDrvError(DRV_ERROR_NONE, "D3DDrv: No error.");
00246
00247 return TRUE;
00248 }
|
|
|
Definition at line 51 of file D3ddrv7x.cpp.
00052 {
00053 RECT WRect;
00054
00055 // Start up
00056 if (!D3DMain_InitD3D(Hook->hWnd, Hook->DriverName+5, Hook->Width, Hook->Height))
00057 {
00058 //SetLastDrvError(DRV_ERROR_INIT_ERROR, "D3D_DrvInit: Could not init driver.\n");
00059 return FALSE;
00060 }
00061
00062 // If they are asking for a window mode, use there hWnd for the size
00063 if (Hook->Width ==-1 && Hook->Height == -1)
00064 {
00065 GetClientRect(Hook->hWnd, &WRect);
00066
00067 Hook->Width = (WRect.right - WRect.left);
00068 Hook->Height = (WRect.bottom - WRect.top);
00069 }
00070
00071 ClientWindow.Width = Hook->Width;
00072 ClientWindow.Height = Hook->Height;
00073 ClientWindow.hWnd = Hook->hWnd;
00074
00075 return TRUE;
00076 }
|
|
|
Definition at line 89 of file D3ddrv7x.cpp.
00090 {
00091 return D3DMain_Reset();
00092 }
|
|
|
Definition at line 80 of file D3ddrv7x.cpp. References D3DMain_ShutdownD3D(), DRIVERCC, and TRUE. Referenced by ErrorBox().
00081 {
00082 D3DMain_ShutdownD3D();
00083 return TRUE;
00084 }
|
|
||||||||||||||||||||
|
Definition at line 2779 of file D3D7xDrv/D3d_main.cpp.
02780 {
02781 HRESULT hr;
02782 int32 i, Width, Height;
02783 char ModeName[MAX_DRIVER_NAME];
02784 DDEnumInfo Info;
02785
02786 //Cb(0, "HackMode 2", 640, 480, Context);
02787 //return GE_TRUE;
02788
02789 Info.Drivers = Drivers;
02790 Info.NumDrivers = 0;
02791
02792 /* 07/16/2000 Wendell Buckner
02793 Convert to Directx7...
02794 hr = DirectDrawEnumerate(EnumDriversCB2, &Info); */
02795 hr = DirectDrawEnumerateEx((LPDDENUMCALLBACKEX) EnumDriversCB2, &Info, NULL);
02796
02797
02798 if (hr != DD_OK)
02799 {
02800 D3DMain_Log("D3DMain_EnumModes: DirectDrawEnumerate failed.\n");
02801 return FALSE;
02802 }
02803
02804
02805 if (!CreateDDFromName(DriverName, &Info))
02806 return GE_FALSE;
02807
02808 if (!D3DMain_EnumDisplayModes())
02809 {
02810 D3DMain_ShutdownD3D();
02811
02812 D3DMain_Log("D3DMain_EnumModes: D3DMain_EnumDisplayModes failed.\n");
02813 return FALSE;
02814 }
02815
02816 for (i=0; i< AppInfo.NumModes; i++)
02817 {
02818 if (AppInfo.Modes[i].Bpp != 16)
02819 continue;
02820
02821 // Get the width/height of mode
02822 Width = AppInfo.Modes[i].Width;
02823 Height = AppInfo.Modes[i].Height;
02824
02825 // Make a unique name
02826 sprintf(ModeName, "%ix%i", Width, Height);
02827
02828 // Call their callback with this driver mode
02829 if (!Cb(i, ModeName, Width, Height, Context))
02830 {
02831 D3DMain_ShutdownD3D();
02832 return GE_TRUE;
02833 }
02834 }
02835
02836 if (AppInfo.CanDoWindow)
02837 {
02838 if (!Cb(i, "WindowMode", -1, -1, Context))
02839 {
02840 D3DMain_ShutdownD3D();
02841 return GE_TRUE;
02842 }
02843 }
02844
02845 D3DMain_ShutdownD3D();
02846
02847 return TRUE;
02848 }
|
|
||||||||||||
|
Definition at line 98 of file D3ddrv7x.cpp.
00099 {
00100 int32 i;
00101 gePixelFormat Format3d, Format2d;
00102 uint32 CurrentBpp;
00103
00104 CurrentBpp = AppInfo.ddsd.ddpfPixelFormat.dwRGBBitCount;
00105
00106 // Setup the 2d surface format
00107 if (CurrentBpp == 32 && AppInfo.ddSurfFormat.ddpfPixelFormat.dwRGBAlphaBitMask == 0xff000000)
00108 Format2d = GE_PIXELFORMAT_32BIT_ARGB;
00109 else if (CurrentBpp == 32 && AppInfo.ddSurfFormat.ddpfPixelFormat.dwBBitMask == 0xff)
00110 Format2d = GE_PIXELFORMAT_32BIT_XRGB;
00111 else if (CurrentBpp == 24 && AppInfo.ddSurfFormat.ddpfPixelFormat.dwBBitMask == 0xff)
00112 Format2d = GE_PIXELFORMAT_24BIT_RGB;
00113 else if (AppInfo.ddSurfFormat.ddpfPixelFormat.dwGBitMask == (31<<5))
00114 Format2d = GE_PIXELFORMAT_16BIT_555_RGB;
00115 else
00116 Format2d = GE_PIXELFORMAT_16BIT_565_RGB;
00117
00118 // Setup the 3d (Texture) format
00119 if (AppInfo.ddTexFormat.ddpfPixelFormat.dwGBitMask == (31<<5))
00120 Format3d = GE_PIXELFORMAT_16BIT_555_RGB;
00121 else
00122 Format3d = GE_PIXELFORMAT_16BIT_565_RGB;
00123
00124
00125 // Create the surface formats now
00126 PixelFormat[0].PixelFormat = Format3d; // 3d 565/555 surface
00127 PixelFormat[0].Flags = RDRIVER_PF_3D | RDRIVER_PF_COMBINE_LIGHTMAP;
00128
00129 PixelFormat[1].PixelFormat = GE_PIXELFORMAT_16BIT_4444_ARGB; // 3d 4444 surface
00130 PixelFormat[1].Flags = RDRIVER_PF_3D | RDRIVER_PF_COMBINE_LIGHTMAP;
00131
00132 PixelFormat[2].PixelFormat = Format2d; // 2d 565/555 surface
00133 PixelFormat[2].Flags = RDRIVER_PF_2D | RDRIVER_PF_CAN_DO_COLORKEY;
00134
00135 PixelFormat[3].PixelFormat = Format3d; // Lightmap 565/555 surface
00136 PixelFormat[3].Flags = RDRIVER_PF_LIGHTMAP;
00137
00138 PixelFormat[4].PixelFormat = GE_PIXELFORMAT_16BIT_1555_ARGB;
00139 PixelFormat[4].Flags = RDRIVER_PF_3D | RDRIVER_PF_COMBINE_LIGHTMAP;
00140
00141 // Then hand them off to the caller
00142 for (i=0; i<5; i++)
00143 {
00144 if (!Cb(&PixelFormat[i], Context))
00145 return GE_TRUE;
00146 }
00147
00148 return TRUE;
00149 }
|
|
||||||||||||
|
Definition at line 2718 of file D3D7xDrv/D3d_main.cpp.
02719 {
02720 HRESULT hr;
02721 int32 i;
02722 DDEnumInfo Info;
02723
02724 unlink(D3DMAIN_LOG_FILENAME);
02725
02726 Info.Drivers = Drivers;
02727 Info.NumDrivers = 0;
02728
02729 /* 07/16/2000 Wendell Buckner
02730 Convert to Directx7...
02731 hr = DirectDrawEnumerate(EnumDriversCB2, &Info); */
02732 hr = DirectDrawEnumerateEx((LPDDENUMCALLBACKEX) EnumDriversCB2, &Info, NULL);
02733
02734
02735 if (hr != DD_OK)
02736 {
02737 D3DMain_Log("D3DMain_EnumSubDrivers: DirectDrawEnumerate failed.\n");
02738 return FALSE;
02739 }
02740
02741 for (i=0; i< Info.NumDrivers; i++)
02742 {
02743 // Create the DD object for this driver
02744 if (!CreateDDFromDriver(&Info.Drivers[i]))
02745 return GE_FALSE;
02746
02747 if (Main_CheckDD())
02748 {
02749 if (!Cb(i, Info.Drivers[i].Name, Context))
02750 {
02751 RELEASE(AppInfo.lpD3D);
02752 AppInfo.lpD3D = NULL;
02753
02754 //D3DMain_ShutdownD3D();
02755 RELEASE(AppInfo.lpDD);
02756 AppInfo.lpDD = NULL;
02757 memset(&AppInfo, 0, sizeof(AppInfo));
02758 break;
02759 }
02760 }
02761
02762 RELEASE(AppInfo.lpD3D);
02763 AppInfo.lpD3D = NULL;
02764
02765 //D3DMain_ShutdownD3D();
02766 RELEASE(AppInfo.lpDD);
02767 AppInfo.lpDD = NULL;
02768 memset(&AppInfo, 0, sizeof(AppInfo));
02769 }
02770
02771 //Cb(i, "(D3D)HackDriver", Context);
02772
02773 return TRUE;
02774 }
|
|
|
Definition at line 156 of file D3ddrv7x.cpp.
00157 {
00158 *Gamma = 1.0f;
00159
00160 return GE_TRUE;
00161 }
|
|
|
Definition at line 265 of file D3ddrv7x.cpp. References AppInfo, bfh, BITMAPFILEHEADER::bfOffBits, BITMAPFILEHEADER::bfSize, BITMAPFILEHEADER::bfType, DRIVERCC, FALSE, HBITMAP, height, App_Info::lpBackBuffer, NULL, TRUE, and width.
00266 {
00267 DDSURFACEDESC2 ddsd;
00268 BITMAPFILEHEADER bfh;
00269 BITMAPINFOHEADER bih;
00270 HRESULT result;
00271 HDC surfDC = NULL;
00272 HDC memDC = NULL;
00273 HBITMAP bitmap = NULL;
00274 HGDIOBJ oldbit = NULL;
00275 FILE *file = NULL;
00276 void *data= NULL;
00277 int width, height, bpp;
00278 int datasize;
00279 BOOL success = FALSE;
00280
00281 memset(&ddsd,0,sizeof(ddsd));
00282 ddsd.dwSize = sizeof(ddsd);
00283 result = AppInfo.lpBackBuffer->GetSurfaceDesc(&ddsd);
00284
00285 if (FAILED(result))
00286 goto cleanup;
00287
00288 width = ddsd.dwWidth;
00289 height= ddsd.dwHeight;
00290 bpp = ddsd.ddpfPixelFormat.dwRGBBitCount / 8;
00291
00292 if (bpp < 2)
00293 bpp = 2;
00294
00295 if (bpp > 3)
00296 bpp = 3;
00297
00298 datasize = width * bpp * height;
00299
00300 if (width * bpp % 4)
00301 datasize += height * (4 - width * bpp % 4);
00302
00303 memset((void*)&bfh, 0, sizeof(bfh));
00304
00305 bfh.bfType = 'B'+('M'<<8);
00306 bfh.bfSize = sizeof(bfh) + sizeof(bih) + datasize;
00307 bfh.bfOffBits = sizeof(bfh) + sizeof(bih);
00308
00309 memset((void*)&bih, 0, sizeof(bih));
00310
00311 bih.biSize = sizeof(bih);
00312 bih.biWidth = ddsd.dwWidth;
00313 bih.biHeight = ddsd.dwHeight;
00314 bih.biPlanes = 1;
00315 bih.biBitCount = (unsigned short)(bpp * 8);
00316 bih.biCompression = BI_RGB;
00317
00318 result = AppInfo.lpBackBuffer->GetDC(&surfDC);
00319
00320 if (FAILED(result))
00321 goto cleanup;
00322
00323 bitmap = CreateDIBSection(NULL, (BITMAPINFO *)&bih, DIB_RGB_COLORS, &data, NULL, 0);
00324
00325 if (!bitmap)
00326 goto cleanup;
00327
00328 if (!data)
00329 goto cleanup;
00330
00331 memDC = CreateCompatibleDC(surfDC);
00332
00333 if (!memDC)
00334 goto cleanup;
00335
00336 oldbit = SelectObject(memDC, bitmap);
00337
00338 if (!oldbit || FAILED(oldbit))
00339 goto cleanup;
00340
00341 result = BitBlt(memDC, 0, 0, width, height, surfDC, 0, 0, SRCCOPY);
00342
00343 if (!result)
00344 goto cleanup;
00345
00346 AppInfo.lpBackBuffer->ReleaseDC(surfDC);
00347 surfDC = NULL;
00348 file = fopen(Name, "wb");
00349
00350 if (!file)
00351 goto cleanup;
00352
00353 fwrite((void*)&bfh, sizeof(bfh), 1, file);
00354 fwrite((void*)&bih, sizeof(bih), 1, file);
00355 fwrite((void*)data, 1, datasize, file);
00356
00357 success = TRUE;
00358
00359 cleanup:
00360
00361 if (oldbit && !FAILED(oldbit))
00362 SelectObject(memDC, oldbit);
00363
00364 if (memDC)
00365 DeleteDC(memDC);
00366
00367 if (surfDC)
00368 AppInfo.lpBackBuffer->ReleaseDC(surfDC);
00369
00370 if (bitmap)
00371 DeleteObject(bitmap);
00372
00373 if (file)
00374 fclose(file);
00375
00376 return success;
00377 }
|
|
|
Definition at line 151 of file D3ddrv7x.cpp.
00152 {
00153 return GE_TRUE;
00154 }
|
|
||||||||||||
|
Definition at line 250 of file D3ddrv7x.cpp.
00251 {
00252 LastError = Error;
00253
00254 if (ErrorStr)
00255 {
00256 strcpy(LastErrorStr, ErrorStr);
00257 }
00258 else
00259 LastErrorStr[0] = NULL;
00260
00261 D3DDRV.LastErrorStr = LastErrorStr;
00262 D3DDRV.LastError = LastError;
00263 }
|
|
|
|
Definition at line 166 of file D3ddrv7x.cpp. Referenced by BeginScene(), DriverHook(), RenderWorldPoly(), RenderWorldPolys(), and SetLastDrvError(). |
|
|
Definition at line 231 of file D3ddrv7x.cpp. Referenced by DriverHook(). |
|
|
Definition at line 43 of file D3ddrv7x.cpp. |
|
|
|
Definition at line 46 of file D3ddrv7x.cpp. Referenced by DriverHook(), and SetLastDrvError(). |
|
|
Definition at line 94 of file D3ddrv7x.cpp. Referenced by Create2DTexture(), Create3DTexture(), CreateLightmapTexture(), CreatePalTexture(), CreateTexture(), EnumPixelFormats(), GTHandle_Create(), SetupCurrent3dDesc(), SWTHandle_CreateTexture(), SWTHandle_EnumPixelFormats(), and THandle_Create(). |
1.3.2