00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef D3D_MAIN_H
00023 #define D3D_MAIN_H
00024
00025 #include <Windows.h>
00026 #include <DDraw.h>
00027 #include <D3D.h>
00028
00029 #define INITGUID
00030
00031 #include "DCommon.h"
00032
00033 #define MAX_APP_MODES 50
00034 #define DDMAIN_MAX_D3D_DRIVERS 10
00035 #define DDMAIN_MAX_TEXTURE_FORMATS 128
00036 #define DDMAIN_MAX_SURFACE_FORMATS 128
00037
00038 #define D3DMAIN_LOG_FILENAME "D3DDrv.Log"
00039
00040 #define MAX_DRIVER_NAME 1024
00041
00042
00043
00044
00045
00046 typedef struct
00047 {
00048 char Name[MAX_DRIVER_NAME];
00049 char About[MAX_DRIVER_NAME];
00050 D3DDEVICEDESC Desc;
00051 GUID Guid;
00052 BOOL IsHardware;
00053 BOOL DoesTextures;
00054 BOOL DoesZBuffer;
00055 BOOL CanDoWindow;
00056 BOOL DoesTransparency;
00057 BOOL DoesAlpha;
00058 BOOL DoesClamping;
00059 BOOL DoesSrcBlending;
00060 BOOL DoesDestBlending;
00061
00062 WORD MaxTextureBlendStages;
00063 WORD MaxSimultaneousTextures;
00064
00065 BOOL CanUse;
00066 } DDMain_D3DDriver;
00067
00068 typedef struct
00069 {
00070 int32 Width;
00071 int32 Height;
00072 int32 Bpp;
00073 BOOL ThisDriverCanDo;
00074 } App_Mode;
00075
00076 typedef struct
00077 {
00078 DDSURFACEDESC2 ddsd;
00079 BOOL HasOneBitAlpha;
00080 BOOL HasFourBitAlpha;
00081 } DDMain_SurfFormat;
00082
00083 typedef struct
00084 {
00085 uint32 R[256];
00086 uint32 G[256];
00087 uint32 B[256];
00088 uint32 A[256];
00089 } RGB_LUT;
00090
00091
00092 typedef struct
00093 {
00094
00095 HWND hWnd;
00096
00097 DDSURFACEDESC2 ddsd;
00098
00099
00100 int32 OldWidth;
00101 int32 OldHeight;
00102 int32 OldBpp;
00103
00104 int32 CurrentWidth;
00105 int32 CurrentHeight;
00106 int32 CurrentBpp;
00107
00108 int32 OldWindowWidth;
00109 int32 OldWindowHeight;
00110 int32 WindowXOffset;
00111 int32 WindowYOffset;
00112
00113 RECT OldWindowRect;
00114 ULONG OldGWL_STYLE;
00115
00116 geBoolean ModeSet;
00117
00118 char DDName[MAX_DRIVER_NAME];
00119
00120 LPDIRECTDRAW4 lpDD;
00121 LPDIRECT3D3 lpD3D;
00122
00123 LPDIRECTDRAWSURFACE4 lpFrontBuffer;
00124 LPDIRECTDRAWSURFACE4 lpBackBuffer;
00125 LPDIRECTDRAWSURFACE4 lpZBuffer;
00126 LPDIRECTDRAWCLIPPER lpClipper;
00127 BOOL BackBufferInVideo;
00128 BOOL ZBufferInVideo;
00129 LPDIRECT3DDEVICE3 lpD3DDevice;
00130 LPDIRECT3DVIEWPORT3 lpD3DViewport;
00131
00132 LPDIRECT3DMATERIAL3 BackgroundMaterial;
00133
00134
00135 DDSURFACEDESC2 ddSurfFormat;
00136
00137
00138 DDSURFACEDESC2 ddTexFormat;
00139 DDSURFACEDESC2 ddFourBitAlphaSurfFormat;
00140 DDSURFACEDESC2 ddOneBitAlphaSurfFormat;
00141
00142 RGB_LUT Lut1;
00143 RGB_LUT Lut2;
00144 RGB_LUT Lut3;
00145
00146 BOOL IsPrimary;
00147 BOOL FullScreen;
00148
00149 int32 NumModes;
00150 App_Mode Modes[MAX_APP_MODES];
00151
00152 int32 NumDrivers;
00153 DDMain_D3DDriver Drivers[DDMAIN_MAX_D3D_DRIVERS];
00154 int32 CurrentDriver;
00155 DDDEVICEIDENTIFIER DeviceIdentifier;
00156
00157
00158 int32 NumSurfFormats;
00159 DDMain_SurfFormat SurfFormats[DDMAIN_MAX_SURFACE_FORMATS];
00160
00161
00162 int32 NumTextureFormats;
00163 DDMain_SurfFormat TextureFormats[DDMAIN_MAX_TEXTURE_FORMATS];
00164
00165 BOOL LogToFile;
00166 BOOL FoundGoodDevice;
00167 BOOL CanDoWindow;
00168
00169 BOOL RenderingIsOK;
00170
00171 DWORD VidMemFree;
00172
00173 geFloat Gamma;
00174 BOOL GammaChanged;
00175
00176 geBoolean CanDoMultiTexture;
00177
00178 geBoolean FogEnable;
00179 geFloat FogStart;
00180 geFloat FogEnd;
00181 geFloat FogR;
00182 geFloat FogG;
00183 geFloat FogB;
00184
00185
00186 uint32 Flags;
00187 } App_Info;
00188
00189
00190 typedef struct
00191 {
00192 LPDIRECTDRAW4 lpDD;
00193 char DriverName[MAX_DRIVER_NAME];
00194 BOOL FoundDD;
00195 } DD_Enum;
00196
00197
00198
00199
00200 extern App_Info AppInfo;
00201
00202
00203
00204
00205 BOOL D3DMain_InitD3D(HWND hWnd, const char *DriverName, int32 Width, int32 Height);
00206 BOOL D3DMain_ShutdownD3D(void);
00207 geBoolean D3DMain_Reset(void);
00208 void D3DMain_Log(LPSTR Str, ... );
00209 BOOL D3DMain_RestoreAllSurfaces(void);
00210
00211 BOOL Main_EnumTextureFormats(void);
00212 BOOL D3DMain_EnumDisplayModes(void);
00213 BOOL Main_ClearBackBuffer(BOOL Clear, BOOL ClearZ);
00214 BOOL Main_ShowBackBuffer(void);
00215
00216 BOOL D3DMain_GetSurfaceFormats(void);
00217
00218 BOOL Main_CheckDD(void);
00219 BOOL D3DMain_GetTextureMemory(void);
00220 void Main_BuildRGBGammaTables(geFloat Gamma);
00221
00222 BOOL D3DMain_GetClientWindowOffset(HWND hWnd);
00223 geBoolean DRIVERCC D3DMain_UpdateWindow(void);
00224 geBoolean DRIVERCC D3DMain_SetActive(geBoolean wParam);
00225 geBoolean DRIVERCC D3DMain_SetFogEnable(geBoolean Enable, geFloat r, geFloat g, geFloat b, geFloat Start, geFloat End);
00226
00227 #endif