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 /*                                                                                      */
00007 /*  The contents of this file are subject to the Genesis3D Public License               */
00008 /*  Version 1.01 (the "License"); you may not use this file except in                   */
00009 /*  compliance with the License. You may obtain a copy of the License at                */
00010 /*  http://www.genesis3d.com                                                            */
00011 /*                                                                                      */
00012 /*  Software distributed under the License is distributed on an "AS IS"                 */
00013 /*  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See                */
00014 /*  the License for the specific language governing rights and limitations              */
00015 /*  under the License.                                                                  */
00016 /*                                                                                      */
00017 /*  The Original Code is Genesis3D, released March 25, 1999.                            */
00018 /*  Genesis3D Version 1.1 released November 15, 1999                                 */
00019 /*  Copyright (C) 1999 WildTangent, Inc. All Rights Reserved           */
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 //      Structure defs
00044 //================================================================================
00045 
00046 typedef struct
00047 {
00048     char                                Name[MAX_DRIVER_NAME];  // Short name of the driver 
00049     char                                About[MAX_DRIVER_NAME]; // Short string about the driver 
00050     D3DDEVICEDESC               Desc;                                   // D3DDEVICEDESC for complete information 
00051     GUID                                Guid;                                   // it's GUID 
00052     BOOL                                IsHardware;                             // does this driver represent a hardware device? 
00053     BOOL                                DoesTextures;                   // does this driver do texture mapping? 
00054     BOOL                                DoesZBuffer;                    // can this driver use a z-buffer? 
00055     BOOL                                CanDoWindow;                    // can it render to Window's display depth? 
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;                                 // We can use this driver
00066 } DDMain_D3DDriver;
00067 
00068 typedef struct 
00069 {
00070     int32                               Width;                                                  // width
00071     int32                               Height;                                                 // height
00072     int32                               Bpp;                                                    // bits per pixel 
00073     BOOL                                ThisDriverCanDo;                                // == TRUE if d3d driver can render into
00074 } App_Mode;
00075 
00076 typedef struct
00077 {
00078     DDSURFACEDESC2              ddsd;                                                   // DDSURFACEDESC for complete information 
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 // App_Info, used for everything global. 
00092 typedef struct
00093 {
00094         // Window info
00095         HWND                            hWnd;                                                           // Handle to parent Window
00096 
00097         DDSURFACEDESC2          ddsd;
00098 
00099         // Mode that we were in before initializing
00100         int32                           OldWidth;                                                       // Old screen width
00101         int32                           OldHeight;
00102         int32                           OldBpp;
00103 
00104         int32                           CurrentWidth;
00105         int32                           CurrentHeight;
00106         int32                           CurrentBpp;
00107 
00108         int32                           OldWindowWidth;                                         // Old client width
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];                        // Have no idea how big to make this.  Anyone?
00119 
00120         LPDIRECTDRAW4           lpDD;                                                           // The current initialized DD object
00121     LPDIRECT3D3             lpD3D;                                                              // The current initialized D3D object
00122 
00123     LPDIRECTDRAWSURFACE4        lpFrontBuffer;                                          // front buffer surface 
00124     LPDIRECTDRAWSURFACE4        lpBackBuffer;                                           // back buffer surface 
00125     LPDIRECTDRAWSURFACE4        lpZBuffer;                                                      // z-buffer surface 
00126         LPDIRECTDRAWCLIPPER lpClipper;                                                  // Clipper in windowed case
00127     BOOL                                BackBufferInVideo;                                      // back buf in video mem? 
00128     BOOL                                ZBufferInVideo;                                         // is Z-buf in video mem? 
00129     LPDIRECT3DDEVICE3   lpD3DDevice;                                            // D3D device 
00130     LPDIRECT3DVIEWPORT3 lpD3DViewport;                                          // D3D viewport
00131 
00132         LPDIRECT3DMATERIAL3     BackgroundMaterial;
00133 
00134         // 2d surface format (for blt'ing to the display)
00135         DDSURFACEDESC2          ddSurfFormat;                                           // 555 or 565 surface desc
00136 
00137         // Texture formats (for the D3D device)
00138         DDSURFACEDESC2          ddTexFormat;                                            // 555 or 565 surface desc
00139         DDSURFACEDESC2          ddFourBitAlphaSurfFormat;                       // 4444 surface desc
00140         DDSURFACEDESC2          ddOneBitAlphaSurfFormat;                        // 1555 surface desc
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         // Surface formats
00158         int32                           NumSurfFormats;                                         // Num 2D texture formats avail (from DD4 object)
00159     DDMain_SurfFormat   SurfFormats[DDMAIN_MAX_SURFACE_FORMATS];
00160 
00161     // Texture formats
00162         int32                           NumTextureFormats;                                      // Num 3D texture formats avail (from device)
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         // DD / D3D Flags
00186         uint32                          Flags;
00187 } App_Info;
00188 
00189 // DD enum strcuture.  Used when enuming dd
00190 typedef struct
00191 {
00192         LPDIRECTDRAW4   lpDD;
00193         char                    DriverName[MAX_DRIVER_NAME];
00194         BOOL                    FoundDD;
00195 } DD_Enum;
00196 
00197 //================================================================================
00198 //      Globals
00199 //================================================================================
00200 extern App_Info AppInfo;                                // Our global structure that knows all... (once initialized)
00201 
00202 //================================================================================
00203 //      Global functions
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

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