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

D3d_main.h

Go to the documentation of this file.
00001 /****************************************************************************************/
00002 /*  D3D_Main.h                                                                          */
00003 /*                                                                                      */
00004 /*  Author: John Pollard                                                                */
00005 /*  Description: DD/D3D wrapper                                                         */
00006 /*  07/16/2000 Wendell Buckner                                                          */
00007 /*   Convert to Directx7...                                                             */
00008 /*                                                                                      */
00009 /*  The contents of this file are subject to the Genesis3D Public License               */
00010 /*  Version 1.01 (the "License"); you may not use this file except in                   */
00011 /*  compliance with the License. You may obtain a copy of the License at                */
00012 /*  http://www.genesis3d.com                                                            */
00013 /*                                                                                      */
00014 /*  Software distributed under the License is distributed on an "AS IS"                 */
00015 /*  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See                */
00016 /*  the License for the specific language governing rights and limitations              */
00017 /*  under the License.                                                                  */
00018 /*                                                                                      */
00019 /*  The Original Code is Genesis3D, released March 25, 1999.                            */
00020 /*  Genesis3D Version 1.1 released November 15, 1999                                 */
00021 /*  Copyright (C) 1999 WildTangent, Inc. All Rights Reserved           */
00022 /*                                                                                      */
00023 /****************************************************************************************/
00024 #ifndef D3D_MAIN_H
00025 #define D3D_MAIN_H
00026 
00027 #include <Windows.h>
00028 #include <DDraw.h>
00029 #include <D3D.h>
00030 
00031 #define INITGUID
00032 
00033 #include "DCommon.h"
00034 
00035 #define MAX_APP_MODES                                   50
00036 #define DDMAIN_MAX_D3D_DRIVERS                  10
00037 #define DDMAIN_MAX_TEXTURE_FORMATS              128
00038 #define DDMAIN_MAX_SURFACE_FORMATS              128
00039 
00040 #define D3DMAIN_LOG_FILENAME                    "D3DDrv.Log"
00041 
00042 #define MAX_DRIVER_NAME                                 1024
00043 
00044 //================================================================================
00045 //      Structure defs
00046 //================================================================================
00047 
00048 typedef struct
00049 {
00050     char                                Name[MAX_DRIVER_NAME];  // Short name of the driver 
00051     char                                About[MAX_DRIVER_NAME]; // Short string about the driver 
00052 
00053 /* 07/16/2000 Wendell Buckner
00054     Convert to Directx7...    
00055     D3DDEVICEDESC               Desc;                                   // D3DDEVICEDESC for complete information       */
00056     D3DDEVICEDESC7              Desc;                                   // D3DDEVICEDESC for complete information 
00057 
00058     GUID                                Guid;                                   // it's GUID 
00059     BOOL                                IsHardware;                             // does this driver represent a hardware device? 
00060     BOOL                                DoesTextures;                   // does this driver do texture mapping? 
00061     BOOL                                DoesZBuffer;                    // can this driver use a z-buffer? 
00062     BOOL                                CanDoWindow;                    // can it render to Window's display depth? 
00063         BOOL                            DoesTransparency;
00064         BOOL                            DoesAlpha;
00065         BOOL                            DoesClamping;
00066         BOOL                            DoesSrcBlending;
00067         BOOL                            DoesDestBlending;
00068 
00069     WORD                                MaxTextureBlendStages;
00070     WORD                                MaxSimultaneousTextures;        
00071         
00072         BOOL                            CanUse;                                 // We can use this driver
00073 } DDMain_D3DDriver;
00074 
00075 typedef struct 
00076 {
00077     int32                               Width;                                                  // width
00078     int32                               Height;                                                 // height
00079     int32                               Bpp;                                                    // bits per pixel 
00080     BOOL                                ThisDriverCanDo;                                // == TRUE if d3d driver can render into
00081 } App_Mode;
00082 
00083 typedef struct
00084 {
00085     DDSURFACEDESC2              ddsd;                                                   // DDSURFACEDESC for complete information 
00086     BOOL                                HasOneBitAlpha; 
00087     BOOL                                HasFourBitAlpha;
00088 } DDMain_SurfFormat;
00089 
00090 typedef struct
00091 {
00092         uint32                          R[256];
00093         uint32                          G[256];
00094         uint32                          B[256];
00095         uint32                          A[256];
00096 } RGB_LUT;
00097 
00098 // App_Info, used for everything global. 
00099 typedef struct
00100 {
00101         // Window info
00102         HWND                            hWnd;                                                           // Handle to parent Window
00103 
00104         DDSURFACEDESC2          ddsd;
00105 
00106         // Mode that we were in before initializing
00107         int32                           OldWidth;                                                       // Old screen width
00108         int32                           OldHeight;
00109         int32                           OldBpp;
00110 
00111         int32                           CurrentWidth;
00112         int32                           CurrentHeight;
00113         int32                           CurrentBpp;
00114 
00115         int32                           OldWindowWidth;                                         // Old client width
00116         int32                           OldWindowHeight;
00117         int32                           WindowXOffset;
00118         int32                           WindowYOffset;
00119 
00120         RECT                            OldWindowRect;
00121         ULONG                           OldGWL_STYLE;
00122 
00123         geBoolean                       ModeSet;
00124 
00125         char                            DDName[MAX_DRIVER_NAME];                        // Have no idea how big to make this.  Anyone?
00126 
00127 /* 07/16/2000 Wendell Buckner
00128     Convert to Directx7...    
00129         LPDIRECTDRAW4           lpDD;                                                           // The current initialized DD object
00130     LPDIRECT3D3             lpD3D;                                                              // The current initialized D3D object
00131     LPDIRECTDRAWSURFACE4        lpFrontBuffer;                                          // front buffer surface 
00132     LPDIRECTDRAWSURFACE4        lpBackBuffer;                                           // back buffer surface 
00133     LPDIRECTDRAWSURFACE4        lpZBuffer;                                                      // z-buffer surface */
00134 
00135         LPDIRECTDRAW7           lpDD;                                                           // The current initialized DD object
00136     LPDIRECT3D7             lpD3D;                                                              // The current initialized D3D object
00137     LPDIRECTDRAWSURFACE7        lpFrontBuffer;                                  // front buffer surface 
00138     LPDIRECTDRAWSURFACE7        lpBackBuffer;                                   // back buffer surface 
00139     LPDIRECTDRAWSURFACE7        lpZBuffer;                                              // z-buffer surface 
00140 
00141 
00142 
00143         LPDIRECTDRAWCLIPPER lpClipper;                                                  // Clipper in windowed case
00144     BOOL                                BackBufferInVideo;                                      // back buf in video mem? 
00145     BOOL                                ZBufferInVideo;                                         // is Z-buf in video mem? 
00146 
00147 /* 07/16/2000 Wendell Buckner
00148     Convert to Directx7...    
00149     LPDIRECT3DDEVICE3   lpD3DDevice;                                            // D3D device 
00150     LPDIRECT3DVIEWPORT3 lpD3DViewport;                                          // D3D viewport 
00151         LPDIRECT3DMATERIAL3     BackgroundMaterial;                                 */
00152     LPDIRECT3DDEVICE7   lpD3DDevice;                                            // D3D device 
00153     LPD3DVIEWPORT7          lpD3DViewport;                                              // D3D viewport
00154     LPDIRECT3DDEVICE7   BackgroundMaterial;
00155 
00156         // 2d surface format (for blt'ing to the display)
00157         DDSURFACEDESC2          ddSurfFormat;                                           // 555 or 565 surface desc
00158 
00159         // Texture formats (for the D3D device)
00160         DDSURFACEDESC2          ddTexFormat;                                            // 555 or 565 surface desc
00161         DDSURFACEDESC2          ddFourBitAlphaSurfFormat;                       // 4444 surface desc
00162         DDSURFACEDESC2          ddOneBitAlphaSurfFormat;                        // 1555 surface desc
00163 
00164         RGB_LUT                         Lut1;
00165         RGB_LUT                         Lut2;
00166         RGB_LUT                         Lut3;
00167 
00168         BOOL                            IsPrimary;                                                      // 
00169         BOOL                            FullScreen;
00170         
00171         int32                           NumModes;
00172         App_Mode                        Modes[MAX_APP_MODES];
00173 
00174         int32                           NumDrivers;
00175         DDMain_D3DDriver        Drivers[DDMAIN_MAX_D3D_DRIVERS];
00176         int32                           CurrentDriver;
00177 
00178 /* 07/16/2000 Wendell Buckner
00179     Convert to Directx7...    
00180         DDDEVICEIDENTIFIER      DeviceIdentifier; */
00181     DDDEVICEIDENTIFIER2 DeviceIdentifier;
00182 
00183         // Surface formats
00184         int32                           NumSurfFormats;                                         // Num 2D texture formats avail (from DD4 object)
00185     DDMain_SurfFormat   SurfFormats[DDMAIN_MAX_SURFACE_FORMATS];
00186 
00187     // Texture formats
00188         int32                           NumTextureFormats;                                      // Num 3D texture formats avail (from device)
00189     DDMain_SurfFormat   TextureFormats[DDMAIN_MAX_TEXTURE_FORMATS];
00190 
00191         BOOL                            LogToFile;
00192         BOOL                            FoundGoodDevice;
00193         BOOL                            CanDoWindow;
00194         
00195         BOOL                            RenderingIsOK;
00196 
00197         DWORD                           VidMemFree;
00198 
00199         float                           Gamma;
00200         BOOL                            GammaChanged;
00201 
00202         geBoolean                       CanDoMultiTexture;
00203 
00204         geBoolean                       FogEnable;
00205         float                           FogStart;
00206         float                           FogEnd;
00207         float                           FogR;
00208         float                           FogG;
00209         float                           FogB;
00210 
00211         // DD / D3D Flags
00212         uint32                          Flags;
00213 } App_Info;
00214 
00215 // DD enum strcuture.  Used when enuming dd
00216 typedef struct
00217 {
00218 /* 07/16/2000 Wendell Buckner
00219     Convert to Directx7...    
00220         LPDIRECTDRAW4   lpDD;     */
00221         LPDIRECTDRAW7   lpDD;
00222         
00223         char                    DriverName[MAX_DRIVER_NAME];
00224         BOOL                    FoundDD;
00225 } DD_Enum;
00226 
00227 //================================================================================
00228 //      Globals
00229 //================================================================================
00230 extern App_Info AppInfo;                                // Our global structure that knows all... (once initialized)
00231 
00232 //================================================================================
00233 //      Global functions
00234 //================================================================================
00235 BOOL                            D3DMain_InitD3D(HWND hWnd, const char *DriverName, int32 Width, int32 Height);
00236 BOOL                            D3DMain_ShutdownD3D(void);
00237 geBoolean                       D3DMain_Reset(void);
00238 void                            D3DMain_Log(LPSTR Str, ... );
00239 BOOL                            D3DMain_RestoreAllSurfaces(void);
00240 
00241 BOOL                            Main_EnumTextureFormats(void);
00242 BOOL                            D3DMain_EnumDisplayModes(void);
00243 BOOL                            Main_ClearBackBuffer(BOOL Clear, BOOL ClearZ);
00244 BOOL                            Main_ShowBackBuffer(void);
00245 
00246 BOOL                            D3DMain_GetSurfaceFormats(void);
00247 
00248 BOOL                            Main_CheckDD(void);
00249 BOOL                            D3DMain_GetTextureMemory(void);
00250 void                            Main_BuildRGBGammaTables(float Gamma);
00251 
00252 BOOL                            D3DMain_GetClientWindowOffset(HWND hWnd);
00253 geBoolean DRIVERCC      D3DMain_UpdateWindow(void);
00254 geBoolean DRIVERCC      D3DMain_SetActive(geBoolean wParam);
00255 geBoolean DRIVERCC      D3DMain_SetFogEnable(geBoolean Enable, float r, float g, float b, float Start, float End);
00256 
00257 #endif

Generated on Tue Sep 30 12:35:32 2003 for GTestAndEngine by doxygen 1.3.2