Main Page Modules Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

# deDriver.hpp

Go to the documentation of this file.

    00001 ///////////////////////////////////////////////////////////////////////////////
    00002 /// @file deDriver.hpp
    00003 ///
    00004 /// @brief base header for drivers
    00005 ///
    00006 /// @author Lightning, Assassin
    00007 ///
    00008 /// This file is the intellectual property of Novus Delta, LLC.. Usage of the
    00009 /// contents of this file is subject to the Destiny3D Member License which
    00010 /// can be found at http://www.destiny3d.com.  Any other usage is prohibited.
    00011 ///
    00012 /// This file is distributed "AS IS" without warranty of any kind.  Novus
    00013 /// Delta, LLC. does not guarantee the fitness of the contents of this file
    00014 /// for any particular purpose.
    00015 ///
    00016 /// Copyright (C) 2001-2003 Novus Delta, LLC. All Rights Reserved.
    00017 ///
    00018 /// <hr>
    00019 ///                                 Change History
    00020 /// <hr>
    00021 ///
    00022 /// @date Aug 2001
    00023 /// @author Lightning
    00024 /// @remarks Initial Creation
    00025 ///
    00026 /// @date Apr 2002
    00027 /// @author Assassin
    00028 /// @remarks Vertex Buffer mods
    00029 ///
    00030 /// @date May 2002
    00031 /// @author Assassin
    00032 /// @remarks Stencil-buffer and Render-to-Texture
    00033 ///
    00034 /// @date Jul 2004
    00035 /// @author poly-gone
    00036 /// @remarks Floating point surface format support (DX9 driver)
    00037 /// @remarks Two sided stencil support (DX9 driver)
    00038 ///
    00039 /// @todo more stencil-buffer support
    00040 /// @todo more render-to-texture capability
    00041 /// @todo pixel shader support
    00042 /// @todo poly-gone Add HDR rendering support
    00043 /// @todo poly-gone Add hard/soft shadow support
    00044 ///////////////////////////////////////////////////////////////////////////////
    00045
    00046 #ifndef DEDRIVER_HPP
    00047 #define DEDRIVER_HPP
    00048
    00049 #include "deGlobalTypes.hpp"
    00050 #include "deArray.hpp"
    00051
    00052 #if defined(DEDRIVER_DLL_EXPORTS) || defined(DESTINY3D_EXPORT_ALL)
    00053 #   define DEDRIVER_API extern "C" DEDLL_EXPORT
    00054 #elif defined(DESTINY3D_STATIC_LINK)
    00055 #   define DEDRIVER_API extern "C"
    00056 #else
    00057 #   define DEDRIVER_API extern "C" DEDLL_IMPORT
    00058 #endif
    00059
    00060 #ifdef USING_DESTINY3D
    00061 #ifdef _DEBUG
    00062 #   ifdef DESTINY3D_STATIC_LINK
    00063 #       pragma comment(lib, "deDriver_sd")
    00064 #   else
    00065 #       pragma comment(lib, "deDriverd")
    00066 #   endif //DESTINY3D_STATIC_LINK
    00067 #else
    00068 #   ifdef DESTINY3D_STATIC_LINK
    00069 #       pragma comment(lib, "deDriver_s")
    00070 #   else
    00071 #       pragma comment(lib, "deDriver")
    00072 #   endif //DESTINY3D_STATIC_LINK
    00073 #endif //_DEBUG
    00074 #endif //USING_DESTINY3D
    00075
    00076
    00077 //-------------------------------------------
    00078 // Class defines
    00079 //-------------------------------------------
    00080 class IdeDriver;
    00081 class IdeVertexBuffer;
    00082 class IdeShader;
    00083 class deDriverLoad;
    00084 class IdeDriverLoad;
    00085 class IdeBitmap;
    00086 class IdeBitmapProxy;
    00087 class IdeFileSystem;
    00088 class deString;
    00089 class IdeRenderState;
    00090 class IdeFile;
    00091 struct deTransformInfo;
    00092
    00093 // factory functions down bottom
    00094
    00095 //-------------------------------------------
    00096 // Typedefs
    00097 //-------------------------------------------
    00098
    00099 //struct typedefs
    00100 typedef struct deDriverInfo deDriverInfo;
    00101
    00102 //some internal typedef's
    00103 typedef deBoolean (*ISDESTINY3DDRIVER)();
    00104 typedef IdeDriver *(*GETDRIVERINSTANCE)(long ID);
    00105 typedef const deDriverInfo *(*GETDRIVERINFO)(long StructSize);
    00106
    00107
    00108
    00109 //-------------------------------------------
    00110 // Structures
    00111 //-------------------------------------------
    00112
    00113 typedef struct deDriverInfo
    00114 {
    00115     char *  Name;       /// name of the driver
    00116     long    Major;
    00117     long    Minor;
    00118     long    Revision;
    00119     char *  DLL;        /// dll name of the driver (filled in from DriverLoad)
    00120 } deDriverInfo;
    00121
    00122 //-------------------------------------------
    00123 // Classes
    00124 //-------------------------------------------
    00125
    00126 /// The base class that every driver is derived from.
    00127 /// The driver is a generic interface between the engine or application and the
    00128 /// specific hardware API being used - usually Direct3D or OpenGL. Through this
    00129 /// interface, various rendering states are set, resources are exposed to the
    00130 /// video hardware, and rendering of geometric objects takes place. Relevant
    00131 /// details about the video hardware itself can be queried, allowing the engine
    00132 /// or an application to appropriately allocate resources and choose render states.
    00133 /// IdeDriver is the final stopping point for data from the engine or application
    00134 /// before it's shipped off to the hardware, so it does some error and
    00135 /// redundancy checking when setting states and resources.
    00136 /// An application should generally not interface directly with IdeDriver, instead
    00137 /// using the IdeRender interface to handle things in an established manner.
    00138 //class IdeDriver
    00139 DE3D_INTERFACE_(IdeDriver)
    00140 {
    00141 public:
    00142     /// different driver types
    00143     enum Types
    00144     {
    00145         DRIVER_INVALID = -1,            ///< invalid option
    00146         DRIVER_DIRECT3D8 = 0,           ///< Direct3D driver
    00147         DRIVER_DIRECT3D9 = 2,           ///< Direct3D driver
    00148         DRIVER_OPENGL = 1,              ///< OpenGL driver
    00149         DRIVER_COUNT,                   // max value
    00150         DRIVER_FORCE_32BIT = 0x7FFFFFFF // force the enum size to 32bits
    00151     };
    00152
    00153     /// types of color formats, indicating number of bits per channel
    00154     enum BPP
    00155     {
    00156         BPP_UNKNOWN = 0,        ///< unknown the possible bits
    00157         BPP_X1R5G5B5,           ///< 16bit rgb, 5 bits for r, g, b
    00158         BPP_A1R5G5B5,           ///< 16bit argb, 1 bit for a, 5 bits for r, g, b
    00159         BPP_A4R4G4B4,           ///< 16bit argb, 4 bits for a, r, g, b
    00160         BPP_X4R4G4B4,           ///< 16bit rgb, 4 bits for r, g, b
    00161         BPP_A8,                 ///< 8bit alpha
    00162         BPP_R3G3B2,             ///< 8bit rgb, 3 bits for r, g, 2 bits for b
    00163         BPP_A8R3G3B2,           ///< 16bit argb, 8 bits for a, 3 bits for r, g, 2 bits for b
    00164         BPP_A2B10G10R10,        ///< 32bit abgr, 2 bits for a, 10 bits for b, g, r
    00165         BPP_G16R16,             ///< 32bit rg, 16 bits for g, r
    00166         BPP_R5G6B5,             ///< 16bit rgb, 5 bits for r, b, 6 bits for g
    00167         BPP_R8G8B8,             ///< 24bit rgb, 8 bits for r, g, b
    00168         BPP_A8R8G8B8,           ///< 32bit argb, 8 bits for a, r, g, b
    00169         BPP_X8R8G8B8,           ///< 32bit rgb, 8 bits for r, g, b
    00170         BPP_P8,                 ///< 8bit color indexed
    00171         BPP_A8P8,               ///< 8bit color index, 8bit alph
    00172         BPP_L8,                 ///< 8bit luminance
    00173         BPP_A8L8,               ///< 16bit luminance with alpha 8 bits for a, l
    00174         BPP_A4L4,               ///< 8bit luminance with alpha, 4 bits for a, l
    00175         BPP_V8U8,               ///< 16bit bumpmap, 8 bits for v, u
    00176         BPP_Q8W8V8U8,           ///< 32bit bumpmap, 8 bits for q, w, v, u
    00177         BPP_V16U16,             ///< 32bit bumpmap, 16 bits for u, v
    00178         BPP_W11V11U10,          ///< 32bit bumpmap, 11 bits for w, v, 10 bits for u
    00179         BPP_L6V5U5,             ///< 16bit bumpmap with luminance, 6 bits for l, 5 bits for v, u
    00180         BPP_X8L8V8U8,           ///< 32bit bumpmap with luminance, 8 bits for l, v, u
    00181         BPP_A2W10V10U10,        ///< 32bit bumpmap with alpha, 2 bits for a, 10 bits for w, v, u
    00182         BPP_UYVY,               ///< UYVY format
    00183         BPP_YUY2,               ///< YUY2 format
    00184         BPP_DXT1,               ///< DXT texture compression format
    00185         BPP_DXT2,               ///< DXT texture compression format
    00186         BPP_DXT3,               ///< DXT texture compression format
    00187         BPP_DXT4,               ///< DXT texture compression format
    00188         BPP_DXT5,               ///< DXT texture compression format
    00189         BPP_R16F,               ///< 16-bpc single channel floating point format
    00190         BPP_G16R16F,            ///< 16-bpc double channel floating point format
    00191         BPP_A16B16G16R16F,      ///< 16-bpc ABGR floating point format
    00192         BPP_R32F,               ///< 32-bpc single channel floating point format
    00193         BPP_G32R32F,            ///< 32-bpc double channel floating point format
    00194         BPP_A32B32G32R32F,      ///< 32-bpc ABGR floating point format
    00195         BPP_COUNT,              // max value
    00196         BPP_FORCE_32BIT = 0x7FFFFFFF    // force the enum size to 32bits
    00197     };
    00198
    00199     /// possible z-buffer formats
    00200     enum ZPP
    00201     {
    00202         ZPP_UNKNOWN = 0,        ///< bad value
    00203         ZPP_D16,                ///< 16-bit depth buffer
    00204         ZPP_D15S1,              ///< 15-bit depth with 1-bit stencil (0,1)
    00205         ZPP_D24,                ///< 24-bit depth buffer
    00206         ZPP_D24S4,              ///< 24-bit depth with 4-bit stencil (0-15)
    00207         ZPP_D24S8,              ///< 24-bit depth with 8-bit stencil (0-255)
    00208         ZPP_D32,                ///< 32-bit depth (some cards might not work with this)
    00209         ZPP_COUNT,
    00210         ZPP_FORCE_32BIT = 0x7FFFFFFF
    00211     };
    00212
    00213     /// list of renderstates that can be changed.
    00214     /// specify deTRUE or deFALSE as the 2nd parameter to SetRenderState unless otherwise noted
    00215     enum RenderState
    00216     {
    00217         RENDER_ZENABLE = 0,             ///< enable z buffer for depth testing
    00218         RENDER_ZENABLEUSEW,             ///< enable w buffer for depth testing
    00219         RENDER_ZWRITESENABLE,           ///< enable z-buffer writes
    00220         RENDER_DEPTHFUNCTION,           ///< type of depth compare to do (2nd param: RenderCmpFunc)
    00221         RENDER_DEPTHBIAS,               ///< bias to apply when coplanar faces are rendered. higher is closer.
    00222         RENDER_FILLMODE,                ///< type of fill mode (2nd param: RenderFillMode)
    00223         RENDER_SHADEMODE,               ///< type of shading (2nd param: RenderShadeMode)
    00224         RENDER_COLORMASK,               ///< mask for color channels (2nd param: deARGB with zero or non-zero in each channel)
    00225         RENDER_ALPHATESTENABLE,         ///< enable alpha testing on tri's
    00226         RENDER_ALPHAREF,                ///< reference alpha value to test against (2nd param: DWORD value)
    00227         RENDER_ALPHAFUNCTION,           ///< type of alpha compare to do (2nd param: RenderCmpFunc)
    00228         RENDER_ALPHABLENDENABLE,        ///< enable alpha blending
    00229         RENDER_SOURCEBLEND,             ///< type of blending on source (2nd param: RenderBlend)
    00230         RENDER_DESTBLEND,               ///< type of blending on dest (2nd param: RenderBlend)
    00231         RENDER_TEXTUREFACTOR,           ///< color to be used on multi-tex blending (2nd param: deARGB color)
    00232         RENDER_CULLMODE,                ///< type of culling (2nd param: RenderCullMode)
    00233         RENDER_FSAAENABLE,              ///< enable full-scene anti-aliasing
    00234         RENDER_FSAAMASK,                ///< set the mask for FSAA (example: 0x05)
    00235         RENDER_FOGENABLE,               ///< enable fogging (0 = off, 1 = depth-based, 2 = range-based)
    00236         RENDER_FOGSTART,                ///< start of fog as float, *((long *)&FogStart) to pass
    00237         RENDER_FOGEND,                  ///< end of fog as float, *((long *)&FogStart) to pass
    00238         RENDER_FOGCOLOR,                ///< color of fod (2nd param: deARGB color)
    00239         RENDER_CLIPPINGENABLE,          ///< enable clipping
    00240         RENDER_SWVERTEXPROCESS,         ///< enable software vertex processing
    00241         RENDER_HWLIGHTINGENABLE,        ///< enable fixed-function vertex lighting
    00242         RENDER_AMBIENTLIGHT,            ///< ambient light color value (2nd param: deARGB color)
    00243         RENDER_DITHERENABLE,            ///< enable dithering, useful in 16-bit display modes
    00244         RENDER_SPECULARENABLE,          ///< enable specular highlighting for fixed-function lighting
    00245         RENDER_SPECULARPERSPECTIVE,     ///< set specular calculations to use perspective projection
    00246         RENDER_PERVERTEXCOLOR,          ///< enable per-vertex color values to be used in lighting model
    00247         RENDER_STENCILENABLE,           ///< enable stencil buffering
    00248         RENDER_TWOSIDEDSTENCILENABLE,   ///< enable two sided stencil buffering
    00249         RENDER_STENCILREF,              ///< set the stencil reference value (2nd param: DWORD value, default value: 0)
    00250         RENDER_STENCILMASK,             ///< set the stencil mask value (2nd param: DWORD value, default value: 0xFFFFFFFF)
    00251         RENDER_STENCILWRITEMASK,        ///< set the stencil write-mask value (2nd param: DWORD value, default value: 0xFFFFFFFF)
    00252         RENDER_STENCILFUNCTION,         ///< type of stencil comparison to perform (2nd param: RenderCmpFunc)
    00253         RENDER_STENCILFAIL,             ///< operation to perform when both the stencil and depth tests fail (2nd param: RenderStencilOp)
    00254         RENDER_STENCILZFAIL,            ///< operation to perform when stencil test passes and depth test fails (2nd param: RenderStencilOp)
    00255         RENDER_STENCILPASS,             ///< operatoin to perform when both the stencil and depth tests pass (2nd param: RenderStencilOp)
    00256         RENDER_CCW_STENCILFUNCTION,     ///< type of stencil comparison to perform for second stencil "side" (2nd param: RenderCmpFunc)
    00257         RENDER_CCW_STENCILFAIL,         ///< operation to perform when both the stencil and depth tests fail (2nd param: RenderStencilOp)
    00258         RENDER_CCW_STENCILZFAIL,        ///< operation to perform when stencil test passes and depth test fails for second stencil "side" (2nd param: RenderStencilOp)
    00259         RENDER_CCW_STENCILPASS,         ///< operation to perform when both the stencil and depth tests pass for second stencil "side" (2nd param: RenderStencilOp)
    00260         RENDER_COUNT,                   //number of renderstates
    00261         RENDER_FORCE_32BIT = 0x7FFFFFFF
    00262     };
    00263
    00264     /// list of fill modes for RENDER_FILLMODE
    00265     enum RenderFillMode
    00266     {
    00267         FILL_POINT = 0,         ///< just show points
    00268         FILL_WIREFRAME,         ///< show a wireframe view
    00269         FILL_SOLID,             ///< show everything in solid (default behavior, can still render lines)
    00270         FILL_COUNT,             //number of fills
    00271         FILL_FORCE_32BIT = 0x7FFFFFFF
    00272     };
    00273
    00274     /// list of culling modes for RENDER_CULLMODE
    00275     enum RenderCullMode
    00276     {
    00277         CULL_NONE = 0,      ///< no culling
    00278         CULL_CW,            ///< cull backfaces with clockwise vertex winding
    00279         CULL_CCW,           ///< cull backfaces with counter-clockwise vertex winding
    00280         CULL_COUNT,         //number of culls
    00281         CULL_FORCE_32BIT = 0x7FFFFFFF
    00282     };
    00283
    00284     /// list of shading modes for RENDER_SHADEMODE
    00285     enum RenderShadeMode
    00286     {
    00287         SHADE_FLAT = 0,     ///< flat shading
    00288         SHADE_GOURAUD,      ///< gouraud shading
    00289         SHADE_COUNT,        //number of shades
    00290         SHADE_FORCE_32BIT = 0x7FFFFFFF
    00291     };
    00292
    00293     /// function for comparing values when performing per-pixel tests
    00294     enum RenderCmpFunc
    00295     {
    00296         COMPARE_NEVER = 0,      ///< never use pixel
    00297         COMPARE_LESS,           ///< use pixel if value is less than current
    00298         COMPARE_EQUAL,          ///< use pixel if equal value
    00299         COMPARE_LESSEQUAL,      ///< use pixel if less than or equal to current (default depth comparison)
    00300         COMPARE_GREATER,        ///< use pixel if greater than current
    00301         COMPARE_GREATEREQUAL,   ///< use pixel if greater than or equal to current
    00302         COMPARE_NOTEQUAL,       ///< use pixel if not equal to current
    00303         COMPARE_ALWAYS,         ///< always use pixel (default stencil comparison, default alpha comparison)
    00304         COMPARE_COUNT,          //count of compares
    00305         COMPARE_FORCE_32BIT = 0x7FFFFFFF
    00306     };
    00307
    00308     /// operation to perform for stenciling.
    00309     /// "max" value is (2^n)-1 where n is the bit-depth of the stencil buffer (unsigned integer).
    00310     /// (StencilRef & StencilMask) RenderCmpFunc (StencilBufferValue & StencilMask)
    00311     enum RenderStencilOp
    00312     {
    00313         STENCIL_KEEP = 0,   ///< (default value) keep the current value
    00314         STENCIL_ZERO,       ///< set the stencil-buffer entry to 0
    00315         STENCIL_REPLACE,    ///< replace the stencil-buffer entry with the reference value
    00316         STENCIL_INCRWRAP,   ///< increment the stencil-buffer entry, clamping to max
    00317         STENCIL_DECRWRAP,   ///< decrement the stencil-buffer entry, clamping to 0
    00318         STENCIL_INVERT,     ///< invert the bits in the stencil-buffer entry
    00319         STENCIL_INCR,       ///< increment the stencil-buffer entry, wrapping to 0
    00320         STENCIL_DECR,       ///< decrement the stencil-buffer entry, wrapping to max
    00321         STENCIL_COUNT,
    00322         STENCIL_FORCE_32BIT = 0x7FFFFFFF
    00323     };
    00324
    00325     /// blending operation to perform
    00326     enum RenderBlend
    00327     {
    00328         BLEND_ZERO = 0,             ///< never overwrite
    00329         BLEND_ONE,                  ///< always overwrite
    00330         BLEND_SOURCE,               ///< blend with source
    00331         BLEND_INVERSESOURCE,        ///< blend with inverse source
    00332         BLEND_SOURCEALPHA,          ///< blend with source alpha
    00333         BLEND_INVERSESOURCEALPHA,   ///< blend with inverse source alpha
    00334         BLEND_DEST,                 ///< blend with destination
    00335         BLEND_INVERSEDEST,          ///< blend with inverse destination alpha
    00336         BLEND_DESTALPHA,            ///< blend with destination alpha
    00337         BLEND_INVERSEDESTALPHA,     ///< blend with inverse destination alpha
    00338         BLEND_SOURCEALPHASAT,       ///< blend with source alpha saturation
    00339         BLEND_COUNT,                //number of blends
    00340         BLEND_FORCE_32BIT = 0x7FFFFFFF
    00341     };
    00342
    00343     /// resource types to feed into ValidFormat
    00344     enum Resource
    00345     {
    00346         RESOURCE_UNKNOWN = -1,      ///< invalid value
    00347         RESOURCE_DISPLAY,           ///< resource is a full-screen display
    00348         RESOURCE_DISPLAYWINDOWED,   ///< resource is a windowed display
    00349         RESOURCE_TEXTURE,           ///< resource is a texture
    00350         RESOURCE_RENDERTARGET,      ///< resource is a color-buffer render-target
    00351         RESOURCE_DEPTHSTENCIL,      ///< resource is a z-buffer with depth and possibly stencil information
    00352         RESOURCE_FSAA,              ///< resource alias for a full-scene anti-aliased device
    00353         RESOURCE_FSAAWINDOWED,      ///< resource alias for a full-scene anti-aliased device, in windowed mode
    00354         RESOURCE_COUNT,
    00355         RESOURCE_FORCE_32BIT = 0x7FFFFFFF
    00356     };
    00357
    00358     /// settings for how the engine should allow quality compromises
    00359     enum QualityFlag
    00360     {
    00361         QUALITY_UNKNOWN = -1,
    00362         QUALITY_ALLOW_TEXTURE_MANGLING,     ///< allow the engine to resize and adjust bitdepth of textures. boolean value.
    00363         QUALITY_ALLOW_INVALID_TEXTURES,     ///< engine will complain but allow invalid (bitdepth or size) textures to be created. boolean value.
    00364         QUALITY_FLAG_COUNT,
    00365         QUALITY_FORCE_32BIT = 0x7FFFFFFF
    00366     };
    00367
    00368     /// a basic struct used to hold display information
    00369     struct deDisplay
    00370     {
    00371         long        Adapter;        ///< adapter number
    00372         long        Width;          ///< the width of the display
    00373         long        Height;         ///< the height
    00374         HMONITOR    MonitorHandle;  ///< the handle to the attached monitor
    00375         BPP         BackBpp;        ///< the BPP format for the backbuffer/rendertarget
    00376         BPP         FrontBpp;       ///< the BPP format for the actual display
    00377         ZPP         Zpp;            ///< the Z-buffer format for the display
    00378         long        ZDepth;         ///< bit-depth for the depth channel
    00379         long        StencilDepth;   ///< bit-depth for the stencil channel
    00380         long        RefreshRate;    ///< the refresh rate of the screen, in Hertz
    00381         long        FSAASamples;    ///< number of anti-aliasing samples to take per screen pixel
    00382         deBoolean   TripleBuffer;   ///< enable triple-buffering, which can alleviate frame timing issues with VSync enabled.
    00383         deBoolean   Windowed;       ///< false for full-screen, true for windowed
    00384         deBoolean   IgnoreVSync;    ///< set to true to disable v-sync
    00385     };
    00386
    00387     /// structure for keeping track of things that happen between BeginFrame calls
    00388     struct deDriverStats
    00389     {
    00390         long VBufferUploads;        ///< number of driver vertex buffer uploads
    00391         long TextureUploads;        ///< number of driver texture uploads
    00392         long BytesUsed;             ///< number of unique bytes of data referenced during the frame
    00393     };
    00394
    00395     /// structure for evaluating the capabilities of a hardware device
    00396     struct deDriverCaps
    00397     {
    00398         char        AdapterDescription[255];    ///< name of the video card, as it identifies itself
    00399         deBoolean   HWTnL;              ///< does the card support hardware transform and lighting?
    00400         deBoolean   Dot3Support;        ///< does the card support dot-product3 for textures?
    00401         long        MaxTextureBitDepth; ///< highest texture bitdepth (16 for old cards, 32 or higher for new ones)
    00402         long        SimulTextures;      ///< number of textures that can be used at once to render
    00403         long        TexWidth;           ///< maximum texture width
    00404         long        TexHeight;          ///< maximum texture height
    00405         long        NumStreams;         ///< number of vertex streams supported
    00406         long        MaxVert;            ///< highest index value for a vertex
    00407         long        MaxPrim;            ///< maximum number of primitives renderable in a call
    00408         long        MaxLights;          ///< limit of lights in hardware fixed-function pipeline
    00409         long        VertCacheSize;      ///< number of vertices stored in post-transform cache (if known)
    00410         deFloat     VShader;            ///< supported version number of vertex shader/program
    00411         deFloat     PShader;            ///< supported version number of pixel/fragment shader/program
    00412     };
    00413
    00414 protected:
    00415     virtual ~IdeDriver() {}
    00416 public:
    00417     /// Delete the object
    00418     virtual long Release() = 0;
    00419     virtual deBoolean Init(HWND WindowHandle) = 0;
    00420     //display modification functions
    00421
    00422     /// Set the display up, creating a new internal render device
    00423     /// @param Display [in] user-defined display settings, may not be NULL
    00424     virtual deBoolean SetDisplay(deDisplay *Display) = 0;
    00425     /// Reset the driver, possibly with altered display properties.
    00426     /// Resetting will cause all vertex buffers and textures to be flushed
    00427     /// @param Display [in] user-defined display settings, may be NULL to keep current settings
    00428     virtual deBoolean Reset(deDisplay *Display = NULL) = 0;
    00429     /// Get a pointer to the driver's internally-held display struct
    00430     virtual const deDisplay* GetDisplay() const = 0;
    00431     /// Fill a deDisplay with an adapter's CURRENT (even un-renderable) display settings.
    00432     /// If a fullscreen rendering mode has not been set up, this will be the desktop settings.
    00433     virtual deBoolean GetCurrentDisplay(long Adapter, deDisplay * Display) const = 0;
    00434     /// Feed in a display struct to be filled in for the enumerated mode
    00435     /// @param Display [in, out] pointer to a user-created deDisplay struct to be filled in, may not be NULL
    00436     virtual deBoolean GetDisplayMode(long Adapter, long Mode, deDisplay *Display) const = 0;
    00437     /// Fill a deDriverCaps structure with an adapter's device capabilities
    00438     virtual const deDriverCaps* GetCaps(long Adapter) const = 0;
    00439     /// Update the driver's knowledge of the client-window rect
    00440     virtual deRect UpdateWindowRect() = 0;
    00441     /// Get the driver's internally-held client-window rect
    00442     virtual deRect GetDisplayRect() const = 0;
    00443
    00444     /// Get the number of adapters supported under this driver
    00445     virtual long GetAdapterCount() const = 0;
    00446     /// Get the number of modes for a particular adapter
    00447     virtual long GetModeCount(long Adapter) const = 0;
    00448     /// Test whether windowed mode is allowed on a particular adapter
    00449     virtual deBoolean WindowedAllowed(long Adapter) const = 0;
    00450     /// Test for a valid format for various resource types
    00451     virtual deBoolean ValidFormat(long Adapter, Resource ResourceType, BPP BPPType, ZPP ZPPType, BPP FrontBuffer, long ExtraFlag=0) const = 0;
    00452     /// Get the bit-depth of a particular color format
    00453     virtual long BitDepth(BPP BPPType) const = 0;
    00454     /// Get the bit-depth of a particular z-buffer format
    00455     virtual long BitDepth(ZPP ZPPType) const = 0;
    00456     /// Get the bit-depth devoted to stencil channel in z-buffer format
    00457     virtual long StencilDepth(ZPP ZPPType) const = 0;
    00458     /// Test whether a particular z-buffer format supports stenciling
    00459     virtual deBoolean HasStencil(ZPP ZPPType) const = 0;
    00460
    00461     //vertex buffer functions
    00462     /// Add a vertex buffer to the driver
    00463     virtual deBoolean AddVertexBuffer(IdeVertexBuffer *Vertex) = 0;
    00464     /// Remove a vertex buffer from the driver
    00465     virtual deBoolean RemoveVertexBuffer(IdeVertexBuffer *Vertex) = 0;
    00466     /// Update a vertex buffer so the driver's internal data matches it
    00467     virtual deBoolean UpdateVertexBuffer(IdeVertexBuffer *Vertex) = 0;
    00468
    00469     // Shader functions (incomplete)
    00470     virtual deBoolean AddShader(IdeShader * Shader) = 0;
    00471     virtual deBoolean SetShader(IdeShader * Shader) = 0;
    00472     virtual deBoolean RemoveShader(IdeShader * Shader) = 0;
    00473
    00474     //frame functions
    00475     /// Call before rendering anything
    00476     virtual deBoolean BeginFrame() = 0;
    00477     /// Finish the render and update the front-buffer
    00478     virtual deBoolean EndFrame() = 0;
    00479
    00480     /// Clear the frame with a particular color
    00481     virtual deBoolean ClearFrame(deARGB Color, deBoolean ClearTarget = deTRUE, deBoolean ClearZBuffer = deTRUE, deBoolean ClearStencil = deTRUE) = 0;
    00482
    00483     /// Render the selected Vertex Buffer to the back-buffer
    00484     virtual deBoolean Render(IdeVertexBuffer *VBuffer, long IndexOffset, IdeVertexBuffer *IndexOverride = NULL) = 0;
    00485
    00486     //viewport/FOV functions
    00487     /// Set the screen-space viewport
    00488     virtual deBoolean SetViewport(long X, long Y, long Width, long Height, deFloat MinZ, deFloat MaxZ) = 0;
    00489     virtual deBoolean SetDepthRange(deFloat MinZ, deFloat MaxZ) = 0;
    00490     /// Set up a perspective view transformation
    00491     virtual deBoolean SetFOVClipping(deFloat FOV, deFloat Aspect, deFloat ClipNear, deFloat ClipFar) = 0;
    00492     /// Set up an orthographic (parallel projection) view transformation
    00493     virtual deBoolean SetOrthoClipping(deFloat Width, deFloat Height, deFloat ClipNear, deFloat ClipFar, deBoolean Invert = deFALSE) = 0;
    00494     /// Set up a perspective view transformation with a sub-rect specified in the [0,1] range
    00495     virtual deBoolean SetFOVClippingSubRect(deFloat FOVY, deFloat Aspect, deFloat ClipNear, deFloat ClipFar, deRect SubRect) = 0;
    00496     virtual deBoolean SetFOVClippingSubRectFloat(deFloat FOVY, deFloat Aspect, deFloat ClipNear, deFloat ClipFar, deFloatRect SubRect) = 0;
    00497     /// Set up an orthographic (parallel projection) view transformation with a sub-rect specified in the [0,1] range
    00498     virtual deBoolean SetOrthoClippingSubRect(deFloat Width, deFloat Height, deFloat ClipNear, deFloat ClipFar, deBoolean Invert, deRect SubRect) = 0;
    00499     virtual deBoolean SetOrthoClippingSubRectFloat(deFloat Width, deFloat Height, deFloat ClipNear, deFloat ClipFar, deBoolean Invert, deFloatRect SubRect) = 0;
    00500     virtual deBoolean SetScissorRect(deRect ScissorRect) = 0;
    00501
    00502     //camera transformation functions
    00503     /// Set the camera transform (position and orientation)
    00504     virtual deBoolean SetCameraTransform(deTransformInfo *M) = 0;
    00505
    00506     //world transformation functions
    00507     /// Set the world transform (to take things from "object space" to "world space")
    00508     virtual deBoolean SetWorldTransform(deTransformInfo * Mat) = 0;
    00509
    00510     // texture transformation functions
    00511     /// Set the texture transform for a particular stage
    00512     virtual deBoolean SetTextureTransform(long StageNum, deTransformInfo * Mat) = 0;
    00513
    00514     //texture functions
    00515     /// Adds a bitmap to the driver, turning it into a driver texture, and possibly a render-target.
    00516     virtual deBoolean AddBitmap(IdeBitmap *Bitmap) = 0;
    00517     /// Adds a bitmap to the driver, turning it into a driver texture, and possibly a render-target.
    00518     virtual deBoolean AddBitmapProxy(IdeBitmapProxy *BitmapProxy) = 0;
    00519     /// Removes a bitmap from a driver by deleting the internal driver texture.
    00520     virtual deBoolean RemoveBitmap(IdeBitmap *Bitmap) = 0;
    00521
    00522     //render-to-texture functions
    00523     /// Sets the current render-target to the bitmap passed in, if the bitmap
    00524     /// can be a render-target.
    00525     /// @param pBitmap [in] Bitmap that is a render-target to be rendered to. This bitmap
    00526     ///                will only act as a handle to the internal driver texture being used,
    00527     ///                it doesn't contain a copy of what the video card's texture stores
    00528     virtual deBoolean RenderTo(IdeBitmap *pBitmap, long CubeMapFace = 0) = 0;
    00529     /// Copies the frontbuffer into the bitmap specified
    00530     /// cannot be a render-target
    00531     /// @param pBitmap [out] Bitmap pointer that is to have the screen data copied into.
    00532     ///                A new deBitmap object will be created internally, and its address stored into this parameter.
    00533     ///                After the data is copied, you must save the file to disk manually, if desired.
    00534     virtual deBoolean ScreenShot(IdeBitmap * &pBitmap, deBoolean GrabWindow = deTRUE) = 0;
    00535     virtual deBoolean GetVideoTexture(IdeBitmap* pBitmap, long CubeMapFace = 0) = 0;
    00536
    00537     //render states
    00538     /// Get current value of the State passed in
    00539     virtual unsigned long GetRenderState(RenderState State) = 0;
    00540     /// Set a class-based render-state (texture, material, or light).
    00541     virtual deBoolean SetRenderState(const IdeRenderState *State) = 0;
    00542     /// Set a value-based render-state
    00543     virtual deBoolean SetRenderState(RenderState State, unsigned long Value) = 0;
    00544     virtual deBoolean EnableLight(long LightID, deBoolean Enable) = 0;
    00545     /// Disable all fixed-function lights
    00546     virtual deBoolean DisableAllLights() = 0;
    00547     /// Get the status of a particular quality flag
    00548     virtual unsigned long GetQualityFlag(QualityFlag Flag) = 0;
    00549     /// Set the status of a particular quality flag
    00550     virtual deBoolean SetQualityFlag(QualityFlag Flag, unsigned long Value) = 0;
    00551
    00552     //driver info
    00553     /// Get the type of driver this is
    00554     virtual IdeDriver::Types GetType() const = 0;
    00555     /// Get some information about the driver
    00556     virtual deDriverInfo *GetInfo() const = 0;
    00557     virtual long GetCount() = 0;
    00558
    00559     //logging info
    00560     /// Log text to the driver's log file
    00561     virtual void LogInfo(char *Data, ...) = 0;
    00562     /// Get a pointer to the driver's internal statistics structure
    00563     virtual deDriverStats* GetDriverStats() = 0;
    00564     /// Reset the driver's internal statistics structure to all zeroes
    00565     virtual void ResetDriverStats() = 0;
    00566 };
    00567
    00568 /// used to load up a driver from a set location.
    00569 /// Related functions: IdeDriverLoad_CreateDriverLoad
    00570 //class IdeDriverLoad
    00571 DE3D_INTERFACE_(IdeDriverLoad)
    00572 {
    00573 protected:
    00574     virtual ~IdeDriverLoad() {}
    00575 public:
    00576     virtual long Release() = 0;
    00577
    00578     //basic driver info functions
    00579     /// get the number of drivers found
    00580     virtual long GetCount() = 0;
    00581     virtual const deDriverInfo *GetInfo(long DriverNumber) = 0;
    00582     virtual const deDriverInfo *GetInfo(char *DriverName) = 0;
    00583     /// get an instance of an enumerated driver
    00584     virtual IdeDriver *GetDriver(long DriverNumber) = 0;
    00585     virtual IdeDriver *GetDriver(char *DriverName) = 0;
    00586 };
    00587
    00588 /// used to store vertex information in order to render triangulated meshes.
    00589 /// Related functions: IdeVertexBuffer_CreateVBuffer, IdeVertexBuffer_CreateSubVBuffer
    00590 //class IdeVertexBuffer : virtual public IdeRefCountBase
    00591 DE3D_INTERFACE(IdeVertexBuffer, IdeRefCountBase)
    00592 {
    00593 public:
    00594     /// internal buffer types possible to create and use
    00595     enum BufferType
    00596     {
    00597         BUFFER_POSITION = 0,
    00598         BUFFER_NORMAL,
    00599         BUFFER_DIFFUSE,
    00600         BUFFER_SPECULAR,
    00601         BUFFER_TEXTURECOORDS0,
    00602         BUFFER_TEXTURECOORDS1,
    00603         BUFFER_TEXTURECOORDS2,
    00604         BUFFER_TEXTURECOORDS3,
    00605         BUFFER_TEXTURECOORDS4,
    00606         BUFFER_TEXTURECOORDS5,
    00607         BUFFER_TEXTURECOORDS6,
    00608         BUFFER_TEXTURECOORDS7,
    00609         BUFFER_INDICES16,
    00610         BUFFER_INDICES32,
    00611         BUFFER_COUNT,
    00612         BUFFER_FORCE_32BIT = 0x7FFFFFFF
    00613     };
    00614
    00615     /// type of rendering for the buffer
    00616     enum RenderType
    00617     {
    00618         RENDER_POINTLIST = 0,
    00619         RENDER_LINELIST,
    00620         RENDER_LINESTRIP,
    00621         RENDER_TRIANGLELIST,
    00622         RENDER_TRIANGLESTRIP,
    00623         RENDER_TRIANGLEFAN,
    00624         RENDER_COUNT,
    00625         RENDER_FORCE_32BIT = 0x7FFFFFFF
    00626     };
    00627
    00628     /// data types that the different buffers are (with different byte-sizes)
    00629     enum BufferDataType
    00630     {
    00631         BUFFER_DATALONG = 0,
    00632         BUFFER_DATAFLOAT,
    00633         BUFFER_DATAFLOAT2,
    00634         BUFFER_DATAFLOAT3,
    00635         BUFFER_DATASHORT,
    00636         BUFFER_DATACOUNT,
    00637         BUFFER_DATAFORCE_32BIT = 0x7FFFFFFF
    00638     };
    00639
    00640     /// types of vbuffer that this could be
    00641     enum VBufferType
    00642     {
    00643         BUFFERTYPE_REAL = 0,
    00644         BUFFERTYPE_SUB,
    00645         BUFFERTYPE_COUNT,
    00646         BUFFERTYPE_FORCE_32BIT = 0x7FFFFFFF
    00647     };
    00648
    00649 protected:
    00650     //destructor
    00651     virtual ~IdeVertexBuffer() {}
    00652
    00653 public:
    00654     virtual const IdeVertexBuffer& operator=(const IdeVertexBuffer &S) = 0;
    00655
    00656     //buffer information
    00657     virtual void* GetBuffer(BufferType Type) const = 0;
    00658
    00659     //vertex information
    00660     virtual long GetVertexCount() const = 0;
    00661     virtual long GetVertexStart() const = 0;
    00662
    00663     //index information
    00664     virtual long GetIndexCount() const = 0;
    00665     virtual long GetIndexStart() const = 0;
    00666
    00667     //tri information
    00668     virtual long GetTriCount() const = 0;
    00669     virtual deBoolean CalcTriCount() = 0;
    00670
    00671     //static/dynamic information
    00672     virtual deBoolean GetDynamicStatusVertex() const = 0;
    00673     virtual deBoolean GetDynamicStatusIndex() const = 0;
    00674     virtual void SetDynamicStatus(deBoolean Vertex, deBoolean Index) = 0;
    00675
    00676     //type of rendering we are doing
    00677     virtual RenderType GetRenderType() const = 0;
    00678     virtual deBoolean SetRenderType(RenderType Type) = 0;
    00679
    00680     //buffer functions
    00681     virtual deBoolean SetBufferSize(long EntryCount, deBoolean IndicesNotVertices = deFALSE) = 0;
    00682     virtual deBoolean CreateBuffer(BufferType Type, deBoolean Clear) = 0;
    00683     virtual deBoolean DestroyBuffer(BufferType Type) = 0;
    00684     virtual deBoolean FillBuffer(BufferType Type, const void *Buffer, long StartEntry, long EntryCount) = 0;
    00685     virtual void DirtyBuffer(BufferType Type) = 0;
    00686     virtual deBoolean BufferExists(BufferType Type) const = 0;
    00687
    00688     //for doing separate index and data buffers
    00689     virtual deBoolean BindDataBuffer(IdeVertexBuffer* DataBuffer) = 0;
    00690     virtual IdeVertexBuffer* GetBoundDataBuffer() const = 0;
    00691
    00692     //a function to obtain the buffer data type
    00693     virtual BufferDataType GetBufferDataType(BufferType Type, long *Size) const = 0;
    00694
    00695     //lock/unlock functions
    00696     virtual deBoolean Lock() = 0;
    00697     virtual deBoolean Unlock() = 0;
    00698
    00699     //functions for the driver class to tell the vertex class of info to store
    00700     virtual deBoolean SetDriverBuffer(long ID, void *Buffer, IdeDriver * Driver) = 0;
    00701     virtual void *GetDriverBuffer(long ID, long *BufferUpdateList) const = 0;
    00702
    00703     // stuff for the sub-vbuffer capability
    00704     virtual VBufferType GetVBufferType() const = 0;
    00705     virtual IdeVertexBuffer* GetParentBuffer() const = 0;
    00706 };
    00707
    00708 /// a rewritten vertex buffer class
    00709 /// (new, not finished yet)
    00710 //class IdeVertexBuffer2 : public IdeRefCountBase
    00711 DE3D_INTERFACE(IdeVertexBuffer2, IdeRefCountBase)
    00712 {
    00713 public:
    00714     /// type of rendering for the buffer
    00715     enum Primitive_t
    00716     {
    00717         RENDER_POINTLIST = 0,   ///< render points (v1),(v2)...
    00718         RENDER_LINELIST,        ///< render lines (v1,v2),(v3,v4)...
    00719         RENDER_LINESTRIP,       ///< render lines (v1,v2),(v2,v3)...
    00720         RENDER_TRIANGLELIST,    ///< render triangles (v1,v2,v3),(v4,v5,v6)...
    00721         RENDER_TRIANGLESTRIP,   ///< render triangles (v1,v2,v3),(v3,v2,v4)...
    00722         RENDER_TRIANGLEFAN,     ///< render triangles (v1,v2,v3),(v1,v4,v5)...
    00723         RENDER_COUNT,
    00724         RENDER_FORCE_32BIT = 0x7FFFFFFF
    00725     };
    00726     /// Usage specifier for a vertex stream.
    00727     enum DataUsage_t
    00728     {
    00729         // basic
    00730         USAGE_POSITION = 0, ///< untransformed position
    00731         USAGE_NORMAL,       ///< vertex normal
    00732         USAGE_TEXCOORD,     ///< texture coordinates
    00733         USAGE_COLOR,        ///< vertex color
    00734         // esoteric
    00735         USAGE_TANGENT,      ///<
    00736         USAGE_BINORMAL,     ///<
    00737         USAGE_BLENDWEIGHT,  ///<
    00738         USAGE_BLENDINDICES, ///<
    00739         USAGE_FOG,          ///<
    00740         USAGE_TESSFACTOR,   ///<
    00741         USAGE_POSITION_T,   ///<
    00742         USAGE_DEPTH,        ///<
    00743         USAGE_SAMPLE,       ///<
    00744         USAGE_COUNT,
    00745         USAGE_FORCE_32BIT = 0x7FFFFFFF
    00746     };
    00747
    00748     /// Data types that the different buffers are (with different byte-sizes).
    00749     /// All have sizes that are multiples of 32 bytes, and may be padded if necessary.
    00750     enum DataType_t
    00751     {
    00752         DATA_FLOAT32_1,     ///< (float_1, 0, 0, 1)
    00753         DATA_FLOAT32_2,     ///< (float_1, float_2, 0, 1)
    00754         DATA_FLOAT32_3,     ///< (float_1, float_2, float_3, 1)
    00755         DATA_FLOAT32_4,     ///< (float_1, float_2, float_3, float_4)
    00756         DATA_ARGB,          ///< (R, G, B, A)
    00757         DATA_U8_4,          ///< (u8_1, u8_2, u8_3, u8_4)
    00758         DATA_S16_2,         ///< (s16_1, s16_2, 0, 1)
    00759         DATA_S16_4,         ///< (s16_1, s16_2, s16_3, s16_4)
    00760         DATA_U8_4N,         ///< normalized version of DATA_U8_4
    00761         DATA_S16_2N,        ///< normalized version of DATA_S16_2
    00762         DATA_S16_4N,        ///< normalized version of DATA_S16_4
    00763         DATA_U16_2N,        ///< normalized, unsigned version of DATA_S16_2
    00764         DATA_U16_4N,        ///< normalized, unsigned version of DATA_S16_4
    00765         DATA_U10_3,         ///< (u10_1, u10_2, u10_3, 1)
    00766         DATA_S10_3N,        ///< normalized, signed version of DATA_U10_3
    00767         DATA_FLOAT16_2,     ///< (float_1, float_2, 0, 1)
    00768         DATA_FLOAT16_4,     ///< (float_1, float_2, float_3, float_4)
    00769         DATA_COUNT,
    00770         DATA_FORCE_32BIT = 0x7FFFFFFF
    00771     };
    00772     enum StreamFlag_t
    00773     {
    00774         FLAG_DYNAMIC,
    00775         FLAG_INSTANCES,
    00776         FLAG_COUNT,
    00777         FLAG_FORCE_32BIT = 0x7FFFFFFF
    00778     };
    00779     struct UsageDescriptor_t
    00780     {
    00781         DataUsage_t Usage;      ///< semantic of vertex element
    00782         u32         UsageIndex; ///< instance of this semantic
    00783     };
    00784     /// Used to store the specifics of a vertex element
    00785     struct StreamDescriptor_t
    00786     {
    00787         UsageDescriptor_t Usage;    ///< how the element is to be used
    00788         DataType_t  Type;           ///< what kind of data is stored in the element
    00789     };
    00790
    00791 protected:
    00792     virtual ~IdeVertexBuffer2() {}
    00793 public:
    00794 /// @todo implement IdeVertexBuffer2
    00795
    00796     virtual void*       LockStream(UsageDescriptor_t element) = 0;
    00797     virtual deBoolean   UnlockStream(UsageDescriptor_t element, deBoolean modified = deTRUE) = 0;
    00798     virtual deBoolean   CreateStream(UsageDescriptor_t element, DataType_t datatype) = 0;
    00799     virtual deBoolean   SetStreamFlag(UsageDescriptor_t element, StreamFlag_t flag, u32 value) = 0;
    00800     virtual deBoolean   GetStreamFlag(UsageDescriptor_t element, StreamFlag_t flag, u32* value) = 0;
    00801
    00802     virtual DataType_t  GetStreamDataType(UsageDescriptor_t element) const = 0;
    00803     virtual deBoolean   StreamExists(UsageDescriptor_t element) const = 0;
    00804
    00805     virtual deBoolean   SetVertexCount(u32 count) = 0;
    00806     virtual deBoolean   SetIndexCount(u32 count) = 0;
    00807     virtual deBoolean   SetPrimitiveType(Primitive_t primitiveType) = 0;
    00808
    00809     virtual u32         GetVertexCount() const = 0;
    00810     virtual u32         GetIndexCount() const = 0;
    00811     virtual u32         GetPrimitiveCount() const = 0;
    00812     virtual Primitive_t GetPrimitiveType() const = 0;
    00813
    00814     //functions for the driver class to tell the vertex class of info to store
    00815     virtual deBoolean   DriverSetInfo(IdeDriver * pDriver, void *Info) = 0;
    00816     virtual void *      DriverGetInfo(IdeDriver * pDriver, deBoolean* &UpdatedStreams) const = 0;
    00817     virtual u32         DriverGetNumStreams() = 0;
    00818     virtual StreamDescriptor_t* DriverGetStreamDescriptors();
    00819     virtual u32         DriverLock() = 0;
    00820     virtual u32         DriverUnlock() = 0;
    00821 };
    00822
    00823 /// The interface for vertex and pixel shaders
    00824 //class IdeShader : virtual public IdeRefCountBase
    00825 DE3D_INTERFACE(IdeShader, IdeRefCountBase)
    00826 {
    00827 public:
    00828     /// Shader types.
    00829     enum ShaderType
    00830     {
    00831         SHADER_INVALID = -1,    ///< Invalid Shader
    00832         SHADER_VERTEX,          ///< Vertex shader
    00833         SHADER_PIXEL,           ///< Pixel shader
    00834         SHADER_FORCE_32BIT = 0x7FFFFFFF ///< Force a 32 bit enum
    00835     };
    00836
    00837     /// Shader instruction types
    00838     enum deShaderInstructionType
    00839     {
    00840         INSTRUCTION_VERSION_VERTEX = 0, ///< Vertex Shader Version Instruction
    00841         INSTRUCTION_VERSION_PIXEL,      ///< Pixel Shader Version Instruction
    00842         INSTRUCTION_ADD,                ///< "add" instruction
    00843         INSTRUCTION_DP3,                ///< "dp3" instruction
    00844         INSTRUCTION_DP4,                ///< "dp4" instruction
    00845         INSTRUCTION_DST,                ///< "dst" instruction
    00846         INSTRUCTION_EXPP,               ///< "expp" instruction
    00847         INSTRUCTION_LIT,                ///< "lit" instruction
    00848         INSTRUCTION_LOGP,               ///< "logp" instruction
    00849         INSTRUCTION_MAD,                ///< "mad" instruction
    00850         INSTRUCTION_MAX,                ///< "max" instruction
    00851         INSTRUCTION_MIN,                ///< "min" instruction
    00852         INSTRUCTION_MOV,                ///< "mov" instruction
    00853         INSTRUCTION_MUL,                ///< "mul" instruction
    00854         INSTRUCTION_RCP,                ///< "rcp" instruction
    00855         INSTRUCTION_RSQ,                ///< "rsq" instruction
    00856         INSTRUCTION_SGE,                ///< "sge" instruction
    00857         INSTRUCTION_SLT,                ///< "slt" instruction
    00858         INSTRUCTION_SUB,                ///< "sub" instruction
    00859         INSTRUCTION_DECLARE_CONSTANT,   ///< "DECLARE_CONSTANT" instruction
    00860         INSTRUCTION_DECLARE_MATRIX,     ///< "DECLARE_MATRIX" instruction
    00861         INSTRUCTION_FORCE_32BIT = 0x7FFFFFFF ///< Force a 32-Bit enumeration
    00862     };
    00863
    00864     // Shader arguments
    00865     enum Argument
    00866     {
    00867         ARGUMENT_INVALID = 0,                   ///< Invalid Argument
    00868         ARGUMENT_VERSION_1 = 0x00000001,        ///< 1.0 version argument
    00869         ARGUMENT_CONSTANT = 0x00010000,         ///< Constant registers start
    00870         ARGUMENT_TEMP = 0x00610000,             ///< Temporary registers start
    00871         ARGUMENT_VERTEX = 0x006D0000,           ///< Vertex data registers Start
    00872         ARGUMENT_OUTPOS = 0x007D0000,           ///< Output position register
    00873         ARGUMENT_OUTCOLOR = 0x007E0000,         ///< Output color registers
    00874         ARGUMENT_OUTFOG = 0x00800000,           ///< Output fog register
    00875         ARGUMENT_OUTPTS = 0x00810000,           ///< Point size register
    00876         ARGUMENT_OUTTEX = 0x00820000,           ///< Output texture coordinates registers start
    00877         ARGUMENT_OUTTEX_END = 0x008A0000,       ///< Output texture coordinates registers end
    00878         ARGUMENT_DE_TRANSFORM = 0,              ///< DE_TRANSFORM argument
    00879         ARGUMENT_DE_PROJECTION = 1,             ///< DE_PROJECTION argument
    00880         ARGUMENT_DE_TRANSFORM_PROJECTION = 2,   ///< DE_TRANSFORM_PROJECTION argument
    00881         ARGUMENT_DE_IDENTITY = 3,               ///< DE_IDENTITY argument
    00882         ARGUMENT_DE_INVERSE = 4,                ///< DE_INVERSE argument
    00883         ARGUMENT_DE_TRANSPOSE = 5,              ///< DE_TRANSPOSE argument
    00884         ARGUMENT_DE_INVERSE_TRANSPOSE = 6,      ///< DE_INVERSE_TRANSPOSE argument
    00885         ARGUMENT_FORCE_32BIT = 0x7FFFFFFF ///< Force a 32-Bit enumeration
    00886     };
    00887
    00888     /// A struct used to hold information about a shader instruction
    00889     struct deShaderInstruction
    00890     {
    00891         deShaderInstructionType Type;
    00892         DWORD Arguments[3];
    00893     };
    00894
    00895     /// A struct used to hold information about a shader constant
    00896     struct deShaderConstant
    00897     {
    00898         deShaderInstructionType Type;
    00899         float Arguments[5];
    00900     };
    00901
    00902 protected:
    00903     // destructor
    00904     virtual ~IdeShader() {}
    00905
    00906     // Public member functions
    00907 public:
    00908     /// Assembles a shader.
    00909     /// @param Code [in] Shader code to assemble.
    00910     /// @param ErrorCallback [in] Callback function that is called when parsing errors occur.
    00911     virtual deBoolean Assemble(char * Code,void (*ErrorCallback)(long LineNumber,char * Error)) = 0;
    00912
    00913     /// Disassembles the shader.
    00914     /// @param Code [out] A pointer to a valid deString to put the shader code in.
    00915     virtual deBoolean Disassemble(deString * Code) = 0;
    00916
    00917     /// Returns the shader's type.
    00918     virtual ShaderType GetShaderType() const = 0;
    00919
    00920     /// Returns the number of instructions the shader contains
    00921     virtual long GetInstructionCount() const = 0;
    00922
    00923     /// Return the shader's instruction array
    00924     virtual const deTArray<deShaderInstruction> * GetInstructions() const = 0;
    00925
    00926     /// Return the number of constants the shader contains
    00927     virtual long GetConstantCount() const = 0;
    00928
    00929     /// Return the shader's constant array
    00930     virtual const deTArray<deShaderConstant> * GetConstants() const = 0;
    00931
    00932     /// Writes the assembled shader to a file
    00933     /// @param FileSystem [in] A pointer to a valid IdeFileSystem to write to
    00934     virtual deBoolean Write(IdeFile * File) const = 0;
    00935
    00936     /// Reads an  assembled shader from a file
    00937     /// @param FileSystem [in] A pointer to a valid IdeFileSystem to read a shader from
    00938     virtual deBoolean Read(IdeFile * File) = 0;
    00939
    00940     /// Called by the driver to set driver specific shader data
    00941     /// @param Shader [in] A pointer to the driver's private data
    00942     virtual deBoolean SetDriverShader(void * Shader) = 0;
    00943
    00944     /// Called by the driver. Returns the driver's private data
    00945     virtual void * GetDriverShader() const = 0;
    00946 };
    00947
    00948 //-------------------------------------------
    00949 // C exports
    00950 //-------------------------------------------
    00951
    00952 // factory functions
    00953 //a common function for filling in version information about the drivers based on compile date/time
    00954 DEDRIVER_API deBoolean IdeDriver_FillVersionInfo(deDriverInfo *DriverInfo, char *Date, char *Time);
    00955
    00956 DEDRIVER_API IdeDriverLoad* IdeDriverLoad_CreateDriverLoad(char const * path);
    00957
    00958 DEDRIVER_API deBoolean IdeDriver_Initialize();
    00959 DEDRIVER_API long IdeDriver_BPPBitDepth(IdeDriver::BPP BPPType);
    00960 /// Create an instance of IdeVertexBuffer
    00961 DEDRIVER_API IdeVertexBuffer* IdeVertexBuffer_CreateVBuffer();
    00962 /// Create an instance of IdeVertexBuffer, as a sub-vbuffer inside a parent buffer
    00963 /// @param Composite Parent buffer to create this sub-vbuffer inside of
    00964 DEDRIVER_API IdeVertexBuffer* IdeVertexBuffer_CreateSubVBuffer(IdeVertexBuffer * Composite);
    00965 DEDRIVER_API long IdeVertexBuffer_EntrySize(IdeVertexBuffer::BufferType Type);
    00966 DEDRIVER_API IdeVertexBuffer::BufferDataType IdeVertexBuffer_FillBufferDataType(IdeVertexBuffer::BufferType Type, long *Size);
    00967 DEDRIVER_API IdeShader* IdeShader_Create();
    00968
    00969
    00970 #endif