diff --git a/deltabest_plugin/InternalsPlugin.hpp b/deltabest_plugin/InternalsPlugin.hpp new file mode 100644 index 0000000..4ef68fb --- /dev/null +++ b/deltabest_plugin/InternalsPlugin.hpp @@ -0,0 +1,370 @@ +//╔═════════════════════════════════════════════════════════════════════════╗ +//║ ║ +//║ Module: Header file for internals plugin ║ +//║ ║ +//║ Description: Interface declarations for internals plugin ║ +//║ ║ +//║ This source code module, and all information, data, and algorithms ║ +//║ associated with it, are part of isiMotor Technology (tm). ║ +//║ PROPRIETARY AND CONFIDENTIAL ║ +//║ Copyright (c) 1996-2007 Image Space Incorporated. All rights reserved. ║ +//║ ║ +//║ Change history: ║ +//║ tag.2005.11.29: created ║ +//║ ║ +//╚═════════════════════════════════════════════════════════════════════════╝ + +#ifndef _INTERNALS_PLUGIN_HPP_ +#define _INTERNALS_PLUGIN_HPP_ + +#include "RFPluginObjects.hpp" + +// change this variable whenever a change is made to the plugin interfaces +// use m_uVersion (returned by GetVersion() for version control instead //#define INTERNALS_PLUGIN_VERSION (0.0f) + + +//┌────────────────────────────────────────────────────────────────────────┐ +//│ Structs to retrieve internal information (e.g. telemetry info) │ +//└────────────────────────────────────────────────────────────────────────┘ + +struct TelemVect3 +{ + float x, y, z; + + void Set( const float a, const float b, const float c ) { x = a; y = b; z = c; } +}; + + +struct TelemWheel +{ + float mRotation; // radians/sec + float mSuspensionDeflection; // meters + float mRideHeight; // meters + float mTireLoad; // Newtons + float mLateralForce; // Newtons + float mGripFract; // an approximation of what fraction of the contact patch is sliding + float mBrakeTemp; // Celsius + float mPressure; // kPa + float mTemperature[3]; // Celsius, left/center/right (not to be confused with inside/center/outside!) +}; + +struct TelemWheelV2 : public TelemWheel +{ + float mWear; // wear (0.0-1.0, fraction of maximum) ... this is not necessarily proportional with grip loss + char mTerrainName[16]; // the material prefixes from the TDF file + unsigned char mSurfaceType; // 0=dry, 1=wet, 2=grass, 3=dirt, 4=gravel, 5=rumblestrip + bool mFlat; // whether tire is flat + bool mDetached; // whether wheel is detached + + // Future use + unsigned char mExpansion[32]; +}; + + +// Our world coordinate system is left-handed, with +y pointing up. +// The local vehicle coordinate system is as follows: +// +x points out the left side of the car (from the driver's perspective) +// +y points out the roof +// +z points out the back of the car +// Rotations are as follows: +// +x pitches up +// +y yaws to the right +// +z rolls to the right + +struct TelemInfoBase +{ + // Time + float mDeltaTime; // time since last update (seconds) + long mLapNumber; // current lap number + float mLapStartET; // time this lap was started + char mVehicleName[64]; // current vehicle name + char mTrackName[64]; // current track name + + // Position and derivatives + TelemVect3 mPos; // world position in meters + TelemVect3 mLocalVel; // velocity (meters/sec) in local vehicle coordinates + TelemVect3 mLocalAccel; // acceleration (meters/sec^2) in local vehicle coordinates + + // Orientation and derivatives + TelemVect3 mOriX; // top row of orientation matrix (also converts local vehicle vectors into world X using dot product) + TelemVect3 mOriY; // mid row of orientation matrix (also converts local vehicle vectors into world Y using dot product) + TelemVect3 mOriZ; // bot row of orientation matrix (also converts local vehicle vectors into world Z using dot product) + TelemVect3 mLocalRot; // rotation (radians/sec) in local vehicle coordinates + TelemVect3 mLocalRotAccel; // rotational acceleration (radians/sec^2) in local vehicle coordinates + + // Vehicle status + long mGear; // -1=reverse, 0=neutral, 1+=forward gears + float mEngineRPM; // engine RPM + float mEngineWaterTemp; // Celsius + float mEngineOilTemp; // Celsius + float mClutchRPM; // clutch RPM + + // Driver input + float mUnfilteredThrottle; // ranges 0.0-1.0 + float mUnfilteredBrake; // ranges 0.0-1.0 + float mUnfilteredSteering; // ranges -1.0-1.0 (left to right) + float mUnfilteredClutch; // ranges 0.0-1.0 + + // Misc + float mSteeringArmForce; // force on steering arms +}; + +struct TelemInfo : public TelemInfoBase // re-arranged for expansion, but backwards-compatible +{ + TelemWheel mWheel[4]; // wheel info (front left, front right, rear left, rear right) +}; + +struct TelemInfoV2 : public TelemInfoBase // for noobs: TelemInfoV2 contains everything in TelemInfoBase, plus the following: +{ + // state/damage info + float mFuel; // amount of fuel (liters) + float mEngineMaxRPM; // rev limit + unsigned char mScheduledStops; // number of scheduled pitstops + bool mOverheating; // whether overheating icon is shown + bool mDetached; // whether any parts (besides wheels) have been detached + unsigned char mDentSeverity[8];// dent severity at 8 locations around the car (0=none, 1=some, 2=more) + float mLastImpactET; // time of last impact + float mLastImpactMagnitude; // magnitude of last impact + TelemVect3 mLastImpactPos; // location of last impact + + // Future use + unsigned char mExpansion[64]; + + // keeping this at the end of the structure to make it easier to replace in future versions + TelemWheelV2 mWheel[4]; // wheel info (front left, front right, rear left, rear right) +}; + + +struct GraphicsInfo // may be expanded in the future to provide interfaces for drawing onscreen +{ + TelemVect3 mCamPos; // camera position + TelemVect3 mCamOri; // camera orientation + HWND mHWND; // app handle +}; + +struct GraphicsInfoV2 : public GraphicsInfo // for noobs: GraphicsInfoV2 contains everything in GraphicsInfo, plus the following: +{ + float mAmbientRed; + float mAmbientGreen; + float mAmbientBlue; +}; + + +struct VehicleScoringInfo +{ + char mDriverName[32]; // driver name + char mVehicleName[64]; // vehicle name + short mTotalLaps; // laps completed + signed char mSector; // 0=sector3, 1=sector1, 2=sector2 (don't ask why) + signed char mFinishStatus; // 0=none, 1=finished, 2=dnf, 3=dq + float mLapDist; // current distance around track + float mPathLateral; // lateral position with respect to *very approximate* "center" path + float mTrackEdge; // track edge (w.r.t. "center" path) on same side of track as vehicle + + float mBestSector1; // best sector 1 + float mBestSector2; // best sector 2 (plus sector 1) + float mBestLapTime; // best lap time + float mLastSector1; // last sector 1 + float mLastSector2; // last sector 2 (plus sector 1) + float mLastLapTime; // last lap time + float mCurSector1; // current sector 1 if valid + float mCurSector2; // current sector 2 (plus sector 1) if valid + // no current laptime because it instantly becomes "last" + + short mNumPitstops; // number of pitstops made + short mNumPenalties; // number of outstanding penalties +}; + + +struct VehicleScoringInfoV2 : public VehicleScoringInfo // for noobs: VehicleScoringInfoV2 contains everything in VehicleScoringInfo, plus the following: +{ + bool mIsPlayer; // is this the player's vehicle + signed char mControl; // who's in control: -1=nobody (shouldn't get this), 0=local player, 1=local AI, 2=remote, 3=replay (shouldn't get this) + bool mInPits; // between pit entrance and pit exit (not always accurate for remote vehicles) + unsigned char mPlace; // 1-based position + char mVehicleClass[32]; // vehicle class + + // Dash Indicators + float mTimeBehindNext; // time behind vehicle in next higher place + long mLapsBehindNext; // laps behind vehicle in next higher place + float mTimeBehindLeader; // time behind leader + long mLapsBehindLeader; // laps behind leader + float mLapStartET; // time this lap was started + + // Position and derivatives + TelemVect3 mPos; // world position in meters + TelemVect3 mLocalVel; // velocity (meters/sec) in local vehicle coordinates + TelemVect3 mLocalAccel; // acceleration (meters/sec^2) in local vehicle coordinates + + // Orientation and derivatives + TelemVect3 mOriX; // top row of orientation matrix (also converts local vehicle vectors into world X using dot product) + TelemVect3 mOriY; // mid row of orientation matrix (also converts local vehicle vectors into world Y using dot product) + TelemVect3 mOriZ; // bot row of orientation matrix (also converts local vehicle vectors into world Z using dot product) + TelemVect3 mLocalRot; // rotation (radians/sec) in local vehicle coordinates + TelemVect3 mLocalRotAccel; // rotational acceleration (radians/sec^2) in local vehicle coordinates + + // Future use + unsigned char mExpansion[128]; +}; + + +struct ScoringInfoBase +{ + char mTrackName[64]; // current track name + long mSession; // current session + float mCurrentET; // current time + float mEndET; // ending time + long mMaxLaps; // maximum laps + float mLapDist; // distance around track + char *mResultsStream; // results stream additions since last update (newline-delimited and NULL-terminated) + + long mNumVehicles; // current number of vehicles +}; + +struct ScoringInfo : public ScoringInfoBase // re-arranged for expansion, but backwards-compatible +{ + VehicleScoringInfo *mVehicle; // array of vehicle scoring info's +}; + +struct ScoringInfoV2 : public ScoringInfoBase // for noobs: ScoringInfoV2 contains everything in ScoringInfoBase, plus the following: +{ + // Game phases: + // 0 Before session has begun + // 1 Reconnaissance laps (race only) + // 2 Grid walk-through (race only) + // 3 Formation lap (race only) + // 4 Starting-light countdown has begun (race only) + // 5 Green flag + // 6 Full course yellow / safety car + // 7 Session stopped + // 8 Session over + unsigned char mGamePhase; + + // Yellow flag states (applies to full-course only) + // -1 Invalid + // 0 None + // 1 Pending + // 2 Pits closed + // 3 Pit lead lap + // 4 Pits open + // 5 Last lap + // 6 Resume + // 7 Race halt (not currently used) + signed char mYellowFlagState; + + signed char mSectorFlag[3]; // whether there are any local yellows at the moment in each sector (not sure if sector 0 is first or last, so test) + unsigned char mStartLight; // start light frame (number depends on track) + unsigned char mNumRedLights; // number of red lights in start sequence + bool mInRealtime; // in realtime as opposed to at the monitor + char mPlayerName[32]; // player name (including possible multiplayer override) + char mPlrFileName[64]; // may be encoded to be a legal filename + + // weather + float mDarkCloud; // cloud darkness? 0.0-1.0 + float mRaining; // raining severity 0.0-1.0 + float mAmbientTemp; // temperature (Celsius) + float mTrackTemp; // temperature (Celsius) + TelemVect3 mWind; // wind speed + float mOnPathWetness; // on main path 0.0-1.0 + float mOffPathWetness; // on main path 0.0-1.0 + + // Future use + unsigned char mExpansion[256]; + + // keeping this at the end of the structure to make it easier to replace in future versions + VehicleScoringInfoV2 *mVehicle; // array of vehicle scoring info's +}; + + +struct CommentaryRequestInfo +{ + char mName[32]; // one of the event names in the commentary INI file + double mInput1; // first value to pass in (if any) + double mInput2; // first value to pass in (if any) + double mInput3; // first value to pass in (if any) + bool mSkipChecks; // ignores commentary detail and random probability of event + + // constructor (for noobs, this just helps make sure everything is initialized to something reasonable) + CommentaryRequestInfo() { mName[0] = 0; mInput1 = 0.0; mInput2 = 0.0; mInput3 = 0.0; mSkipChecks = false; } +}; + + +//┌────────────────────────────────────────────────────────────────────────┐ +//│ Plugin classes used to access internals │ +//└────────────────────────────────────────────────────────────────────────┘ + +// Note: use class InternalsPlugin for GetVersion()==1, or +// use class InternalsPluginV2 for GetVersion()==2, or +// use class InternalsPluginV3 for GetVersion()==3 +class InternalsPlugin : public PluginObject +{ + public: + + // General internals methods + InternalsPlugin() {} + virtual ~InternalsPlugin() {} + + virtual void Startup() {} // game startup + virtual void Shutdown() {} // game shutdown + + virtual void EnterRealtime() {} // entering realtime (where the vehicle can be driven) + virtual void ExitRealtime() {} // exiting realtime + + // GAME OUTPUT + virtual bool WantsTelemetryUpdates() { return( false ); } // whether we want telemetry updates + virtual void UpdateTelemetry( const TelemInfo &info ) {} // update plugin with telemetry info + + virtual bool WantsGraphicsUpdates() { return( false ); } // whether we want graphics updates + virtual void UpdateGraphics( const GraphicsInfo &info ) {} // update plugin with graphics info + + // GAME INPUT + virtual bool HasHardwareInputs() { return( false ); } // whether plugin has hardware plugins + virtual void UpdateHardware( const float fDT ) {} // update the hardware with the time between frames + virtual void EnableHardware() {} // message from game to enable hardware + virtual void DisableHardware() {} // message from game to disable hardware + + // See if the plugin wants to take over a hardware control. If the plugin takes over the + // control, this method returns true and sets the value of the float pointed to by the + // second arg. Otherwise, it returns false and leaves the float unmodified. + virtual bool CheckHWControl( const char * const controlName, float &fRetVal ) { return false; } + + virtual bool ForceFeedback( float &forceValue ) { return( false ); } // alternate force feedback computation - return true if editing the value +}; + + +class InternalsPluginV2 : public InternalsPlugin // for noobs: InternalsPluginV2 contains everything in InternalsPlugin, plus the following: +{ + public: + + // SCORING OUTPUT + virtual bool WantsScoringUpdates() { return( false ); } // whether we want scoring updates + virtual void UpdateScoring( const ScoringInfo &info ) {} // update plugin with scoring info (approximately once per second) +}; + + +class InternalsPluginV3 : public InternalsPluginV2 // for noobs: InternalsPluginV3 contains everything in InternalsPluginV2 (and InternalsPlugin), plus the following: +{ + public: + + // SESSION NOTIFICATIONS + virtual void StartSession() {} // session started + virtual void EndSession() {} // session ended + + // GAME OUTPUT + virtual void UpdateTelemetry( const TelemInfoV2 &info ) {} // update plugin with telemetry info + + // GRAPHICS OUTPUT + virtual void UpdateGraphics( const GraphicsInfoV2 &info ) {} // update plugin with graphics info + + // SCORING OUTPUT + virtual void UpdateScoring( const ScoringInfoV2 &info ) {} // update plugin with scoring info (approximately once per second) + + // COMMENTARY INPUT + virtual bool RequestCommentary( CommentaryRequestInfo &info ) { return( false ); } // to use our commentary event system, fill in data and return true +}; + +//┌────────────────────────────────────────────────────────────────────────┐ +//└────────────────────────────────────────────────────────────────────────┘ + +#endif // _INTERNALS_PLUGIN_HPP_ + diff --git a/deltabest_plugin/RFPluginObjects.hpp b/deltabest_plugin/RFPluginObjects.hpp new file mode 100644 index 0000000..7e8a56b --- /dev/null +++ b/deltabest_plugin/RFPluginObjects.hpp @@ -0,0 +1,133 @@ +//╔═════════════════════════════════════════════════════════════════════════╗ +//║ ║ +//║ Module: Header file for plugin object types ║ +//║ ║ +//║ Description: interface declarations for plugin objects ║ +//║ ║ +//║ This source code module, and all information, data, and algorithms ║ +//║ associated with it, are part of isiMotor Technology (tm). ║ +//║ PROPRIETARY AND CONFIDENTIAL ║ +//║ Copyright (c) 1996-2007 Image Space Incorporated. All rights reserved. ║ +//║ ║ +//║ Change history: ║ +//║ kc.2004.0?.??: created ║ +//║ mm.2004.05.25: added this description header ║ +//║ mm.2004.05.20: splitting this file up so that each type of plugin ║ +//║ gets its own header file. ║ +//║ ║ +//╚═════════════════════════════════════════════════════════════════════════╝ +#ifndef _PLUGINOBJECT +#define _PLUGINOBJECT + +#include + + +// forward referencing stuff +class PluginObjectInfo; + + +//┌────────────────────────────────────────────────────────────────────────┐ +//│ typedefs for dll functions - easier to use a typedef than to type +//│ out the crazy syntax for declaring and casting function pointers +//└────────────────────────────────────────────────────────────────────────┘ +typedef const char* (__cdecl *GETPLUGINNAME)(); +typedef unsigned (__cdecl *GETPLUGINVERSION)(); +typedef unsigned (__cdecl *GETPLUGINOBJECTCOUNT)(); +typedef PluginObjectInfo* (__cdecl *GETPLUGINOBJECTINFO)(const unsigned uIndex); +typedef PluginObjectInfo* (__cdecl *GETPLUGINOBJECTINFO)(const unsigned uIndex); +typedef float (__cdecl *GETPLUGINSYSTEMVERSION) (); + + +//plugin object types +enum PluginObjectType +{ + PO_VIDEO_EXPORT = 0x00000001, + PO_RFMODIFIER = 0x00000002, + PO_HWPLUGIN = 0x00000003, + PO_GAMESTATS = 0x00000004, + PO_NCPLUGIN = 0x00000005, + PO_MOTION = 0x00000006, + PO_IRCPLUGIN = 0x00000007, + PO_IVIBE = 0x00000008, + PO_INTERNALS = 0x00000009, +}; + + +//┌────────────────────────────────────────────────────────────────────────┐ +//│ Plugin Object Property +//│ - can be used to expose pluginobject settings to rFactor. +//│ In practice this feature has gone almost entirely unused +//└────────────────────────────────────────────────────────────────────────┘ +enum POPType +{ + POPTYPE_INT, + POPTYPE_FLOAT, + POPTYPE_STRING, +}; + +static char POPTypeNames[3][64] = +{ + "POPTYPE_INT", + "POPTYPE_FLOAT", + "POPTYPE_STRING", +}; + +const unsigned POP_MAXNAME = 32; +const unsigned POP_MAXDESC = 256; + +struct PluginObjectProperty +{ + union + { + int iValue; + float fValue; + char* szValue; + }; + + POPType uPropertyType; + char szName[POP_MAXNAME]; + char szDesc[POP_MAXDESC]; +}; + +//┌────────────────────────────────────────────────────────────────────────┐ +//│ PluginObject +//│ - interface used by plugin classes. +//└────────────────────────────────────────────────────────────────────────┘ +class PluginObject +{ +public: + PluginObject() {} + virtual ~PluginObject(){}; + virtual void Destroy()=0; + virtual class PluginObjectInfo* GetInfo()=0; + + virtual unsigned GetPropertyCount() const =0; + virtual PluginObjectProperty* GetProperty(const unsigned uIndex) =0; + virtual PluginObjectProperty* GetProperty(const char* szName) =0; +}; + +//┌────────────────────────────────────────────────────────────────────────┐ +//│ PluginObjectInfo +//│ - interface used by plugin info classes. +//│ the purpose of the plugin info classes is to allow the game to get +//│ information about and instantiate the plugin objects contained in +//│ a dll without needing to know anything about the PO in advance +//└────────────────────────────────────────────────────────────────────────┘ +class PluginObjectInfo +{ +public: + virtual ~PluginObjectInfo() {}; + virtual const char* GetName() const = 0; + virtual const char* GetFullName() const = 0; + virtual const char* GetDesc() const = 0; + virtual const unsigned GetType() const = 0; + virtual const char* GetSubType() const = 0; + virtual const unsigned GetVersion() const = 0; + virtual void* Create() const = 0; +}; + + + + + +#endif \ No newline at end of file diff --git a/deltabest_plugin/SimpleRPMTestPlugin.tga b/deltabest_plugin/SimpleRPMTestPlugin.tga new file mode 100644 index 0000000..3793bee Binary files /dev/null and b/deltabest_plugin/SimpleRPMTestPlugin.tga differ diff --git a/deltabest_plugin/rFplugin.cpp b/deltabest_plugin/rFplugin.cpp new file mode 100644 index 0000000..d7552f3 --- /dev/null +++ b/deltabest_plugin/rFplugin.cpp @@ -0,0 +1,1142 @@ +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include +#include "d3dx9.h" +#include "d3d9.h" + +#include "rFplugin.hpp" // corresponding header file + +// plugin information +unsigned g_uPluginID = 0; +char g_szPluginName[] = "rFactorDeltaBestPlugin"; +unsigned g_uPluginVersion = 001; +unsigned g_uPluginObjectCount = 1; +RenderPluginInfo g_PluginInfo; + +// interface to plugin information +extern "C" __declspec(dllexport) +const char* __cdecl GetPluginName() { return g_szPluginName; } + +extern "C" __declspec(dllexport) +unsigned __cdecl GetPluginVersion() { return g_uPluginVersion; } + +extern "C" __declspec(dllexport) +unsigned __cdecl GetPluginObjectCount() { return g_uPluginObjectCount; } + +// get the plugin-info object used to create the plugin. +extern "C" __declspec(dllexport) +PluginObjectInfo* __cdecl GetPluginObjectInfo( const unsigned uIndex ) +{ + switch(uIndex) + { + case 0: + return &g_PluginInfo; + default: + return 0; + } +} + + +bool in_realtime = false; /* Are we in cockpit? As opposed to monitor */ +bool session_started = false; /* Is a Practice/Race/Q session started or are we in spectator mode, f.ex.? */ +bool lap_was_timed = false; /* If current/last lap that ended was timed or not */ +bool green_flag = false; /* Is the race in green flag condition? */ +bool key_switch = true; /* Enabled/disabled state by keyboard action */ +bool displayed_welcome = false; /* Whether we displayed the "plugin enabled" welcome message */ +bool loaded_best_in_session = false; /* Did we already load the best lap in this session? */ +bool shown_best_in_session = false; /* Did we show a message for the best lap restored from file? */ +bool player_in_pits = false; /* Is the player currently in the pits? */ +unsigned int prev_pos = 0; /* Meters around the track of the current lap (previous interval) */ +unsigned int last_pos = 0; /* Meters around the track of the current lap */ +unsigned int scoring_ticks = 0; /* Advances every time UpdateScoring() is called */ +unsigned int laps_since_realtime = 0; /* Number of laps completed since entering realtime last time */ +double current_delta_best = NULL; /* Current calculated delta best time */ +double prev_delta_best = NULL; +double prev_lap_dist = 0; /* Used to accurately calculate dt and */ +double previous_elapsed_time = 0; /* elpased time of last interval */ +double previous_velocity = 0; /* vehicle velocity of last interval */ +double previous_delta_speed = 0; +double inbtw_scoring_traveled = 0; /* Distance traveled (m) between successive UpdateScoring() calls */ +double inbtw_scoring_elapsed = 0; +long render_ticks = 0; +long render_ticks_int = 2; +char userappdata[FILENAME_MAX]; +// char datapath[FILENAME_MAX] = ""; +char bestlap_dir[FILENAME_MAX] = ""; +char bestlap_filename[FILENAME_MAX] = ""; + +/* Keeps information about last and best laps */ + +struct LapInterval { + int sector; + double elapsed; + double speed; +}; + +struct LapTime { + double final; + double started; + double ended; + double interval_offset; + // double elapsed[MAX_TRACK_LENGTH]; + LapInterval intervals[MAX_TRACK_LENGTH]; +} best_lap, previous_lap, last_lap, optimal_lap, spy_lap; + +struct PluginConfig { + + bool bar_enabled; + unsigned int bar_left; + unsigned int bar_top; + unsigned int bar_width; + unsigned int bar_height; + unsigned int bar_gutter; + + bool time_enabled; + bool hires_updates; + unsigned int time_top; + unsigned int time_width; + unsigned int time_height; + unsigned int time_font_size; + char time_font_name[FONT_NAME_MAXLEN]; + + bool info_enabled; + unsigned int info_left; + unsigned int info_top; + unsigned int info_width; + unsigned int info_height; + unsigned int info_timeout; + + unsigned int keyboard_magic; + unsigned int keyboard_reset; +} config; + +#ifdef ENABLE_LOG +FILE* out_file = NULL; +#endif + +// DirectX 9 objects, to render some text on screen +LPD3DXFONT g_Font = NULL; +D3DXFONT_DESC FontDesc = { + DEFAULT_FONT_SIZE, 0, 400, 0, false, DEFAULT_CHARSET, + OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_PITCH, DEFAULT_FONT_NAME +}; +RECT FontPosition, ShadowPosition; +LPD3DXSPRITE bar = NULL; +LPDIRECT3DTEXTURE9 texture = NULL; + +D3DDEVICE_CREATION_PARAMETERS cparams; +RECT size_rect; + +float SCREEN_WIDTH = 1920; +float SCREEN_HEIGHT = 1080; +float SCREEN_CENTER = SCREEN_WIDTH / 2.0; + + +/* Simple style: negative delta = green, positive delta = red */ +D3DCOLOR TextColor(double delta) +{ + D3DCOLOR text_color = 0xE0000000; /* Alpha (transparency) value */ + bool is_negative = delta < 0; + double cutoff_val = 0.20; + double abs_val = abs(delta); + + text_color |= is_negative + ? (COLOR_INTENSITY << 8) + : (COLOR_INTENSITY << 16); + + /* Blend red or green with white when closer to zero */ + if (abs_val <= cutoff_val) { + unsigned int col_val = int(COLOR_INTENSITY * (1 / cutoff_val) * (cutoff_val - abs_val)); + if (is_negative) + text_color |= (col_val << 16) + col_val; + else + text_color |= (col_val << 8) + col_val; + } + + return text_color; +} + +D3DCOLOR BarColor(double delta, double delta_diff) +{ + static const D3DCOLOR ALPHA = 0xE0000000; + bool is_gaining = delta_diff > 0; + D3DCOLOR bar_color = ALPHA; + bar_color |= is_gaining ? (COLOR_INTENSITY << 16) : (COLOR_INTENSITY << 8); + + double abs_val = abs(delta_diff); + double cutoff_val = 2.5; + + if (abs_val <= cutoff_val) { + unsigned int col_val = int(COLOR_INTENSITY * (1 / cutoff_val) * (cutoff_val - abs_val)); + if (is_gaining) + bar_color |= (col_val << 8) + col_val; + else + bar_color |= (col_val << 16) + col_val; + } + + return bar_color; +} + +// Signal that this plugin wants to get notifications from the D3D9 proxy DLL +extern "C" __declspec(dllexport) +bool __cdecl WantsD3D9Updates( void ) +{ + return true ; +} + +extern "C" __declspec(dllexport) +void __cdecl Init( IDirect3DDevice9 *d3d ) +{ +#ifdef ENABLE_LOG + WriteLog("---INIT DX9---"); +#endif /* ENABLE_LOG */ + + d3d->GetCreationParameters(&cparams); + GetClientRect(cparams.hFocusWindow, &size_rect); + + SCREEN_WIDTH = size_rect.right; + SCREEN_HEIGHT = size_rect.bottom; + SCREEN_CENTER = SCREEN_WIDTH / 2.0; + + LoadConfig(config, CONFIG_FILE, SCREEN_WIDTH, SCREEN_HEIGHT); + + /* Now we know screen X/Y, we can place the text somewhere specific (in height). + If everything is zero then apply our defaults. */ + + if (config.time_width == 0) + config.time_width = SCREEN_WIDTH; + if (config.time_height == 0) + config.time_height = SCREEN_HEIGHT; + if (config.time_top == 0) + config.time_top = SCREEN_HEIGHT / 6.0; + + //config.bar_left = GetPrivateProfileInt("Bar", "Left", 0, ini_file); + //config.bar_top = GetPrivateProfileInt("Bar", "Top", 0, ini_file); + //config.time_top = GetPrivateProfileInt("Time", "Top", 0, ini_file); + + FontDesc.Height = config.time_font_size; + sprintf(FontDesc.FaceName, config.time_font_name); + + D3DXCreateFontIndirect((LPDIRECT3DDEVICE9) d3d, &FontDesc, &g_Font); + assert(g_Font != NULL); + + D3DXCreateTextureFromFile((LPDIRECT3DDEVICE9) d3d, TEXTURE_BACKGROUND, &texture); + D3DXCreateSprite((LPDIRECT3DDEVICE9) d3d, &bar); + + assert(texture != NULL); + assert(bar != NULL); +} + + +// Callback triggered just before the backbuffer is flipped to the front. Original function name: Present() +// Note that this is outside the BeginScene/EndScene block, but it seems to work. +// If you find issues, rename this function to 'EndScene' +extern "C" __declspec(dllexport) +void __cdecl Present( IDirect3DDevice9 *d3d ) +{ + double delta; + double diff; + + RenderPlugin *plugin = RenderPlugin::TheInstance() ; + if ( plugin ) + { + delta = plugin->CalculateDeltaBest(); + diff = plugin->CalculateDeltaSpeed(); + + HRESULT dxStatus = d3d->TestCooperativeLevel(); + + if (dxStatus == D3DERR_DEVICELOST) + { + key_switch = false; + return; + } + + if (dxStatus == D3DERR_DEVICENOTRESET) + { + key_switch = false; + return; + } + + if (dxStatus == D3DERR_DRIVERINTERNALERROR) + { + key_switch = false; + return; + } + + // Are we in the car? Is it time to draw a Delta Bar? + if ( plugin->CanDisplayBar() ) + { + + const float BAR_WIDTH = config.bar_width; + const float BAR_TOP = config.bar_top; + const float BAR_HEIGHT = config.bar_height; + const float BAR_TIME_GUTTER = config.bar_gutter; + const float TIME_WIDTH = config.time_width; + const float TIME_HEIGHT = config.time_height; + + D3DXVECTOR3 delta_pos; + RECT delta_size = { 0, 0, 0, BAR_HEIGHT - 2 }; + + // Provide a default centered position in case user + // disabled drawing of the bar + delta_pos.x = SCREEN_WIDTH / 2.0; + delta_pos.y = BAR_TOP + 1; + delta_pos.z = 0; + delta_size.right = 1; + + // Computed positions, sizes + const float BAR_LEFT = (SCREEN_WIDTH - BAR_WIDTH) / 2.0; + // The -5 "compensates" for font height vs time box height difference + const float TIME_TOP = (BAR_TOP + BAR_HEIGHT + BAR_TIME_GUTTER); + const D3DCOLOR BAR_COLOR = D3DCOLOR_RGBA(0x50, 0x50, 0x50, 0xCC); + + D3DCOLOR bar_grey = BAR_COLOR; + + // if (g_Font == NULL) + // return; + // if (bar == NULL) + // return; + + if(dxStatus == D3D_OK) + { + + bar->Begin(D3DXSPRITE_ALPHABLEND); + + if (config.bar_enabled) { + + D3DXVECTOR3 bar_pos; + bar_pos.x = BAR_LEFT; + bar_pos.y = BAR_TOP; + bar_pos.z = 0; + + RECT bar_rect = { 0, 0, BAR_WIDTH, BAR_HEIGHT }; + + // Draw delta bar + D3DCOLOR delta_bar_color; + + delta_bar_color = BarColor(delta, diff); + delta_pos.x = SCREEN_CENTER; + + // Delta is negative: colored bar is in the right-hand half. + if (delta < 0) { + delta_size.right = (BAR_WIDTH / 2.0) * (-delta / 2.0); + } + + // Delta non-negative, colored bar is in the left-hand half + else if (delta > 0) { + delta_pos.x -= (BAR_WIDTH / 2.0) * (delta / 2.0); + delta_size.right = SCREEN_CENTER - delta_pos.x; + } + + // Don't allow positive (green) bar to start before the -2.0s position + delta_pos.x = max(delta_pos.x, SCREEN_CENTER - (BAR_WIDTH / 2.0)); + + // Max width is always half of bar width (left or right half) + delta_size.right = min(delta_size.right, BAR_WIDTH / 2.0); + + // Min width is 1, as zero doesn't make sense to draw + if (delta_size.right < 1) + delta_size.right = 1; + + if (plugin->CanDisplayData()) + { +#ifdef ENABLE_LOG + // WriteLog("[DRAW] colored-bar at (%.2f, %.2f) width: %.2f height: %.2f\n", delta_pos.x, delta_pos.y, delta_size.right, delta_size.bottom); +#endif /* ENABLE_LOG */ + + bar->Draw(texture, &delta_size, NULL, &delta_pos, delta_bar_color); + } + +#ifdef ENABLE_LOG + // WriteLog("[DRAW] bar at (%.2f, %.2f) width: %.2f height: %.2f\n", bar_pos.x, bar_pos.y, bar_rect.right, bar_rect.bottom); +#endif /* ENABLE_LOG */ + + bar->Draw(texture, &bar_rect, NULL, &bar_pos, bar_grey); + + } + + // Draw the time text ("-0.18") + if (config.time_enabled) { + + D3DCOLOR shadowColor = 0xC0333333; + D3DCOLOR textColor = TextColor(delta); + + char lp_deltaBest[15] = ""; + + float time_rect_center = delta < 0 + ? (delta_pos.x + delta_size.right) + : delta_pos.x; + float left_edge = (SCREEN_WIDTH - BAR_WIDTH) / 2.0; + float right_edge = (SCREEN_WIDTH + BAR_WIDTH) / 2.0; + if (time_rect_center <= left_edge) + time_rect_center = left_edge + 1; + else if (time_rect_center >= right_edge) + time_rect_center = right_edge - 1; + + RECT time_rect = { 0, 0, TIME_WIDTH, TIME_HEIGHT }; + D3DXVECTOR3 time_pos; + time_pos.x = time_rect_center - TIME_WIDTH / 2.0; + time_pos.y = TIME_TOP; + time_pos.z = 0; + time_rect.right = TIME_WIDTH; + +#ifdef ENABLE_LOG + // WriteLog("[DRAW] delta-box at (%.2f, %.2f) width: %d height: %d value: %.2f\n", time_pos.x, time_pos.y, time_rect.right, time_rect.bottom, delta); +#endif /* ENABLE_LOG */ + + if (plugin->CanDisplayData()) + { + FontPosition.left = time_pos.x; + FontPosition.top = time_pos.y - 5; // To vertically align text and box + FontPosition.right = FontPosition.left + TIME_WIDTH; + FontPosition.bottom = FontPosition.top + TIME_HEIGHT + 5; + + ShadowPosition.left = FontPosition.left + 2.5; + ShadowPosition.top = FontPosition.top + 2.5; + ShadowPosition.right = FontPosition.right; + ShadowPosition.bottom = FontPosition.bottom; + + bar->Draw(texture, &time_rect, NULL, &time_pos, bar_grey); + + sprintf(lp_deltaBest, "%+2.2f", delta); + g_Font->DrawText(NULL, (LPCSTR)lp_deltaBest, -1, &FontPosition, DT_CENTER, textColor); + g_Font->DrawText(NULL, (LPCSTR)lp_deltaBest, -1, &ShadowPosition, DT_CENTER, shadowColor); + } + } + + bar->End(); + } + } + } +} + +extern "C" __declspec(dllexport) +void __cdecl Release( IDirect3DDevice9 *d3d ) +{ +#ifdef ENABLE_LOG + WriteLog("---Release DX9---"); +#endif /* ENABLE_LOG */ +} + +void WriteLog(const char * const format, ...) +{ +#ifdef ENABLE_LOG + if (out_file == NULL) + out_file = fopen(LOG_FILE, "a"); + + if (out_file != NULL) + { + char buffer[2048]; + va_list args; + va_start (args, format); + vsnprintf (buffer, sizeof(buffer), format, args); + fprintf(out_file, "%s\n", buffer); + va_end (args); + } +#endif /* ENABLE_LOG */ +} + + + + +// RenderPluginInfo class + +RenderPluginInfo::RenderPluginInfo() +{ + // put together a name for this plugin + sprintf( m_szFullName, "%s - %s", g_szPluginName, RenderPluginInfo::GetName() ); +} + +const char* RenderPluginInfo::GetName() const { return RenderPlugin::GetName(); } +const char* RenderPluginInfo::GetFullName() const { return m_szFullName; } +const char* RenderPluginInfo::GetDesc() const { return "An implementation of delta best display plugin"; } +const unsigned RenderPluginInfo::GetType() const { return RenderPlugin::GetType(); } +const char* RenderPluginInfo::GetSubType() const { return RenderPlugin::GetSubType(); } +const unsigned RenderPluginInfo::GetVersion() const { return RenderPlugin::GetVersion(); } +void* RenderPluginInfo::Create() const { return new RenderPlugin(); } + + +// RenderPlugin class + +const char RenderPlugin::m_szName[] = "rFactorDeltaBestPlugin"; +const char RenderPlugin::m_szSubType[] = "Internals"; +const unsigned RenderPlugin::m_uID = 1; +const unsigned RenderPlugin::m_uVersion = 3; // set to 3 for InternalsPluginV3 functionality and added graphical and vehicle info +RenderPlugin *RenderPlugin::ms_the_instance = NULL ; + +PluginObjectInfo *RenderPlugin::GetInfo() +{ + return &g_PluginInfo; +} + + +RenderPlugin::RenderPlugin() +{ + ms_the_instance = this ; + m_in_real_time = false ; + m_engine_rpm = 0.0 ; +} + +RenderPlugin::~RenderPlugin() +{ + if ( this == ms_the_instance ) + { + ms_the_instance = NULL ; + } +} + + +void RenderPlugin::Startup() +{ + // default HW control enabled to true + mEnabled = true; +#ifdef ENABLE_LOG + if (out_file == NULL) + out_file = fopen(LOG_FILE, "w"); + + WriteLog("--STARTUP--"); +#endif /* ENABLE_LOG */ +} + + +void RenderPlugin::Shutdown() +{ +} + + +void RenderPlugin::StartSession() +{ +#ifdef ENABLE_LOG + WriteLog("--STARTSESSION--"); +#endif /* ENABLE_LOG */ + session_started = true; + loaded_best_in_session = false; + shown_best_in_session = false; + lap_was_timed = false; + player_in_pits = false; + ResetLap(&last_lap); + ResetLap(&best_lap); + ResetLap(&previous_lap); + ResetLap(&optimal_lap); +} + + +void RenderPlugin::EndSession() +{ + mET = 0.0f; + session_started = false; +#ifdef ENABLE_LOG + WriteLog("--ENDSESSION--"); + if (out_file) { + fclose(out_file); + out_file = NULL; + } +#endif /* ENABLE_LOG */ +} + +void RenderPlugin::Load() +{ +#ifdef ENABLE_LOG + WriteLog("--LOAD--"); +#endif /* ENABLE_LOG */ +} + +void LoadConfig(struct PluginConfig &config, const char *ini_file, float SCREEN_WIDTH, float SCREEN_HEIGHT) +{ + + // #define DEFAULT_INFO_WIDTH 80 + // #define DEFAULT_INFO_HEIGHT 40 + // #define DEFAULT_INFO_TOP 430 + // #define DEFAULT_INFO_LEFT 30 + + float default_bar_width = SCREEN_WIDTH * 0.30208333333333333333333333333333; + float default_bar_height = SCREEN_HEIGHT * 0.01851851851851851851851851851852; + float default_bar_top = SCREEN_HEIGHT * 0.12037037037037037037037037037037; + float default_bar_time_gutter = 5; + float default_time_width = SCREEN_WIDTH * 0.06666666666666666666666666666667; + float default_time_height = SCREEN_HEIGHT * 0.03240740740740740740740740740741; + + float default_font_size = SCREEN_HEIGHT * 0.04444444444444444444444444444444; + + // [Bar] section + config.bar_left = GetPrivateProfileInt("Bar", "Left", 0, ini_file); + config.bar_top = GetPrivateProfileInt("Bar", "Top", default_bar_top, ini_file); + config.bar_width = GetPrivateProfileInt("Bar", "Width", default_bar_width, ini_file); + config.bar_height = GetPrivateProfileInt("Bar", "Height", default_bar_height, ini_file); + config.bar_gutter = GetPrivateProfileInt("Bar", "Gutter", default_bar_time_gutter, ini_file); + config.bar_enabled = GetPrivateProfileInt("Bar", "Enabled", 1, ini_file) == 1 ? true : false; + + // [Time] section + config.time_top = GetPrivateProfileInt("Time", "Top", 0, ini_file); + config.time_width = GetPrivateProfileInt("Time", "Width", default_time_width, ini_file); + config.time_height = GetPrivateProfileInt("Time", "Height", default_time_height, ini_file); + config.time_font_size = GetPrivateProfileInt("Time", "FontSize", default_font_size, ini_file); + config.time_enabled = GetPrivateProfileInt("Time", "Enabled", 1, ini_file) == 1 ? true : false; + config.hires_updates = GetPrivateProfileInt("Time", "HiresUpdates", DEFAULT_HIRES_UPDATES, ini_file) == 1 ? true : false; + GetPrivateProfileString("Time", "FontName", DEFAULT_FONT_NAME, config.time_font_name, FONT_NAME_MAXLEN, ini_file); + + // [Keyboard] section + config.keyboard_magic = GetPrivateProfileInt("Keyboard", "MagicKey", DEFAULT_MAGIC_KEY, ini_file); + config.keyboard_reset = GetPrivateProfileInt("Keyboard", "ResetKey", DEFAULT_RESET_KEY, ini_file); +} + +void RenderPlugin::Unload() +{ + if (g_Font != NULL) { + g_Font->Release(); + g_Font = NULL; + } + if (bar != NULL) { + bar->Release(); + bar = NULL; + } + if (texture != NULL) { + texture->Release(); + texture = NULL; + } +#ifdef ENABLE_LOG + WriteLog("--UNLOAD--"); +#endif /* ENABLE_LOG */ +} + + +void RenderPlugin::EnterRealtime() +{ + // start up timer every time we enter realtime + mET = 0.0f; + in_realtime = true; + laps_since_realtime = 0; + +#ifdef ENABLE_LOG + WriteLog("---ENTERREALTIME---"); +#endif /* ENABLE_LOG */ +} + +void RenderPlugin::ExitRealtime() +{ + in_realtime = false; + + /* Reset delta best state */ + last_pos = 0; + prev_lap_dist = 0; + current_delta_best = 0; + prev_delta_best = 0; + +#ifdef ENABLE_LOG + WriteLog("---EXITREALTIME---"); +#endif /* ENABLE_LOG */ +} + +void RenderPlugin::ResetLap(struct LapTime *lap) +{ + if (lap == NULL) + return; + + lap->ended = 0; + lap->final = 0; + lap->started = 0; + lap->interval_offset = 0; + + unsigned int i = 0, n = MAX_TRACK_LENGTH; + for (i = 0; i < n; i++) + { + lap->intervals[i].sector = 0; + lap->intervals[i].elapsed = 0.0; + lap->intervals[i].speed = 0.0; + // lap->elapsed[i] = 0; + } +} + +bool RenderPlugin::CanDisplayBar() +{ + // If we're in the monitor or replay, or no session has started yet, + // no delta best should be displayed + if (! in_realtime) + return false; + + // Option might be disabled by the user (TAB) + if (! key_switch) + return false; + + return true; +} + +bool RenderPlugin::CanDisplayData() +{ + // If we're in the monitor or replay, or no session has started yet, + // no delta best should be displayed + if (! in_realtime) + return false; + + // Option might be disabled by the user (TAB) + if (! key_switch) + return false; + + // If we are in any race/practice phase that's not + // green flag, we don't need or want Delta Best displayed + if (! green_flag) + return false; + + if (player_in_pits) + return false; + + // Don't display anything if current lap isn't timed + if (! lap_was_timed) + return false; + + // We can't display a delta best until we have a best lap recorded + if (! best_lap.final) + return false; + + return true; +} + +void RenderPlugin::UpdateScoring(const ScoringInfoV2 &info) +{ + + /* No scoring updates should take place if we're + in the monitor as opposed to the cockpit mode */ + if (!in_realtime || !session_started) + return; + + /* Toggle shortcut key. Turns off/on the display of delta time */ + if (KEY_DOWN(config.keyboard_magic)) + key_switch = ! key_switch; + + /* Reset the best lap time to none for the session */ + else if (KEY_DOWN(config.keyboard_reset)) { + ResetLap(&previous_lap); + ResetLap(&last_lap); + ResetLap(&best_lap); + ResetLap(&optimal_lap); + } + + /* Update plugin context information, used by NeedToDisplay() */ + green_flag = ((info.mGamePhase == GP_GREEN_FLAG) + || (info.mGamePhase == GP_YELLOW_FLAG) + || (info.mGamePhase == GP_SESSION_OVER)); + + for (long i = 0; i < info.mNumVehicles; ++i) { + VehicleScoringInfoV2 &vinfo = info.mVehicle[i]; + + // Player's car? If not, skip + if ((!vinfo.mIsPlayer) || /*(vinfo.mControl != 0) ||*/ (vinfo.mInPits)) + continue; + + player_in_pits = vinfo.mInPits; + +#ifdef ENABLE_LOG + WriteLog("mLapStartET=%.3f mLastLapTime=%.3f mCurrentET=%.3f Elapsed=%.3f mLapDist=%.3f/%.3f prevLapDist=%.3f prevCurrentET=%.3f deltaBest=%+2.2f lastPos=%d prevPos=%d, speed=%.3f", + vinfo.mLapStartET, + vinfo.mLastLapTime, + info.mCurrentET, + (info.mCurrentET - vinfo.mLapStartET), + vinfo.mLapDist, + info.mLapDist, + prev_lap_dist, + previous_elapsed_time, + current_delta_best, + last_pos, + prev_pos, + magnitude(vinfo.mLocalVel)); +#endif /* ENABLE_LOG */ + + if (! loaded_best_in_session) { +#ifdef ENABLE_LOG + WriteLog("Trying to load best lap for this session"); +#endif + LoadBestLap(&best_lap, info, vinfo); + loaded_best_in_session = true; + } + + /* Check if we started a new lap just now */ + bool new_lap = (vinfo.mLapStartET != last_lap.started); + double curr_lap_dist = vinfo.mLapDist >= 0 ? vinfo.mLapDist : 0; + double time_interval = (info.mCurrentET - previous_elapsed_time); + double velocity_delta = (magnitude(vinfo.mLocalVel) - previous_velocity); + + if (new_lap) { + + /* mLastLapTime is -1 when lap wasn't timed */ + lap_was_timed = ! (vinfo.mLapStartET == 0.0 && vinfo.mLastLapTime == 0.0); + + if (lap_was_timed) { + last_lap.final = vinfo.mLastLapTime; + last_lap.ended = info.mCurrentET; + +#ifdef ENABLE_LOG + WriteLog("New LAP: Last = %.3f, started = %.3f, ended = %.3f interval_offset = %.3f", + last_lap.final, last_lap.started, last_lap.ended, last_lap.interval_offset); +#endif /* ENABLE_LOG */ + + /* Was it the best lap so far? */ + /* .final == -1.0 is the first lap of the session, can't be timed */ + bool valid_timed_lap = last_lap.final > 0.0; + bool best_so_far = valid_timed_lap && ( + (best_lap.final == NULL) + || (best_lap.final != NULL && last_lap.final < best_lap.final)); + + if (best_so_far) { +#ifdef ENABLE_LOG + WriteLog("Last lap was the best so far (final time = %.3f, previous best = %.3f)", last_lap.final, best_lap.final); +#endif /* ENABLE_LOG */ + + /** + * Complete the mileage of the last lap. + * This avoids nasty jumps into empty space (+50.xx) when later comparing with best lap. + */ + unsigned int meters = info.mLapDist; + for (unsigned int i = last_pos + 1 ; i <= (unsigned int) info.mLapDist; i++) { + + // Elapsed time at this position already filled in by UpdateTelemetry()? + // if (last_lap.intervals[i].elapsed > 0.0) + // continue; + + // Linear interpolation of elapsed time in relation to physical position + double interval_fraction = meters == last_pos ? 1.0 : (1.0 * i - last_pos) / (1.0 * info.mLapDist - last_pos); + last_lap.intervals[i].elapsed = previous_elapsed_time + (interval_fraction * time_interval) - vinfo.mLapStartET; + last_lap.intervals[i].speed = previous_velocity + (interval_fraction * velocity_delta); + last_lap.intervals[i].sector = vinfo.mSector; +#ifdef ENABLE_LOG + WriteLog("[DELTAFILL] elapsed[%d] = %.3f, speed[%d] = %.3f (interval_fraction=%.3f)", i, last_lap.intervals[i].elapsed, i, last_lap.intervals[i].speed, interval_fraction); +#endif /* ENABLE_LOG */ + } + + ResetLap(&best_lap); + best_lap = last_lap; + SaveBestLap(&best_lap, info, vinfo); + } + +#ifdef ENABLE_LOG + WriteLog("Best LAP yet = %.3f, started = %.3f, ended = %.3f", + best_lap.final, best_lap.started, best_lap.ended); +#endif /* ENABLE_LOG */ + } + + /* Prepare to archive the new lap */ + ResetLap(&last_lap); + last_lap.started = vinfo.mLapStartET; + last_lap.final = NULL; + last_lap.ended = NULL; + last_lap.interval_offset = info.mCurrentET - vinfo.mLapStartET; + // last_lap.elapsed[0] = 0; + last_pos = prev_pos = 0; + prev_lap_dist = 0; + // Leave previous_elapsed_time alone, or you have hyper-jumps + previous_elapsed_time = info.mCurrentET; + } + + /* If there's a lap in progress, save the delta updates */ + if (last_lap.started > 0.0) { + unsigned int meters = round(vinfo.mLapDist >= 0 ? vinfo.mLapDist : 0); + + /* It could be that we have stopped our vehicle. + In that case (same array position), we want to + overwrite the previous value anyway */ + if (meters >= last_pos) { + double distance_traveled = (vinfo.mLapDist - prev_lap_dist); + if (distance_traveled < 0) + distance_traveled = 0; + + if (meters == last_pos) { + // last_lap.elapsed[meters] = info.mCurrentET - vinfo.mLapStartET; +#ifdef ENABLE_LOG + WriteLog("[DELTA] elapsed[%d] = %.3f [same position]", meters, last_lap.intervals[meters].elapsed); +#endif /* ENABLE_LOG */ + } else { +#ifdef ENABLE_LOG + WriteLog("[DELTA] previous_elapsed_time[%d] = %.3f, time_interval = %.3f, speed = %.3f ", meters, previous_elapsed_time, time_interval, magnitude(vinfo.mLocalVel)); +#endif /* ENABLE_LOG */ + for (unsigned int i = last_pos; i < meters; i++) { + /* Elapsed time at this position already filled in by UpdateTelemetry()? */ + if (last_lap.intervals[i].elapsed > 0.0) + continue; + /* Linear interpolation of elapsed time in relation to physical position */ + double interval_fraction = meters == last_pos ? 1.0 : (1.0 * i - last_pos) / (1.0 * meters - last_pos); + /* Linear interpolation of local velocity in relation to physical position */ + // interval_fraction = meters == last_pos ? 1.0 : (1.0 * i - last_pos) / (1.0 * meters - last_pos); + last_lap.intervals[i].elapsed = /*last_lap.elapsed[i] =*/ previous_elapsed_time + (interval_fraction * time_interval) - vinfo.mLapStartET; + last_lap.intervals[i].speed = previous_velocity + (interval_fraction * velocity_delta); + last_lap.intervals[i].sector = vinfo.mSector; +#ifdef ENABLE_LOG + WriteLog("[DELTAFILL] elapsed[%d] = %.3f, speed[%d] = %.3f (interval_fraction=%.3f)", i, last_lap.intervals[i].elapsed, i, last_lap.intervals[i].speed, interval_fraction); +#endif /* ENABLE_LOG */ + } + // last_lap.elapsed[meters] = info.mCurrentET - vinfo.mLapStartET; + last_lap.intervals[meters].elapsed = info.mCurrentET - vinfo.mLapStartET; + last_lap.intervals[meters].speed = magnitude(vinfo.mLocalVel); + last_lap.intervals[meters].sector = vinfo.mSector; + } + +#ifdef ENABLE_LOG + WriteLog("[DELTA] distance_traveled=%.3f time_interval=%.3f [%d .. %d]", + distance_traveled, time_interval, last_pos, meters); +#endif /* ENABLE_LOG */ + } + + prev_pos = last_pos; + last_pos = meters; + } + + if (curr_lap_dist > prev_lap_dist) + prev_lap_dist = curr_lap_dist; + + previous_elapsed_time = info.mCurrentET; + previous_velocity = magnitude(vinfo.mLocalVel); + + inbtw_scoring_traveled = 0; + inbtw_scoring_elapsed = 0; + } + +} + + +/* We use UpdateTelemetry() to gain notable precision in position updates. +We assume that LocalVelocity is the speed of the +vehicle, which seems to be confirmed by observed data. + +Having forward speed means that with a delta-t we can directly measure +the distance traveled at 15hz instead of 2hz of UpdateScoring(). + +We use this data to complete information on vehicle lap progress +between successive UpdateScoring() calls. + +This behaviour can be disabled by the "HiresUpdates=0" option +in the ini file. + +*/ +void RenderPlugin::UpdateTelemetry( const TelemInfoV2 &info ) +{ + if (! in_realtime) + return; + + if (! config.hires_updates) + return; + + // Have 3D position, lap time and speed, but no lap distance in meters + double dt = info.mDeltaTime; + double forward_speed = magnitude(info.mLocalVel); + + /* Ignore movement in reverse gear + Causes crashes down the line but don't know why :-| */ + if (forward_speed <= 0) + return; + + double distance = forward_speed * dt; + + inbtw_scoring_traveled += distance; + inbtw_scoring_elapsed += dt; + + unsigned int inbtw_pos = round(last_pos + inbtw_scoring_traveled); + if (inbtw_pos > last_pos) { + last_lap.intervals[inbtw_pos].elapsed = last_lap.intervals[last_pos].elapsed + inbtw_scoring_elapsed; + last_lap.intervals[inbtw_pos].speed = forward_speed; +#ifdef ENABLE_LOG + WriteLog("\tNEW inbtw pos=%d elapsed=%.3f (last_pos=%d, t=%.3f, acc_t=%.3f)\n", inbtw_pos, inbtw_scoring_elapsed, last_pos, last_lap.intervals[last_pos].elapsed, last_lap.intervals[inbtw_pos].elapsed); +#endif /* ENABLE_LOG */ + } + +#ifdef ENABLE_LOG + WriteLog("\tdt=%.3f fwd_speed=%.3f dist=%.3f inbtw_scoring_traveled=%.3f last_pos(m)=%d\n", dt, forward_speed, distance, inbtw_scoring_traveled, last_pos); +#endif /* ENABLE_LOG */ +} + + +bool RenderPlugin::RequestCommentary( CommentaryRequestInfo &info ) +{ + // COMMENT OUT TO ENABLE EXAMPLE + return( false ); + + // only if enabled, of course + if( !mEnabled ) + return( false ); + + // Note: function is called twice per second + + strcpy( info.mName, "PlayerLaptime" ); + info.mInput1 = 0.0f; + info.mInput2 = 0.0f; + info.mInput3 = 0.0f; + info.mSkipChecks = true; + mEnabled = false; + return( true ); +} + + +double RenderPlugin::CalculateDeltaBest() +{ + // Shouldn't really happen + if (! best_lap.final) + return 0; + + // Current position in meters around the track + int m = round(last_pos + inbtw_scoring_traveled); + + // By using meters, and backfilling all the missing information, the program can be reasonably close to the position in the best lap + double last_time_at_pos = last_lap.intervals[m].elapsed; + double best_time_at_pos = best_lap.intervals[m].elapsed; + double delta_best = last_time_at_pos - best_time_at_pos; + + if (delta_best > 99.0) + delta_best = 99.0; + else if (delta_best < -99) + delta_best = -99.0; + + return delta_best; +} + +double RenderPlugin::CalculateDeltaSpeed() +{ + // Shouldn't really happen + if (! best_lap.final) + return 0; + + // Current position in meters around the track + int m = round(last_pos + inbtw_scoring_traveled); + + double last_speed_at_pos = last_lap.intervals[m].speed; + double best_speed_at_pos = best_lap.intervals[m].speed; + double delta_speed = best_speed_at_pos - last_speed_at_pos; + + return delta_speed; +} + +bool RenderPlugin::SaveBestLap(const struct LapTime *lap, const ScoringInfoV2 &scoring, const VehicleScoringInfoV2 &veh) +{ + +#ifdef ENABLE_LOG + WriteLog("[SAVE] Saving best lap of %.2f", lap->final); +#endif /* ENABLE_LOG */ + + /* Get file name for the best lap */ + const char *szBestLapFile = GetBestLapFileName(scoring, veh); + if (szBestLapFile == NULL) { + return false; + } + + FILE* fBestLap = fopen(szBestLapFile, "w"); + if (fBestLap) { + //fprintf(fBestLap, "[Elapsed]\n"); + + fprintf(fBestLap, "[LapTime] %f|%f|%f|%f\n", lap->started, lap->ended, lap->interval_offset, lap->final); + + unsigned int i = 0, n = MAX_TRACK_LENGTH; + for (i = 0; i < n; i++) { + /* Occasionally, first few meters of the track + could set elapsed to 0.0, or even negative. */ + + // Don't store meters with no speed data + if (lap->intervals[i].speed <= 0.0) { + break; + } + + fprintf(fBestLap, "%d=S%d|%f|%f\n", i, lap->intervals[i].sector, lap->intervals[i].elapsed, lap->intervals[i].speed); + } + fclose(fBestLap); +#ifdef ENABLE_LOG + WriteLog("[SAVE] Write to file completed '%s'", szBestLapFile); +#endif /* ENABLE_LOG */ + return true; + } + + else { +#ifdef ENABLE_LOG + WriteLog("[SAVE] Couldn't save to file '%s'", szBestLapFile); +#endif /* ENABLE_LOG */ + return false; + } + +} + +void RenderPlugin::LoadBestLap(struct LapTime *lap, const ScoringInfoV2 &scoring, const VehicleScoringInfoV2 &veh) +{ +#ifdef ENABLE_LOG + WriteLog("[LOAD] Loading best lap"); +#endif /* ENABLE_LOG */ + + /* Get file name for the best lap */ + const char *szBestLapFile = GetBestLapFileName(scoring, veh); + if (szBestLapFile == NULL) { + return; + } + + int sector; + double started; + double ended; + double interval_offset; + double final; + double elapsed; + double speed; + + FILE* fBestLap = fopen(szBestLapFile, "r"); + if (fBestLap) { + + ResetLap(lap); + + fscanf(fBestLap, "[LapTime] %lf|%lf|%lf|%lf\n", &started, &ended, &interval_offset, &final); + + lap->started = started; + lap->ended = ended; + lap->interval_offset = interval_offset; + lap->final = final; + + int i = 0; + while (! feof(fBestLap)) { + unsigned int meters = -1; + double elapsed = 0.0; + // fscanf(fBestLap, "%u=%lf\n", &meters, &elapsed); + fscanf(fBestLap, "%d=S%d|%lf|%lf\n", &i, §or, &elapsed, &speed); + + lap->intervals[i].sector = sector; + lap->intervals[i].elapsed = elapsed; + lap->intervals[i].speed = speed; + +#ifdef ENABLE_LOG + WriteLog("[LOAD] read value from file %d=S%d|%f|%f", i, sector, elapsed, speed); +#endif /* ENABLE_LOG */ + } + + fclose(fBestLap); + +#ifdef ENABLE_LOG + WriteLog("[LOAD] Load from file completed"); +#endif /* ENABLE_LOG */ + } + + else { +#ifdef ENABLE_LOG + WriteLog("[LOAD] No file to load or couldn't load from '%s'", szBestLapFile); +#endif /* ENABLE_LOG */ + } +} + +const char * RenderPlugin::GetBestLapFileName(const ScoringInfoV2 &scoring, const VehicleScoringInfoV2 &veh) +{ + sprintf(bestlap_dir, BEST_LAP_DIR, GetUserDataPath()); + + DWORD ftyp = GetFileAttributesA(bestlap_dir); + if (ftyp == INVALID_FILE_ATTRIBUTES) + { + CreateDirectory(bestlap_dir, NULL); + } + + sprintf(bestlap_filename, BEST_LAP_FILE, bestlap_dir, scoring.mTrackName, veh.mVehicleClass); + return bestlap_filename; +} + +const char * RenderPlugin::GetUserDataPath() +{ + char* APPDATA = getenv("APPDATA"); + + sprintf(userappdata, "%s\\%s", APPDATA, DATA_PATH_FILE); + + DWORD ftyp = GetFileAttributesA(userappdata); + if (ftyp == INVALID_FILE_ATTRIBUTES) + { + CreateDirectory (userappdata, NULL); + } + + return userappdata; +} diff --git a/deltabest_plugin/rFplugin.hpp b/deltabest_plugin/rFplugin.hpp new file mode 100644 index 0000000..89af3f5 --- /dev/null +++ b/deltabest_plugin/rFplugin.hpp @@ -0,0 +1,193 @@ +#ifndef RENDERPLUGIN_HPP +#define RENDERPLUGIN_HPP + +#include "InternalsPlugin.hpp" + +#include "InternalsPlugin.hpp" +#include +#include /* for rand() */ +#include /* for sample output */ +#include /* DirectX9 main header */ +#include + +#define PLUGIN_NAME "rF Delta Best" +#define DELTA_BEST_VERSION "v1/Sila" + +#undef ENABLE_LOG /* To enable file logging */ + +#define LOG_FILE "Plugins\\DeltaBest.log" +#define CONFIG_FILE "Plugins\\DeltaBest.ini" +#define TEXTURE_BACKGROUND "Plugins\\DeltaBestBackground.png" + +/* Maximum length of a track in meters */ +#define MAX_TRACK_LENGTH 100000 + +#define DATA_PATH_FILE "DeltaBest" +#define BEST_LAP_DIR "%s\\Laps" +#define BEST_LAP_FILE "%s\\%s_%s.lap" + +/* Game phases -> info.mGamePhase */ +#define GP_GREEN_FLAG 5 +#define GP_YELLOW_FLAG 6 +#define GP_SESSION_OVER 8 + +#define COLOR_INTENSITY 0xF0 + +#define DEFAULT_FONT_SIZE 48 +#define DEFAULT_FONT_NAME "Arial Black" + +#define INFO_FONT_SIZE 24 +#define INFO_FONT_NAME "Arial Black" + +#define DEFAULT_BAR_WIDTH 0 //580 +#define DEFAULT_BAR_HEIGHT 0 //20 +#define DEFAULT_BAR_TOP 0 //130 +#define DEFAULT_BAR_TIME_GUTTER 0 //5 + +#define DEFAULT_INFO_WIDTH 80 +#define DEFAULT_INFO_HEIGHT 40 +#define DEFAULT_INFO_TOP 430 +#define DEFAULT_INFO_LEFT 30 + +#define DEFAULT_TIME_WIDTH 0 //128 +#define DEFAULT_TIME_HEIGHT 35 + +/* Whether to use UpdateTelemetry() to achieve a better precision and + faster updates to the delta time instead of every 0.2s that + UpdateScoring() allows */ +#define DEFAULT_HIRES_UPDATES 0 + + +/* Toggle plugin with CTRL + a magic key. Reference: +http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx */ +#define DEFAULT_MAGIC_KEY (0x44) /* "D" */ +#define DEFAULT_RESET_KEY (0x5A) /* "Z" */ +#define KEY_DOWN(k) ((GetAsyncKeyState(k) & 0x8000) && (GetAsyncKeyState(VK_CONTROL) & 0x8000)) + +#define FONT_NAME_MAXLEN 32 + +#ifdef ENABLE_LOG + void WriteLog(const char * const msg, ...); +#endif /* ENABLE_LOG */ + +void LoadConfig(struct PluginConfig &config, const char *ini_file, float SCREEN_WIDTH, float SCREEN_HEIGHT); + +D3DCOLOR TextColor(double delta); +D3DCOLOR BarColor(double delta, double delta_diff); + +float inline magnitude(TelemVect3 vect) +{ + return sqrt((vect.x * vect.x) + (vect.y * vect.y) + (vect.z * vect.z)); +} + +// This is used for app to find out information about the plugin +class RenderPluginInfo : public PluginObjectInfo +{ +public: + + // Constructor/destructor + RenderPluginInfo(); + ~RenderPluginInfo() {} + + // Derived from base class PluginObjectInfo + virtual const char* GetName() const; + virtual const char* GetFullName() const; + virtual const char* GetDesc() const; + virtual const unsigned GetType() const; + virtual const char* GetSubType() const; + virtual const unsigned GetVersion() const; + virtual void* Create() const; + +private: + + char m_szFullName[128]; +}; + + +// This is used for the app to use the plugin for its intended purpose +class RenderPlugin : public InternalsPluginV3 +{ +protected: + + const static char m_szName[]; + const static char m_szSubType[]; + const static unsigned m_uID; + const static unsigned m_uVersion; + + bool m_in_real_time ; + static RenderPlugin *ms_the_instance ; + float m_engine_rpm ; // factor of 0 to 1 (1=rev limiter) + +public: + + // Constructor/destructor + RenderPlugin(); + ~RenderPlugin(); + + static RenderPlugin *TheInstance(void) { return ms_the_instance ; } + + // Called from class InternalsPluginInfo to return specific information about plugin + static const char * GetName() { return m_szName; } + static const unsigned GetType() { return PO_INTERNALS; } + static const char * GetSubType() { return m_szSubType; } + static const unsigned GetVersion() { return m_uVersion; } + + // Derived from base class PluginObject + void Destroy() { Shutdown(); } // poorly named ... doesn't destroy anything + PluginObjectInfo * GetInfo(); + unsigned GetPropertyCount() const { return 0; } + PluginObjectProperty *GetProperty( const char * ) { return 0; } + PluginObjectProperty *GetProperty( const unsigned ) { return 0; } + + // These are the functions derived from base class InternalsPlugin + // that can be implemented. + void Startup(); // game startup + void Shutdown(); // game shutdown + + void StartSession(); // session has started + void EndSession(); // session has ended + + // WHAT THIS PLUGIN WANTS + virtual bool WantsScoringUpdates() { return( true ); } + virtual void UpdateScoring( const ScoringInfoV2 &info ); + + virtual bool WantsTelemetryUpdates() { return( false ); } + virtual void UpdateTelemetry( const TelemInfoV2 &info ); + + virtual bool RequestCommentary( CommentaryRequestInfo &info ); + + void Load(); // when a new track/car is loaded + void Unload(); // back to the selection screen + + // REAL-TIME DETECTION (when in-car) + virtual void EnterRealtime(); // entering realtime (where the vehicle can be driven) + virtual void ExitRealtime(); // exiting realtime + + // bool inRealTime(void) const { return in_realtime ; } + + double CalculateDeltaBest(); + double CalculateDeltaSpeed(); + bool CanDisplayBar(); + bool CanDisplayData(); + void ResetLap(struct LapTime *lap); + +private: + + // void DrawDeltaBar(const ScreenInfoV01 &info, double delta, double delta_diff); + const char * GetUserDataPath(); + const char * GetBestLapFileName(const ScoringInfoV2 &scoring, const VehicleScoringInfoV2 &veh); + void LoadBestLap(struct LapTime *lap, const ScoringInfoV2 &scoring, const VehicleScoringInfoV2 &veh); + bool SaveBestLap(const struct LapTime *lap, const ScoringInfoV2 &scoring, const VehicleScoringInfoV2 &veh); + + // + // Current status + // + + float mET; /* needed for the hardware example */ + bool mEnabled; /* needed for the hardware example */ + +}; + + +#endif + diff --git a/deltabest_plugin/rFplugin.sln b/deltabest_plugin/rFplugin.sln new file mode 100644 index 0000000..1564682 --- /dev/null +++ b/deltabest_plugin/rFplugin.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual C++ Express 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rFplugin", "rFplugin.vcproj", "{5469D9D1-5419-482B-9618-D1E9656AF375}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5469D9D1-5419-482B-9618-D1E9656AF375}.Debug|Win32.ActiveCfg = Debug|Win32 + {5469D9D1-5419-482B-9618-D1E9656AF375}.Debug|Win32.Build.0 = Debug|Win32 + {5469D9D1-5419-482B-9618-D1E9656AF375}.Release|Win32.ActiveCfg = Release|Win32 + {5469D9D1-5419-482B-9618-D1E9656AF375}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/proxy_dll/credits.txt b/proxy_dll/credits.txt new file mode 100644 index 0000000..fe23368 --- /dev/null +++ b/proxy_dll/credits.txt @@ -0,0 +1 @@ +This is a slightly modified version of Michael Koch's Proxy-Dll (www.mikoweb.eu) diff --git a/proxy_dll/d3d9.h b/proxy_dll/d3d9.h new file mode 100644 index 0000000..4d985e8 --- /dev/null +++ b/proxy_dll/d3d9.h @@ -0,0 +1,1667 @@ +/*==========================================================================; + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: d3d9.h + * Content: Direct3D include file + * + ****************************************************************************/ + +#ifndef _D3D9_H_ +#define _D3D9_H_ + +#ifndef DIRECT3D_VERSION +#define DIRECT3D_VERSION 0x0900 +#endif //DIRECT3D_VERSION + +// include this file content only if compiling for DX9 interfaces +#if(DIRECT3D_VERSION >= 0x0900) + + +/* This identifier is passed to Direct3DCreate9 in order to ensure that an + * application was built against the correct header files. This number is + * incremented whenever a header (or other) change would require applications + * to be rebuilt. If the version doesn't match, Direct3DCreate9 will fail. + * (The number itself has no meaning.)*/ + +#define D3D_SDK_VERSION 31 + + +#include + +#define COM_NO_WINDOWS_H +#include + +#include + +#if !defined(HMONITOR_DECLARED) && (WINVER < 0x0500) + #define HMONITOR_DECLARED + DECLARE_HANDLE(HMONITOR); +#endif + +#define D3DAPI WINAPI + +/* + * Interface IID's + */ +#if defined( _WIN32 ) && !defined( _NO_COM) + +/* IID_IDirect3D9 */ +/* {81BDCBCA-64D4-426d-AE8D-AD0147F4275C} */ +DEFINE_GUID(IID_IDirect3D9, 0x81bdcbca, 0x64d4, 0x426d, 0xae, 0x8d, 0xad, 0x1, 0x47, 0xf4, 0x27, 0x5c); + +/* IID_IDirect3DDevice9 */ +// {D0223B96-BF7A-43fd-92BD-A43B0D82B9EB} */ +DEFINE_GUID(IID_IDirect3DDevice9, 0xd0223b96, 0xbf7a, 0x43fd, 0x92, 0xbd, 0xa4, 0x3b, 0xd, 0x82, 0xb9, 0xeb); + +/* IID_IDirect3DResource9 */ +// {05EEC05D-8F7D-4362-B999-D1BAF357C704} +DEFINE_GUID(IID_IDirect3DResource9, 0x5eec05d, 0x8f7d, 0x4362, 0xb9, 0x99, 0xd1, 0xba, 0xf3, 0x57, 0xc7, 0x4); + +/* IID_IDirect3DBaseTexture9 */ +/* {580CA87E-1D3C-4d54-991D-B7D3E3C298CE} */ +DEFINE_GUID(IID_IDirect3DBaseTexture9, 0x580ca87e, 0x1d3c, 0x4d54, 0x99, 0x1d, 0xb7, 0xd3, 0xe3, 0xc2, 0x98, 0xce); + +/* IID_IDirect3DTexture9 */ +/* {85C31227-3DE5-4f00-9B3A-F11AC38C18B5} */ +DEFINE_GUID(IID_IDirect3DTexture9, 0x85c31227, 0x3de5, 0x4f00, 0x9b, 0x3a, 0xf1, 0x1a, 0xc3, 0x8c, 0x18, 0xb5); + +/* IID_IDirect3DCubeTexture9 */ +/* {FFF32F81-D953-473a-9223-93D652ABA93F} */ +DEFINE_GUID(IID_IDirect3DCubeTexture9, 0xfff32f81, 0xd953, 0x473a, 0x92, 0x23, 0x93, 0xd6, 0x52, 0xab, 0xa9, 0x3f); + +/* IID_IDirect3DVolumeTexture9 */ +/* {2518526C-E789-4111-A7B9-47EF328D13E6} */ +DEFINE_GUID(IID_IDirect3DVolumeTexture9, 0x2518526c, 0xe789, 0x4111, 0xa7, 0xb9, 0x47, 0xef, 0x32, 0x8d, 0x13, 0xe6); + +/* IID_IDirect3DVertexBuffer9 */ +/* {B64BB1B5-FD70-4df6-BF91-19D0A12455E3} */ +DEFINE_GUID(IID_IDirect3DVertexBuffer9, 0xb64bb1b5, 0xfd70, 0x4df6, 0xbf, 0x91, 0x19, 0xd0, 0xa1, 0x24, 0x55, 0xe3); + +/* IID_IDirect3DIndexBuffer9 */ +/* {7C9DD65E-D3F7-4529-ACEE-785830ACDE35} */ +DEFINE_GUID(IID_IDirect3DIndexBuffer9, 0x7c9dd65e, 0xd3f7, 0x4529, 0xac, 0xee, 0x78, 0x58, 0x30, 0xac, 0xde, 0x35); + +/* IID_IDirect3DSurface9 */ +/* {0CFBAF3A-9FF6-429a-99B3-A2796AF8B89B} */ +DEFINE_GUID(IID_IDirect3DSurface9, 0xcfbaf3a, 0x9ff6, 0x429a, 0x99, 0xb3, 0xa2, 0x79, 0x6a, 0xf8, 0xb8, 0x9b); + +/* IID_IDirect3DVolume9 */ +/* {24F416E6-1F67-4aa7-B88E-D33F6F3128A1} */ +DEFINE_GUID(IID_IDirect3DVolume9, 0x24f416e6, 0x1f67, 0x4aa7, 0xb8, 0x8e, 0xd3, 0x3f, 0x6f, 0x31, 0x28, 0xa1); + +/* IID_IDirect3DSwapChain9 */ +/* {794950F2-ADFC-458a-905E-10A10B0B503B} */ +DEFINE_GUID(IID_IDirect3DSwapChain9, 0x794950f2, 0xadfc, 0x458a, 0x90, 0x5e, 0x10, 0xa1, 0xb, 0xb, 0x50, 0x3b); + +/* IID_IDirect3DVertexDeclaration9 */ +/* {DD13C59C-36FA-4098-A8FB-C7ED39DC8546} */ +DEFINE_GUID(IID_IDirect3DVertexDeclaration9, 0xdd13c59c, 0x36fa, 0x4098, 0xa8, 0xfb, 0xc7, 0xed, 0x39, 0xdc, 0x85, 0x46); + +/* IID_IDirect3DVertexShader9 */ +/* {EFC5557E-6265-4613-8A94-43857889EB36} */ +DEFINE_GUID(IID_IDirect3DVertexShader9, 0xefc5557e, 0x6265, 0x4613, 0x8a, 0x94, 0x43, 0x85, 0x78, 0x89, 0xeb, 0x36); + +/* IID_IDirect3DPixelShader9 */ +/* {6D3BDBDC-5B02-4415-B852-CE5E8BCCB289} */ +DEFINE_GUID(IID_IDirect3DPixelShader9, 0x6d3bdbdc, 0x5b02, 0x4415, 0xb8, 0x52, 0xce, 0x5e, 0x8b, 0xcc, 0xb2, 0x89); + +/* IID_IDirect3DStateBlock9 */ +/* {B07C4FE5-310D-4ba8-A23C-4F0F206F218B} */ +DEFINE_GUID(IID_IDirect3DStateBlock9, 0xb07c4fe5, 0x310d, 0x4ba8, 0xa2, 0x3c, 0x4f, 0xf, 0x20, 0x6f, 0x21, 0x8b); + +/* IID_IDirect3DQuery9 */ +/* {d9771460-a695-4f26-bbd3-27b840b541cc} */ +DEFINE_GUID(IID_IDirect3DQuery9, 0xd9771460, 0xa695, 0x4f26, 0xbb, 0xd3, 0x27, 0xb8, 0x40, 0xb5, 0x41, 0xcc); + + +#endif + +#ifdef __cplusplus + +#ifndef DECLSPEC_UUID +#if _MSC_VER >= 1100 +#define DECLSPEC_UUID(x) __declspec(uuid(x)) +#else +#define DECLSPEC_UUID(x) +#endif +#endif + +interface DECLSPEC_UUID("81BDCBCA-64D4-426d-AE8D-AD0147F4275C") IDirect3D9; +interface DECLSPEC_UUID("D0223B96-BF7A-43fd-92BD-A43B0D82B9EB") IDirect3DDevice9; + +interface DECLSPEC_UUID("B07C4FE5-310D-4ba8-A23C-4F0F206F218B") IDirect3DStateBlock9; +interface DECLSPEC_UUID("05EEC05D-8F7D-4362-B999-D1BAF357C704") IDirect3DResource9; +interface DECLSPEC_UUID("DD13C59C-36FA-4098-A8FB-C7ED39DC8546") IDirect3DVertexDeclaration9; +interface DECLSPEC_UUID("EFC5557E-6265-4613-8A94-43857889EB36") IDirect3DVertexShader9; +interface DECLSPEC_UUID("6D3BDBDC-5B02-4415-B852-CE5E8BCCB289") IDirect3DPixelShader9; +interface DECLSPEC_UUID("580CA87E-1D3C-4d54-991D-B7D3E3C298CE") IDirect3DBaseTexture9; +interface DECLSPEC_UUID("85C31227-3DE5-4f00-9B3A-F11AC38C18B5") IDirect3DTexture9; +interface DECLSPEC_UUID("2518526C-E789-4111-A7B9-47EF328D13E6") IDirect3DVolumeTexture9; +interface DECLSPEC_UUID("FFF32F81-D953-473a-9223-93D652ABA93F") IDirect3DCubeTexture9; + +interface DECLSPEC_UUID("B64BB1B5-FD70-4df6-BF91-19D0A12455E3") IDirect3DVertexBuffer9; +interface DECLSPEC_UUID("7C9DD65E-D3F7-4529-ACEE-785830ACDE35") IDirect3DIndexBuffer9; + +interface DECLSPEC_UUID("0CFBAF3A-9FF6-429a-99B3-A2796AF8B89B") IDirect3DSurface9; +interface DECLSPEC_UUID("24F416E6-1F67-4aa7-B88E-D33F6F3128A1") IDirect3DVolume9; + +interface DECLSPEC_UUID("794950F2-ADFC-458a-905E-10A10B0B503B") IDirect3DSwapChain9; +interface DECLSPEC_UUID("d9771460-a695-4f26-bbd3-27b840b541cc") IDirect3DQuery9; + + +#if defined(_COM_SMARTPTR_TYPEDEF) +_COM_SMARTPTR_TYPEDEF(IDirect3D9, __uuidof(IDirect3D9)); +_COM_SMARTPTR_TYPEDEF(IDirect3DDevice9, __uuidof(IDirect3DDevice9)); + +_COM_SMARTPTR_TYPEDEF(IDirect3DStateBlock9, __uuidof(IDirect3DStateBlock9)); +_COM_SMARTPTR_TYPEDEF(IDirect3DResource9, __uuidof(IDirect3DResource9)); +_COM_SMARTPTR_TYPEDEF(IDirect3DVertexDeclaration9, __uuidof(IDirect3DVertexDeclaration9)); +_COM_SMARTPTR_TYPEDEF(IDirect3DVertexShader9, __uuidof(IDirect3DVertexShader9)); +_COM_SMARTPTR_TYPEDEF(IDirect3DPixelShader9, __uuidof(IDirect3DPixelShader9)); +_COM_SMARTPTR_TYPEDEF(IDirect3DBaseTexture9, __uuidof(IDirect3DBaseTexture9)); +_COM_SMARTPTR_TYPEDEF(IDirect3DTexture9, __uuidof(IDirect3DTexture9)); +_COM_SMARTPTR_TYPEDEF(IDirect3DVolumeTexture9, __uuidof(IDirect3DVolumeTexture9)); +_COM_SMARTPTR_TYPEDEF(IDirect3DCubeTexture9, __uuidof(IDirect3DCubeTexture9)); + +_COM_SMARTPTR_TYPEDEF(IDirect3DVertexBuffer9, __uuidof(IDirect3DVertexBuffer9)); +_COM_SMARTPTR_TYPEDEF(IDirect3DIndexBuffer9, __uuidof(IDirect3DIndexBuffer9)); + +_COM_SMARTPTR_TYPEDEF(IDirect3DSurface9, __uuidof(IDirect3DSurface9)); +_COM_SMARTPTR_TYPEDEF(IDirect3DVolume9, __uuidof(IDirect3DVolume9)); + +_COM_SMARTPTR_TYPEDEF(IDirect3DSwapChain9, __uuidof(IDirect3DSwapChain9)); +_COM_SMARTPTR_TYPEDEF(IDirect3DQuery9, __uuidof(IDirect3DQuery9)); + +#endif +#endif + + +typedef interface IDirect3D9 IDirect3D9; +typedef interface IDirect3DDevice9 IDirect3DDevice9; +typedef interface IDirect3DStateBlock9 IDirect3DStateBlock9; +typedef interface IDirect3DVertexDeclaration9 IDirect3DVertexDeclaration9; +typedef interface IDirect3DVertexShader9 IDirect3DVertexShader9; +typedef interface IDirect3DPixelShader9 IDirect3DPixelShader9; +typedef interface IDirect3DResource9 IDirect3DResource9; +typedef interface IDirect3DBaseTexture9 IDirect3DBaseTexture9; +typedef interface IDirect3DTexture9 IDirect3DTexture9; +typedef interface IDirect3DVolumeTexture9 IDirect3DVolumeTexture9; +typedef interface IDirect3DCubeTexture9 IDirect3DCubeTexture9; +typedef interface IDirect3DVertexBuffer9 IDirect3DVertexBuffer9; +typedef interface IDirect3DIndexBuffer9 IDirect3DIndexBuffer9; +typedef interface IDirect3DSurface9 IDirect3DSurface9; +typedef interface IDirect3DVolume9 IDirect3DVolume9; +typedef interface IDirect3DSwapChain9 IDirect3DSwapChain9; +typedef interface IDirect3DQuery9 IDirect3DQuery9; + + +#include "d3d9types.h" +#include "d3d9caps.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * DLL Function for creating a Direct3D9 object. This object supports + * enumeration and allows the creation of Direct3DDevice9 objects. + * Pass the value of the constant D3D_SDK_VERSION to this function, so + * that the run-time can validate that your application was compiled + * against the right headers. + */ + +IDirect3D9 * WINAPI Direct3DCreate9(UINT SDKVersion); + + +/* + * Direct3D interfaces + */ + + + + + +#undef INTERFACE +#define INTERFACE IDirect3D9 + +DECLARE_INTERFACE_(IDirect3D9, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3D9 methods ***/ + STDMETHOD(RegisterSoftwareDevice)(THIS_ void* pInitializeFunction) PURE; + STDMETHOD_(UINT, GetAdapterCount)(THIS) PURE; + STDMETHOD(GetAdapterIdentifier)(THIS_ UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER9* pIdentifier) PURE; + STDMETHOD_(UINT, GetAdapterModeCount)(THIS_ UINT Adapter,D3DFORMAT Format) PURE; + STDMETHOD(EnumAdapterModes)(THIS_ UINT Adapter,D3DFORMAT Format,UINT Mode,D3DDISPLAYMODE* pMode) PURE; + STDMETHOD(GetAdapterDisplayMode)(THIS_ UINT Adapter,D3DDISPLAYMODE* pMode) PURE; + STDMETHOD(CheckDeviceType)(THIS_ UINT iAdapter,D3DDEVTYPE DevType,D3DFORMAT DisplayFormat,D3DFORMAT BackBufferFormat,BOOL bWindowed) PURE; + STDMETHOD(CheckDeviceFormat)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat) PURE; + STDMETHOD(CheckDeviceMultiSampleType)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType,DWORD* pQualityLevels) PURE; + STDMETHOD(CheckDepthStencilMatch)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat) PURE; + STDMETHOD(CheckDeviceFormatConversion)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SourceFormat,D3DFORMAT TargetFormat) PURE; + STDMETHOD(GetDeviceCaps)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS9* pCaps) PURE; + STDMETHOD_(HMONITOR, GetAdapterMonitor)(THIS_ UINT Adapter) PURE; + STDMETHOD(CreateDevice)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface) PURE; +}; + +typedef struct IDirect3D9 *LPDIRECT3D9, *PDIRECT3D9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3D9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3D9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3D9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3D9_RegisterSoftwareDevice(p,a) (p)->lpVtbl->RegisterSoftwareDevice(p,a) +#define IDirect3D9_GetAdapterCount(p) (p)->lpVtbl->GetAdapterCount(p) +#define IDirect3D9_GetAdapterIdentifier(p,a,b,c) (p)->lpVtbl->GetAdapterIdentifier(p,a,b,c) +#define IDirect3D9_GetAdapterModeCount(p,a,b) (p)->lpVtbl->GetAdapterModeCount(p,a,b) +#define IDirect3D9_EnumAdapterModes(p,a,b,c,d) (p)->lpVtbl->EnumAdapterModes(p,a,b,c,d) +#define IDirect3D9_GetAdapterDisplayMode(p,a,b) (p)->lpVtbl->GetAdapterDisplayMode(p,a,b) +#define IDirect3D9_CheckDeviceType(p,a,b,c,d,e) (p)->lpVtbl->CheckDeviceType(p,a,b,c,d,e) +#define IDirect3D9_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->lpVtbl->CheckDeviceFormat(p,a,b,c,d,e,f) +#define IDirect3D9_CheckDeviceMultiSampleType(p,a,b,c,d,e,f) (p)->lpVtbl->CheckDeviceMultiSampleType(p,a,b,c,d,e,f) +#define IDirect3D9_CheckDepthStencilMatch(p,a,b,c,d,e) (p)->lpVtbl->CheckDepthStencilMatch(p,a,b,c,d,e) +#define IDirect3D9_CheckDeviceFormatConversion(p,a,b,c,d) (p)->lpVtbl->CheckDeviceFormatConversion(p,a,b,c,d) +#define IDirect3D9_GetDeviceCaps(p,a,b,c) (p)->lpVtbl->GetDeviceCaps(p,a,b,c) +#define IDirect3D9_GetAdapterMonitor(p,a) (p)->lpVtbl->GetAdapterMonitor(p,a) +#define IDirect3D9_CreateDevice(p,a,b,c,d,e,f) (p)->lpVtbl->CreateDevice(p,a,b,c,d,e,f) +#else +#define IDirect3D9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3D9_AddRef(p) (p)->AddRef() +#define IDirect3D9_Release(p) (p)->Release() +#define IDirect3D9_RegisterSoftwareDevice(p,a) (p)->RegisterSoftwareDevice(a) +#define IDirect3D9_GetAdapterCount(p) (p)->GetAdapterCount() +#define IDirect3D9_GetAdapterIdentifier(p,a,b,c) (p)->GetAdapterIdentifier(a,b,c) +#define IDirect3D9_GetAdapterModeCount(p,a,b) (p)->GetAdapterModeCount(a,b) +#define IDirect3D9_EnumAdapterModes(p,a,b,c,d) (p)->EnumAdapterModes(a,b,c,d) +#define IDirect3D9_GetAdapterDisplayMode(p,a,b) (p)->GetAdapterDisplayMode(a,b) +#define IDirect3D9_CheckDeviceType(p,a,b,c,d,e) (p)->CheckDeviceType(a,b,c,d,e) +#define IDirect3D9_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->CheckDeviceFormat(a,b,c,d,e,f) +#define IDirect3D9_CheckDeviceMultiSampleType(p,a,b,c,d,e,f) (p)->CheckDeviceMultiSampleType(a,b,c,d,e,f) +#define IDirect3D9_CheckDepthStencilMatch(p,a,b,c,d,e) (p)->CheckDepthStencilMatch(a,b,c,d,e) +#define IDirect3D9_CheckDeviceFormatConversion(p,a,b,c,d) (p)->CheckDeviceFormatConversion(a,b,c,d) +#define IDirect3D9_GetDeviceCaps(p,a,b,c) (p)->GetDeviceCaps(a,b,c) +#define IDirect3D9_GetAdapterMonitor(p,a) (p)->GetAdapterMonitor(a) +#define IDirect3D9_CreateDevice(p,a,b,c,d,e,f) (p)->CreateDevice(a,b,c,d,e,f) +#endif + + + + + + + +/* SwapChain */ + + + + + + + + + + + + + + + +#undef INTERFACE +#define INTERFACE IDirect3DDevice9 + +DECLARE_INTERFACE_(IDirect3DDevice9, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DDevice9 methods ***/ + STDMETHOD(TestCooperativeLevel)(THIS) PURE; + STDMETHOD_(UINT, GetAvailableTextureMem)(THIS) PURE; + STDMETHOD(EvictManagedResources)(THIS) PURE; + STDMETHOD(GetDirect3D)(THIS_ IDirect3D9** ppD3D9) PURE; + STDMETHOD(GetDeviceCaps)(THIS_ D3DCAPS9* pCaps) PURE; + STDMETHOD(GetDisplayMode)(THIS_ UINT iSwapChain,D3DDISPLAYMODE* pMode) PURE; + STDMETHOD(GetCreationParameters)(THIS_ D3DDEVICE_CREATION_PARAMETERS *pParameters) PURE; + STDMETHOD(SetCursorProperties)(THIS_ UINT XHotSpot,UINT YHotSpot,IDirect3DSurface9* pCursorBitmap) PURE; + STDMETHOD_(void, SetCursorPosition)(THIS_ int X,int Y,DWORD Flags) PURE; + STDMETHOD_(BOOL, ShowCursor)(THIS_ BOOL bShow) PURE; + STDMETHOD(CreateAdditionalSwapChain)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DSwapChain9** pSwapChain) PURE; + STDMETHOD(GetSwapChain)(THIS_ UINT iSwapChain,IDirect3DSwapChain9** pSwapChain) PURE; + STDMETHOD_(UINT, GetNumberOfSwapChains)(THIS) PURE; + STDMETHOD(Reset)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters) PURE; + STDMETHOD(Present)(THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) PURE; + STDMETHOD(GetBackBuffer)(THIS_ UINT iSwapChain,UINT iBackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface9** ppBackBuffer) PURE; + STDMETHOD(GetRasterStatus)(THIS_ UINT iSwapChain,D3DRASTER_STATUS* pRasterStatus) PURE; + STDMETHOD(SetDialogBoxMode)(THIS_ BOOL bEnableDialogs) PURE; + STDMETHOD_(void, SetGammaRamp)(THIS_ UINT iSwapChain,DWORD Flags,CONST D3DGAMMARAMP* pRamp) PURE; + STDMETHOD_(void, GetGammaRamp)(THIS_ UINT iSwapChain,D3DGAMMARAMP* pRamp) PURE; + STDMETHOD(CreateTexture)(THIS_ UINT Width,UINT Height,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DTexture9** ppTexture,HANDLE* pSharedHandle) PURE; + STDMETHOD(CreateVolumeTexture)(THIS_ UINT Width,UINT Height,UINT Depth,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DVolumeTexture9** ppVolumeTexture,HANDLE* pSharedHandle) PURE; + STDMETHOD(CreateCubeTexture)(THIS_ UINT EdgeLength,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DCubeTexture9** ppCubeTexture,HANDLE* pSharedHandle) PURE; + STDMETHOD(CreateVertexBuffer)(THIS_ UINT Length,DWORD Usage,DWORD FVF,D3DPOOL Pool,IDirect3DVertexBuffer9** ppVertexBuffer,HANDLE* pSharedHandle) PURE; + STDMETHOD(CreateIndexBuffer)(THIS_ UINT Length,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DIndexBuffer9** ppIndexBuffer,HANDLE* pSharedHandle) PURE; + STDMETHOD(CreateRenderTarget)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Lockable,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle) PURE; + STDMETHOD(CreateDepthStencilSurface)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Discard,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle) PURE; + STDMETHOD(UpdateSurface)(THIS_ IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect,IDirect3DSurface9* pDestinationSurface,CONST POINT* pDestPoint) PURE; + STDMETHOD(UpdateTexture)(THIS_ IDirect3DBaseTexture9* pSourceTexture,IDirect3DBaseTexture9* pDestinationTexture) PURE; + STDMETHOD(GetRenderTargetData)(THIS_ IDirect3DSurface9* pRenderTarget,IDirect3DSurface9* pDestSurface) PURE; + STDMETHOD(GetFrontBufferData)(THIS_ UINT iSwapChain,IDirect3DSurface9* pDestSurface) PURE; + STDMETHOD(StretchRect)(THIS_ IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect,IDirect3DSurface9* pDestSurface,CONST RECT* pDestRect,D3DTEXTUREFILTERTYPE Filter) PURE; + STDMETHOD(ColorFill)(THIS_ IDirect3DSurface9* pSurface,CONST RECT* pRect,D3DCOLOR color) PURE; + STDMETHOD(CreateOffscreenPlainSurface)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DPOOL Pool,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle) PURE; + STDMETHOD(SetRenderTarget)(THIS_ DWORD RenderTargetIndex,IDirect3DSurface9* pRenderTarget) PURE; + STDMETHOD(GetRenderTarget)(THIS_ DWORD RenderTargetIndex,IDirect3DSurface9** ppRenderTarget) PURE; + STDMETHOD(SetDepthStencilSurface)(THIS_ IDirect3DSurface9* pNewZStencil) PURE; + STDMETHOD(GetDepthStencilSurface)(THIS_ IDirect3DSurface9** ppZStencilSurface) PURE; + STDMETHOD(BeginScene)(THIS) PURE; + STDMETHOD(EndScene)(THIS) PURE; + STDMETHOD(Clear)(THIS_ DWORD Count,CONST D3DRECT* pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil) PURE; + STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix) PURE; + STDMETHOD(GetTransform)(THIS_ D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix) PURE; + STDMETHOD(MultiplyTransform)(THIS_ D3DTRANSFORMSTATETYPE,CONST D3DMATRIX*) PURE; + STDMETHOD(SetViewport)(THIS_ CONST D3DVIEWPORT9* pViewport) PURE; + STDMETHOD(GetViewport)(THIS_ D3DVIEWPORT9* pViewport) PURE; + STDMETHOD(SetMaterial)(THIS_ CONST D3DMATERIAL9* pMaterial) PURE; + STDMETHOD(GetMaterial)(THIS_ D3DMATERIAL9* pMaterial) PURE; + STDMETHOD(SetLight)(THIS_ DWORD Index,CONST D3DLIGHT9*) PURE; + STDMETHOD(GetLight)(THIS_ DWORD Index,D3DLIGHT9*) PURE; + STDMETHOD(LightEnable)(THIS_ DWORD Index,BOOL Enable) PURE; + STDMETHOD(GetLightEnable)(THIS_ DWORD Index,BOOL* pEnable) PURE; + STDMETHOD(SetClipPlane)(THIS_ DWORD Index,CONST float* pPlane) PURE; + STDMETHOD(GetClipPlane)(THIS_ DWORD Index,float* pPlane) PURE; + STDMETHOD(SetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD Value) PURE; + STDMETHOD(GetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD* pValue) PURE; + STDMETHOD(CreateStateBlock)(THIS_ D3DSTATEBLOCKTYPE Type,IDirect3DStateBlock9** ppSB) PURE; + STDMETHOD(BeginStateBlock)(THIS) PURE; + STDMETHOD(EndStateBlock)(THIS_ IDirect3DStateBlock9** ppSB) PURE; + STDMETHOD(SetClipStatus)(THIS_ CONST D3DCLIPSTATUS9* pClipStatus) PURE; + STDMETHOD(GetClipStatus)(THIS_ D3DCLIPSTATUS9* pClipStatus) PURE; + STDMETHOD(GetTexture)(THIS_ DWORD Stage,IDirect3DBaseTexture9** ppTexture) PURE; + STDMETHOD(SetTexture)(THIS_ DWORD Stage,IDirect3DBaseTexture9* pTexture) PURE; + STDMETHOD(GetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue) PURE; + STDMETHOD(SetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value) PURE; + STDMETHOD(GetSamplerState)(THIS_ DWORD Sampler,D3DSAMPLERSTATETYPE Type,DWORD* pValue) PURE; + STDMETHOD(SetSamplerState)(THIS_ DWORD Sampler,D3DSAMPLERSTATETYPE Type,DWORD Value) PURE; + STDMETHOD(ValidateDevice)(THIS_ DWORD* pNumPasses) PURE; + STDMETHOD(SetPaletteEntries)(THIS_ UINT PaletteNumber,CONST PALETTEENTRY* pEntries) PURE; + STDMETHOD(GetPaletteEntries)(THIS_ UINT PaletteNumber,PALETTEENTRY* pEntries) PURE; + STDMETHOD(SetCurrentTexturePalette)(THIS_ UINT PaletteNumber) PURE; + STDMETHOD(GetCurrentTexturePalette)(THIS_ UINT *PaletteNumber) PURE; + STDMETHOD(SetScissorRect)(THIS_ CONST RECT* pRect) PURE; + STDMETHOD(GetScissorRect)(THIS_ RECT* pRect) PURE; + STDMETHOD(SetSoftwareVertexProcessing)(THIS_ BOOL bSoftware) PURE; + STDMETHOD_(BOOL, GetSoftwareVertexProcessing)(THIS) PURE; + STDMETHOD(SetNPatchMode)(THIS_ float nSegments) PURE; + STDMETHOD_(float, GetNPatchMode)(THIS) PURE; + STDMETHOD(DrawPrimitive)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount) PURE; + STDMETHOD(DrawIndexedPrimitive)(THIS_ D3DPRIMITIVETYPE,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount) PURE; + STDMETHOD(DrawPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE; + STDMETHOD(DrawIndexedPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertices,UINT PrimitiveCount,CONST void* pIndexData,D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE; + STDMETHOD(ProcessVertices)(THIS_ UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer9* pDestBuffer,IDirect3DVertexDeclaration9* pVertexDecl,DWORD Flags) PURE; + STDMETHOD(CreateVertexDeclaration)(THIS_ CONST D3DVERTEXELEMENT9* pVertexElements,IDirect3DVertexDeclaration9** ppDecl) PURE; + STDMETHOD(SetVertexDeclaration)(THIS_ IDirect3DVertexDeclaration9* pDecl) PURE; + STDMETHOD(GetVertexDeclaration)(THIS_ IDirect3DVertexDeclaration9** ppDecl) PURE; + STDMETHOD(SetFVF)(THIS_ DWORD FVF) PURE; + STDMETHOD(GetFVF)(THIS_ DWORD* pFVF) PURE; + STDMETHOD(CreateVertexShader)(THIS_ CONST DWORD* pFunction,IDirect3DVertexShader9** ppShader) PURE; + STDMETHOD(SetVertexShader)(THIS_ IDirect3DVertexShader9* pShader) PURE; + STDMETHOD(GetVertexShader)(THIS_ IDirect3DVertexShader9** ppShader) PURE; + STDMETHOD(SetVertexShaderConstantF)(THIS_ UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount) PURE; + STDMETHOD(GetVertexShaderConstantF)(THIS_ UINT StartRegister,float* pConstantData,UINT Vector4fCount) PURE; + STDMETHOD(SetVertexShaderConstantI)(THIS_ UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount) PURE; + STDMETHOD(GetVertexShaderConstantI)(THIS_ UINT StartRegister,int* pConstantData,UINT Vector4iCount) PURE; + STDMETHOD(SetVertexShaderConstantB)(THIS_ UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount) PURE; + STDMETHOD(GetVertexShaderConstantB)(THIS_ UINT StartRegister,BOOL* pConstantData,UINT BoolCount) PURE; + STDMETHOD(SetStreamSource)(THIS_ UINT StreamNumber,IDirect3DVertexBuffer9* pStreamData,UINT OffsetInBytes,UINT Stride) PURE; + STDMETHOD(GetStreamSource)(THIS_ UINT StreamNumber,IDirect3DVertexBuffer9** ppStreamData,UINT* OffsetInBytes,UINT* pStride) PURE; + STDMETHOD(SetStreamSourceFreq)(THIS_ UINT StreamNumber,UINT Divider) PURE; + STDMETHOD(GetStreamSourceFreq)(THIS_ UINT StreamNumber,UINT* Divider) PURE; + STDMETHOD(SetIndices)(THIS_ IDirect3DIndexBuffer9* pIndexData) PURE; + STDMETHOD(GetIndices)(THIS_ IDirect3DIndexBuffer9** ppIndexData) PURE; + STDMETHOD(CreatePixelShader)(THIS_ CONST DWORD* pFunction,IDirect3DPixelShader9** ppShader) PURE; + STDMETHOD(SetPixelShader)(THIS_ IDirect3DPixelShader9* pShader) PURE; + STDMETHOD(GetPixelShader)(THIS_ IDirect3DPixelShader9** ppShader) PURE; + STDMETHOD(SetPixelShaderConstantF)(THIS_ UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount) PURE; + STDMETHOD(GetPixelShaderConstantF)(THIS_ UINT StartRegister,float* pConstantData,UINT Vector4fCount) PURE; + STDMETHOD(SetPixelShaderConstantI)(THIS_ UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount) PURE; + STDMETHOD(GetPixelShaderConstantI)(THIS_ UINT StartRegister,int* pConstantData,UINT Vector4iCount) PURE; + STDMETHOD(SetPixelShaderConstantB)(THIS_ UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount) PURE; + STDMETHOD(GetPixelShaderConstantB)(THIS_ UINT StartRegister,BOOL* pConstantData,UINT BoolCount) PURE; + STDMETHOD(DrawRectPatch)(THIS_ UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo) PURE; + STDMETHOD(DrawTriPatch)(THIS_ UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo) PURE; + STDMETHOD(DeletePatch)(THIS_ UINT Handle) PURE; + STDMETHOD(CreateQuery)(THIS_ D3DQUERYTYPE Type,IDirect3DQuery9** ppQuery) PURE; +}; + +typedef struct IDirect3DDevice9 *LPDIRECT3DDEVICE9, *PDIRECT3DDEVICE9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DDevice9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DDevice9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DDevice9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DDevice9_TestCooperativeLevel(p) (p)->lpVtbl->TestCooperativeLevel(p) +#define IDirect3DDevice9_GetAvailableTextureMem(p) (p)->lpVtbl->GetAvailableTextureMem(p) +#define IDirect3DDevice9_EvictManagedResources(p) (p)->lpVtbl->EvictManagedResources(p) +#define IDirect3DDevice9_GetDirect3D(p,a) (p)->lpVtbl->GetDirect3D(p,a) +#define IDirect3DDevice9_GetDeviceCaps(p,a) (p)->lpVtbl->GetDeviceCaps(p,a) +#define IDirect3DDevice9_GetDisplayMode(p,a,b) (p)->lpVtbl->GetDisplayMode(p,a,b) +#define IDirect3DDevice9_GetCreationParameters(p,a) (p)->lpVtbl->GetCreationParameters(p,a) +#define IDirect3DDevice9_SetCursorProperties(p,a,b,c) (p)->lpVtbl->SetCursorProperties(p,a,b,c) +#define IDirect3DDevice9_SetCursorPosition(p,a,b,c) (p)->lpVtbl->SetCursorPosition(p,a,b,c) +#define IDirect3DDevice9_ShowCursor(p,a) (p)->lpVtbl->ShowCursor(p,a) +#define IDirect3DDevice9_CreateAdditionalSwapChain(p,a,b) (p)->lpVtbl->CreateAdditionalSwapChain(p,a,b) +#define IDirect3DDevice9_GetSwapChain(p,a,b) (p)->lpVtbl->GetSwapChain(p,a,b) +#define IDirect3DDevice9_GetNumberOfSwapChains(p) (p)->lpVtbl->GetNumberOfSwapChains(p) +#define IDirect3DDevice9_Reset(p,a) (p)->lpVtbl->Reset(p,a) +#define IDirect3DDevice9_Present(p,a,b,c,d) (p)->lpVtbl->Present(p,a,b,c,d) +#define IDirect3DDevice9_GetBackBuffer(p,a,b,c,d) (p)->lpVtbl->GetBackBuffer(p,a,b,c,d) +#define IDirect3DDevice9_GetRasterStatus(p,a,b) (p)->lpVtbl->GetRasterStatus(p,a,b) +#define IDirect3DDevice9_SetDialogBoxMode(p,a) (p)->lpVtbl->SetDialogBoxMode(p,a) +#define IDirect3DDevice9_SetGammaRamp(p,a,b,c) (p)->lpVtbl->SetGammaRamp(p,a,b,c) +#define IDirect3DDevice9_GetGammaRamp(p,a,b) (p)->lpVtbl->GetGammaRamp(p,a,b) +#define IDirect3DDevice9_CreateTexture(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->CreateTexture(p,a,b,c,d,e,f,g,h) +#define IDirect3DDevice9_CreateVolumeTexture(p,a,b,c,d,e,f,g,h,i) (p)->lpVtbl->CreateVolumeTexture(p,a,b,c,d,e,f,g,h,i) +#define IDirect3DDevice9_CreateCubeTexture(p,a,b,c,d,e,f,g) (p)->lpVtbl->CreateCubeTexture(p,a,b,c,d,e,f,g) +#define IDirect3DDevice9_CreateVertexBuffer(p,a,b,c,d,e,f) (p)->lpVtbl->CreateVertexBuffer(p,a,b,c,d,e,f) +#define IDirect3DDevice9_CreateIndexBuffer(p,a,b,c,d,e,f) (p)->lpVtbl->CreateIndexBuffer(p,a,b,c,d,e,f) +#define IDirect3DDevice9_CreateRenderTarget(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->CreateRenderTarget(p,a,b,c,d,e,f,g,h) +#define IDirect3DDevice9_CreateDepthStencilSurface(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->CreateDepthStencilSurface(p,a,b,c,d,e,f,g,h) +#define IDirect3DDevice9_UpdateSurface(p,a,b,c,d) (p)->lpVtbl->UpdateSurface(p,a,b,c,d) +#define IDirect3DDevice9_UpdateTexture(p,a,b) (p)->lpVtbl->UpdateTexture(p,a,b) +#define IDirect3DDevice9_GetRenderTargetData(p,a,b) (p)->lpVtbl->GetRenderTargetData(p,a,b) +#define IDirect3DDevice9_GetFrontBufferData(p,a,b) (p)->lpVtbl->GetFrontBufferData(p,a,b) +#define IDirect3DDevice9_StretchRect(p,a,b,c,d,e) (p)->lpVtbl->StretchRect(p,a,b,c,d,e) +#define IDirect3DDevice9_ColorFill(p,a,b,c) (p)->lpVtbl->ColorFill(p,a,b,c) +#define IDirect3DDevice9_CreateOffscreenPlainSurface(p,a,b,c,d,e,f) (p)->lpVtbl->CreateOffscreenPlainSurface(p,a,b,c,d,e,f) +#define IDirect3DDevice9_SetRenderTarget(p,a,b) (p)->lpVtbl->SetRenderTarget(p,a,b) +#define IDirect3DDevice9_GetRenderTarget(p,a,b) (p)->lpVtbl->GetRenderTarget(p,a,b) +#define IDirect3DDevice9_SetDepthStencilSurface(p,a) (p)->lpVtbl->SetDepthStencilSurface(p,a) +#define IDirect3DDevice9_GetDepthStencilSurface(p,a) (p)->lpVtbl->GetDepthStencilSurface(p,a) +#define IDirect3DDevice9_BeginScene(p) (p)->lpVtbl->BeginScene(p) +#define IDirect3DDevice9_EndScene(p) (p)->lpVtbl->EndScene(p) +#define IDirect3DDevice9_Clear(p,a,b,c,d,e,f) (p)->lpVtbl->Clear(p,a,b,c,d,e,f) +#define IDirect3DDevice9_SetTransform(p,a,b) (p)->lpVtbl->SetTransform(p,a,b) +#define IDirect3DDevice9_GetTransform(p,a,b) (p)->lpVtbl->GetTransform(p,a,b) +#define IDirect3DDevice9_MultiplyTransform(p,a,b) (p)->lpVtbl->MultiplyTransform(p,a,b) +#define IDirect3DDevice9_SetViewport(p,a) (p)->lpVtbl->SetViewport(p,a) +#define IDirect3DDevice9_GetViewport(p,a) (p)->lpVtbl->GetViewport(p,a) +#define IDirect3DDevice9_SetMaterial(p,a) (p)->lpVtbl->SetMaterial(p,a) +#define IDirect3DDevice9_GetMaterial(p,a) (p)->lpVtbl->GetMaterial(p,a) +#define IDirect3DDevice9_SetLight(p,a,b) (p)->lpVtbl->SetLight(p,a,b) +#define IDirect3DDevice9_GetLight(p,a,b) (p)->lpVtbl->GetLight(p,a,b) +#define IDirect3DDevice9_LightEnable(p,a,b) (p)->lpVtbl->LightEnable(p,a,b) +#define IDirect3DDevice9_GetLightEnable(p,a,b) (p)->lpVtbl->GetLightEnable(p,a,b) +#define IDirect3DDevice9_SetClipPlane(p,a,b) (p)->lpVtbl->SetClipPlane(p,a,b) +#define IDirect3DDevice9_GetClipPlane(p,a,b) (p)->lpVtbl->GetClipPlane(p,a,b) +#define IDirect3DDevice9_SetRenderState(p,a,b) (p)->lpVtbl->SetRenderState(p,a,b) +#define IDirect3DDevice9_GetRenderState(p,a,b) (p)->lpVtbl->GetRenderState(p,a,b) +#define IDirect3DDevice9_CreateStateBlock(p,a,b) (p)->lpVtbl->CreateStateBlock(p,a,b) +#define IDirect3DDevice9_BeginStateBlock(p) (p)->lpVtbl->BeginStateBlock(p) +#define IDirect3DDevice9_EndStateBlock(p,a) (p)->lpVtbl->EndStateBlock(p,a) +#define IDirect3DDevice9_SetClipStatus(p,a) (p)->lpVtbl->SetClipStatus(p,a) +#define IDirect3DDevice9_GetClipStatus(p,a) (p)->lpVtbl->GetClipStatus(p,a) +#define IDirect3DDevice9_GetTexture(p,a,b) (p)->lpVtbl->GetTexture(p,a,b) +#define IDirect3DDevice9_SetTexture(p,a,b) (p)->lpVtbl->SetTexture(p,a,b) +#define IDirect3DDevice9_GetTextureStageState(p,a,b,c) (p)->lpVtbl->GetTextureStageState(p,a,b,c) +#define IDirect3DDevice9_SetTextureStageState(p,a,b,c) (p)->lpVtbl->SetTextureStageState(p,a,b,c) +#define IDirect3DDevice9_GetSamplerState(p,a,b,c) (p)->lpVtbl->GetSamplerState(p,a,b,c) +#define IDirect3DDevice9_SetSamplerState(p,a,b,c) (p)->lpVtbl->SetSamplerState(p,a,b,c) +#define IDirect3DDevice9_ValidateDevice(p,a) (p)->lpVtbl->ValidateDevice(p,a) +#define IDirect3DDevice9_SetPaletteEntries(p,a,b) (p)->lpVtbl->SetPaletteEntries(p,a,b) +#define IDirect3DDevice9_GetPaletteEntries(p,a,b) (p)->lpVtbl->GetPaletteEntries(p,a,b) +#define IDirect3DDevice9_SetCurrentTexturePalette(p,a) (p)->lpVtbl->SetCurrentTexturePalette(p,a) +#define IDirect3DDevice9_GetCurrentTexturePalette(p,a) (p)->lpVtbl->GetCurrentTexturePalette(p,a) +#define IDirect3DDevice9_SetScissorRect(p,a) (p)->lpVtbl->SetScissorRect(p,a) +#define IDirect3DDevice9_GetScissorRect(p,a) (p)->lpVtbl->GetScissorRect(p,a) +#define IDirect3DDevice9_SetSoftwareVertexProcessing(p,a) (p)->lpVtbl->SetSoftwareVertexProcessing(p,a) +#define IDirect3DDevice9_GetSoftwareVertexProcessing(p) (p)->lpVtbl->GetSoftwareVertexProcessing(p) +#define IDirect3DDevice9_SetNPatchMode(p,a) (p)->lpVtbl->SetNPatchMode(p,a) +#define IDirect3DDevice9_GetNPatchMode(p) (p)->lpVtbl->GetNPatchMode(p) +#define IDirect3DDevice9_DrawPrimitive(p,a,b,c) (p)->lpVtbl->DrawPrimitive(p,a,b,c) +#define IDirect3DDevice9_DrawIndexedPrimitive(p,a,b,c,d,e,f) (p)->lpVtbl->DrawIndexedPrimitive(p,a,b,c,d,e,f) +#define IDirect3DDevice9_DrawPrimitiveUP(p,a,b,c,d) (p)->lpVtbl->DrawPrimitiveUP(p,a,b,c,d) +#define IDirect3DDevice9_DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) +#define IDirect3DDevice9_ProcessVertices(p,a,b,c,d,e,f) (p)->lpVtbl->ProcessVertices(p,a,b,c,d,e,f) +#define IDirect3DDevice9_CreateVertexDeclaration(p,a,b) (p)->lpVtbl->CreateVertexDeclaration(p,a,b) +#define IDirect3DDevice9_SetVertexDeclaration(p,a) (p)->lpVtbl->SetVertexDeclaration(p,a) +#define IDirect3DDevice9_GetVertexDeclaration(p,a) (p)->lpVtbl->GetVertexDeclaration(p,a) +#define IDirect3DDevice9_SetFVF(p,a) (p)->lpVtbl->SetFVF(p,a) +#define IDirect3DDevice9_GetFVF(p,a) (p)->lpVtbl->GetFVF(p,a) +#define IDirect3DDevice9_CreateVertexShader(p,a,b) (p)->lpVtbl->CreateVertexShader(p,a,b) +#define IDirect3DDevice9_SetVertexShader(p,a) (p)->lpVtbl->SetVertexShader(p,a) +#define IDirect3DDevice9_GetVertexShader(p,a) (p)->lpVtbl->GetVertexShader(p,a) +#define IDirect3DDevice9_SetVertexShaderConstantF(p,a,b,c) (p)->lpVtbl->SetVertexShaderConstantF(p,a,b,c) +#define IDirect3DDevice9_GetVertexShaderConstantF(p,a,b,c) (p)->lpVtbl->GetVertexShaderConstantF(p,a,b,c) +#define IDirect3DDevice9_SetVertexShaderConstantI(p,a,b,c) (p)->lpVtbl->SetVertexShaderConstantI(p,a,b,c) +#define IDirect3DDevice9_GetVertexShaderConstantI(p,a,b,c) (p)->lpVtbl->GetVertexShaderConstantI(p,a,b,c) +#define IDirect3DDevice9_SetVertexShaderConstantB(p,a,b,c) (p)->lpVtbl->SetVertexShaderConstantB(p,a,b,c) +#define IDirect3DDevice9_GetVertexShaderConstantB(p,a,b,c) (p)->lpVtbl->GetVertexShaderConstantB(p,a,b,c) +#define IDirect3DDevice9_SetStreamSource(p,a,b,c,d) (p)->lpVtbl->SetStreamSource(p,a,b,c,d) +#define IDirect3DDevice9_GetStreamSource(p,a,b,c,d) (p)->lpVtbl->GetStreamSource(p,a,b,c,d) +#define IDirect3DDevice9_SetStreamSourceFreq(p,a,b) (p)->lpVtbl->SetStreamSourceFreq(p,a,b) +#define IDirect3DDevice9_GetStreamSourceFreq(p,a,b) (p)->lpVtbl->GetStreamSourceFreq(p,a,b) +#define IDirect3DDevice9_SetIndices(p,a) (p)->lpVtbl->SetIndices(p,a) +#define IDirect3DDevice9_GetIndices(p,a) (p)->lpVtbl->GetIndices(p,a) +#define IDirect3DDevice9_CreatePixelShader(p,a,b) (p)->lpVtbl->CreatePixelShader(p,a,b) +#define IDirect3DDevice9_SetPixelShader(p,a) (p)->lpVtbl->SetPixelShader(p,a) +#define IDirect3DDevice9_GetPixelShader(p,a) (p)->lpVtbl->GetPixelShader(p,a) +#define IDirect3DDevice9_SetPixelShaderConstantF(p,a,b,c) (p)->lpVtbl->SetPixelShaderConstantF(p,a,b,c) +#define IDirect3DDevice9_GetPixelShaderConstantF(p,a,b,c) (p)->lpVtbl->GetPixelShaderConstantF(p,a,b,c) +#define IDirect3DDevice9_SetPixelShaderConstantI(p,a,b,c) (p)->lpVtbl->SetPixelShaderConstantI(p,a,b,c) +#define IDirect3DDevice9_GetPixelShaderConstantI(p,a,b,c) (p)->lpVtbl->GetPixelShaderConstantI(p,a,b,c) +#define IDirect3DDevice9_SetPixelShaderConstantB(p,a,b,c) (p)->lpVtbl->SetPixelShaderConstantB(p,a,b,c) +#define IDirect3DDevice9_GetPixelShaderConstantB(p,a,b,c) (p)->lpVtbl->GetPixelShaderConstantB(p,a,b,c) +#define IDirect3DDevice9_DrawRectPatch(p,a,b,c) (p)->lpVtbl->DrawRectPatch(p,a,b,c) +#define IDirect3DDevice9_DrawTriPatch(p,a,b,c) (p)->lpVtbl->DrawTriPatch(p,a,b,c) +#define IDirect3DDevice9_DeletePatch(p,a) (p)->lpVtbl->DeletePatch(p,a) +#define IDirect3DDevice9_CreateQuery(p,a,b) (p)->lpVtbl->CreateQuery(p,a,b) +#else +#define IDirect3DDevice9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DDevice9_AddRef(p) (p)->AddRef() +#define IDirect3DDevice9_Release(p) (p)->Release() +#define IDirect3DDevice9_TestCooperativeLevel(p) (p)->TestCooperativeLevel() +#define IDirect3DDevice9_GetAvailableTextureMem(p) (p)->GetAvailableTextureMem() +#define IDirect3DDevice9_EvictManagedResources(p) (p)->EvictManagedResources() +#define IDirect3DDevice9_GetDirect3D(p,a) (p)->GetDirect3D(a) +#define IDirect3DDevice9_GetDeviceCaps(p,a) (p)->GetDeviceCaps(a) +#define IDirect3DDevice9_GetDisplayMode(p,a,b) (p)->GetDisplayMode(a,b) +#define IDirect3DDevice9_GetCreationParameters(p,a) (p)->GetCreationParameters(a) +#define IDirect3DDevice9_SetCursorProperties(p,a,b,c) (p)->SetCursorProperties(a,b,c) +#define IDirect3DDevice9_SetCursorPosition(p,a,b,c) (p)->SetCursorPosition(a,b,c) +#define IDirect3DDevice9_ShowCursor(p,a) (p)->ShowCursor(a) +#define IDirect3DDevice9_CreateAdditionalSwapChain(p,a,b) (p)->CreateAdditionalSwapChain(a,b) +#define IDirect3DDevice9_GetSwapChain(p,a,b) (p)->GetSwapChain(a,b) +#define IDirect3DDevice9_GetNumberOfSwapChains(p) (p)->GetNumberOfSwapChains() +#define IDirect3DDevice9_Reset(p,a) (p)->Reset(a) +#define IDirect3DDevice9_Present(p,a,b,c,d) (p)->Present(a,b,c,d) +#define IDirect3DDevice9_GetBackBuffer(p,a,b,c,d) (p)->GetBackBuffer(a,b,c,d) +#define IDirect3DDevice9_GetRasterStatus(p,a,b) (p)->GetRasterStatus(a,b) +#define IDirect3DDevice9_SetDialogBoxMode(p,a) (p)->SetDialogBoxMode(a) +#define IDirect3DDevice9_SetGammaRamp(p,a,b,c) (p)->SetGammaRamp(a,b,c) +#define IDirect3DDevice9_GetGammaRamp(p,a,b) (p)->GetGammaRamp(a,b) +#define IDirect3DDevice9_CreateTexture(p,a,b,c,d,e,f,g,h) (p)->CreateTexture(a,b,c,d,e,f,g,h) +#define IDirect3DDevice9_CreateVolumeTexture(p,a,b,c,d,e,f,g,h,i) (p)->CreateVolumeTexture(a,b,c,d,e,f,g,h,i) +#define IDirect3DDevice9_CreateCubeTexture(p,a,b,c,d,e,f,g) (p)->CreateCubeTexture(a,b,c,d,e,f,g) +#define IDirect3DDevice9_CreateVertexBuffer(p,a,b,c,d,e,f) (p)->CreateVertexBuffer(a,b,c,d,e,f) +#define IDirect3DDevice9_CreateIndexBuffer(p,a,b,c,d,e,f) (p)->CreateIndexBuffer(a,b,c,d,e,f) +#define IDirect3DDevice9_CreateRenderTarget(p,a,b,c,d,e,f,g,h) (p)->CreateRenderTarget(a,b,c,d,e,f,g,h) +#define IDirect3DDevice9_CreateDepthStencilSurface(p,a,b,c,d,e,f,g,h) (p)->CreateDepthStencilSurface(a,b,c,d,e,f,g,h) +#define IDirect3DDevice9_UpdateSurface(p,a,b,c,d) (p)->UpdateSurface(a,b,c,d) +#define IDirect3DDevice9_UpdateTexture(p,a,b) (p)->UpdateTexture(a,b) +#define IDirect3DDevice9_GetRenderTargetData(p,a,b) (p)->GetRenderTargetData(a,b) +#define IDirect3DDevice9_GetFrontBufferData(p,a,b) (p)->GetFrontBufferData(a,b) +#define IDirect3DDevice9_StretchRect(p,a,b,c,d,e) (p)->StretchRect(a,b,c,d,e) +#define IDirect3DDevice9_ColorFill(p,a,b,c) (p)->ColorFill(a,b,c) +#define IDirect3DDevice9_CreateOffscreenPlainSurface(p,a,b,c,d,e,f) (p)->CreateOffscreenPlainSurface(a,b,c,d,e,f) +#define IDirect3DDevice9_SetRenderTarget(p,a,b) (p)->SetRenderTarget(a,b) +#define IDirect3DDevice9_GetRenderTarget(p,a,b) (p)->GetRenderTarget(a,b) +#define IDirect3DDevice9_SetDepthStencilSurface(p,a) (p)->SetDepthStencilSurface(a) +#define IDirect3DDevice9_GetDepthStencilSurface(p,a) (p)->GetDepthStencilSurface(a) +#define IDirect3DDevice9_BeginScene(p) (p)->BeginScene() +#define IDirect3DDevice9_EndScene(p) (p)->EndScene() +#define IDirect3DDevice9_Clear(p,a,b,c,d,e,f) (p)->Clear(a,b,c,d,e,f) +#define IDirect3DDevice9_SetTransform(p,a,b) (p)->SetTransform(a,b) +#define IDirect3DDevice9_GetTransform(p,a,b) (p)->GetTransform(a,b) +#define IDirect3DDevice9_MultiplyTransform(p,a,b) (p)->MultiplyTransform(a,b) +#define IDirect3DDevice9_SetViewport(p,a) (p)->SetViewport(a) +#define IDirect3DDevice9_GetViewport(p,a) (p)->GetViewport(a) +#define IDirect3DDevice9_SetMaterial(p,a) (p)->SetMaterial(a) +#define IDirect3DDevice9_GetMaterial(p,a) (p)->GetMaterial(a) +#define IDirect3DDevice9_SetLight(p,a,b) (p)->SetLight(a,b) +#define IDirect3DDevice9_GetLight(p,a,b) (p)->GetLight(a,b) +#define IDirect3DDevice9_LightEnable(p,a,b) (p)->LightEnable(a,b) +#define IDirect3DDevice9_GetLightEnable(p,a,b) (p)->GetLightEnable(a,b) +#define IDirect3DDevice9_SetClipPlane(p,a,b) (p)->SetClipPlane(a,b) +#define IDirect3DDevice9_GetClipPlane(p,a,b) (p)->GetClipPlane(a,b) +#define IDirect3DDevice9_SetRenderState(p,a,b) (p)->SetRenderState(a,b) +#define IDirect3DDevice9_GetRenderState(p,a,b) (p)->GetRenderState(a,b) +#define IDirect3DDevice9_CreateStateBlock(p,a,b) (p)->CreateStateBlock(a,b) +#define IDirect3DDevice9_BeginStateBlock(p) (p)->BeginStateBlock() +#define IDirect3DDevice9_EndStateBlock(p,a) (p)->EndStateBlock(a) +#define IDirect3DDevice9_SetClipStatus(p,a) (p)->SetClipStatus(a) +#define IDirect3DDevice9_GetClipStatus(p,a) (p)->GetClipStatus(a) +#define IDirect3DDevice9_GetTexture(p,a,b) (p)->GetTexture(a,b) +#define IDirect3DDevice9_SetTexture(p,a,b) (p)->SetTexture(a,b) +#define IDirect3DDevice9_GetTextureStageState(p,a,b,c) (p)->GetTextureStageState(a,b,c) +#define IDirect3DDevice9_SetTextureStageState(p,a,b,c) (p)->SetTextureStageState(a,b,c) +#define IDirect3DDevice9_GetSamplerState(p,a,b,c) (p)->GetSamplerState(a,b,c) +#define IDirect3DDevice9_SetSamplerState(p,a,b,c) (p)->SetSamplerState(a,b,c) +#define IDirect3DDevice9_ValidateDevice(p,a) (p)->ValidateDevice(a) +#define IDirect3DDevice9_SetPaletteEntries(p,a,b) (p)->SetPaletteEntries(a,b) +#define IDirect3DDevice9_GetPaletteEntries(p,a,b) (p)->GetPaletteEntries(a,b) +#define IDirect3DDevice9_SetCurrentTexturePalette(p,a) (p)->SetCurrentTexturePalette(a) +#define IDirect3DDevice9_GetCurrentTexturePalette(p,a) (p)->GetCurrentTexturePalette(a) +#define IDirect3DDevice9_SetScissorRect(p,a) (p)->SetScissorRect(a) +#define IDirect3DDevice9_GetScissorRect(p,a) (p)->GetScissorRect(a) +#define IDirect3DDevice9_SetSoftwareVertexProcessing(p,a) (p)->SetSoftwareVertexProcessing(a) +#define IDirect3DDevice9_GetSoftwareVertexProcessing(p) (p)->GetSoftwareVertexProcessing() +#define IDirect3DDevice9_SetNPatchMode(p,a) (p)->SetNPatchMode(a) +#define IDirect3DDevice9_GetNPatchMode(p) (p)->GetNPatchMode() +#define IDirect3DDevice9_DrawPrimitive(p,a,b,c) (p)->DrawPrimitive(a,b,c) +#define IDirect3DDevice9_DrawIndexedPrimitive(p,a,b,c,d,e,f) (p)->DrawIndexedPrimitive(a,b,c,d,e,f) +#define IDirect3DDevice9_DrawPrimitiveUP(p,a,b,c,d) (p)->DrawPrimitiveUP(a,b,c,d) +#define IDirect3DDevice9_DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) (p)->DrawIndexedPrimitiveUP(a,b,c,d,e,f,g,h) +#define IDirect3DDevice9_ProcessVertices(p,a,b,c,d,e,f) (p)->ProcessVertices(a,b,c,d,e,f) +#define IDirect3DDevice9_CreateVertexDeclaration(p,a,b) (p)->CreateVertexDeclaration(a,b) +#define IDirect3DDevice9_SetVertexDeclaration(p,a) (p)->SetVertexDeclaration(a) +#define IDirect3DDevice9_GetVertexDeclaration(p,a) (p)->GetVertexDeclaration(a) +#define IDirect3DDevice9_SetFVF(p,a) (p)->SetFVF(a) +#define IDirect3DDevice9_GetFVF(p,a) (p)->GetFVF(a) +#define IDirect3DDevice9_CreateVertexShader(p,a,b) (p)->CreateVertexShader(a,b) +#define IDirect3DDevice9_SetVertexShader(p,a) (p)->SetVertexShader(a) +#define IDirect3DDevice9_GetVertexShader(p,a) (p)->GetVertexShader(a) +#define IDirect3DDevice9_SetVertexShaderConstantF(p,a,b,c) (p)->SetVertexShaderConstantF(a,b,c) +#define IDirect3DDevice9_GetVertexShaderConstantF(p,a,b,c) (p)->GetVertexShaderConstantF(a,b,c) +#define IDirect3DDevice9_SetVertexShaderConstantI(p,a,b,c) (p)->SetVertexShaderConstantI(a,b,c) +#define IDirect3DDevice9_GetVertexShaderConstantI(p,a,b,c) (p)->GetVertexShaderConstantI(a,b,c) +#define IDirect3DDevice9_SetVertexShaderConstantB(p,a,b,c) (p)->SetVertexShaderConstantB(a,b,c) +#define IDirect3DDevice9_GetVertexShaderConstantB(p,a,b,c) (p)->GetVertexShaderConstantB(a,b,c) +#define IDirect3DDevice9_SetStreamSource(p,a,b,c,d) (p)->SetStreamSource(a,b,c,d) +#define IDirect3DDevice9_GetStreamSource(p,a,b,c,d) (p)->GetStreamSource(a,b,c,d) +#define IDirect3DDevice9_SetStreamSourceFreq(p,a,b) (p)->SetStreamSourceFreq(a,b) +#define IDirect3DDevice9_GetStreamSourceFreq(p,a,b) (p)->GetStreamSourceFreq(a,b) +#define IDirect3DDevice9_SetIndices(p,a) (p)->SetIndices(a) +#define IDirect3DDevice9_GetIndices(p,a) (p)->GetIndices(a) +#define IDirect3DDevice9_CreatePixelShader(p,a,b) (p)->CreatePixelShader(a,b) +#define IDirect3DDevice9_SetPixelShader(p,a) (p)->SetPixelShader(a) +#define IDirect3DDevice9_GetPixelShader(p,a) (p)->GetPixelShader(a) +#define IDirect3DDevice9_SetPixelShaderConstantF(p,a,b,c) (p)->SetPixelShaderConstantF(a,b,c) +#define IDirect3DDevice9_GetPixelShaderConstantF(p,a,b,c) (p)->GetPixelShaderConstantF(a,b,c) +#define IDirect3DDevice9_SetPixelShaderConstantI(p,a,b,c) (p)->SetPixelShaderConstantI(a,b,c) +#define IDirect3DDevice9_GetPixelShaderConstantI(p,a,b,c) (p)->GetPixelShaderConstantI(a,b,c) +#define IDirect3DDevice9_SetPixelShaderConstantB(p,a,b,c) (p)->SetPixelShaderConstantB(a,b,c) +#define IDirect3DDevice9_GetPixelShaderConstantB(p,a,b,c) (p)->GetPixelShaderConstantB(a,b,c) +#define IDirect3DDevice9_DrawRectPatch(p,a,b,c) (p)->DrawRectPatch(a,b,c) +#define IDirect3DDevice9_DrawTriPatch(p,a,b,c) (p)->DrawTriPatch(a,b,c) +#define IDirect3DDevice9_DeletePatch(p,a) (p)->DeletePatch(a) +#define IDirect3DDevice9_CreateQuery(p,a,b) (p)->CreateQuery(a,b) +#endif + + +#undef INTERFACE +#define INTERFACE IDirect3DStateBlock9 + +DECLARE_INTERFACE_(IDirect3DStateBlock9, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DStateBlock9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(Capture)(THIS) PURE; + STDMETHOD(Apply)(THIS) PURE; +}; + +typedef struct IDirect3DStateBlock9 *LPDIRECT3DSTATEBLOCK9, *PDIRECT3DSTATEBLOCK9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DStateBlock9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DStateBlock9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DStateBlock9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DStateBlock9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DStateBlock9_Capture(p) (p)->lpVtbl->Capture(p) +#define IDirect3DStateBlock9_Apply(p) (p)->lpVtbl->Apply(p) +#else +#define IDirect3DStateBlock9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DStateBlock9_AddRef(p) (p)->AddRef() +#define IDirect3DStateBlock9_Release(p) (p)->Release() +#define IDirect3DStateBlock9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DStateBlock9_Capture(p) (p)->Capture() +#define IDirect3DStateBlock9_Apply(p) (p)->Apply() +#endif + + + +#undef INTERFACE +#define INTERFACE IDirect3DSwapChain9 + +DECLARE_INTERFACE_(IDirect3DSwapChain9, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DSwapChain9 methods ***/ + STDMETHOD(Present)(THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion,DWORD dwFlags) PURE; + STDMETHOD(GetFrontBufferData)(THIS_ IDirect3DSurface9* pDestSurface) PURE; + STDMETHOD(GetBackBuffer)(THIS_ UINT iBackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface9** ppBackBuffer) PURE; + STDMETHOD(GetRasterStatus)(THIS_ D3DRASTER_STATUS* pRasterStatus) PURE; + STDMETHOD(GetDisplayMode)(THIS_ D3DDISPLAYMODE* pMode) PURE; + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(GetPresentParameters)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters) PURE; +}; + +typedef struct IDirect3DSwapChain9 *LPDIRECT3DSWAPCHAIN9, *PDIRECT3DSWAPCHAIN9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DSwapChain9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DSwapChain9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DSwapChain9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DSwapChain9_Present(p,a,b,c,d,e) (p)->lpVtbl->Present(p,a,b,c,d,e) +#define IDirect3DSwapChain9_GetFrontBufferData(p,a) (p)->lpVtbl->GetFrontBufferData(p,a) +#define IDirect3DSwapChain9_GetBackBuffer(p,a,b,c) (p)->lpVtbl->GetBackBuffer(p,a,b,c) +#define IDirect3DSwapChain9_GetRasterStatus(p,a) (p)->lpVtbl->GetRasterStatus(p,a) +#define IDirect3DSwapChain9_GetDisplayMode(p,a) (p)->lpVtbl->GetDisplayMode(p,a) +#define IDirect3DSwapChain9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DSwapChain9_GetPresentParameters(p,a) (p)->lpVtbl->GetPresentParameters(p,a) +#else +#define IDirect3DSwapChain9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DSwapChain9_AddRef(p) (p)->AddRef() +#define IDirect3DSwapChain9_Release(p) (p)->Release() +#define IDirect3DSwapChain9_Present(p,a,b,c,d,e) (p)->Present(a,b,c,d,e) +#define IDirect3DSwapChain9_GetFrontBufferData(p,a) (p)->GetFrontBufferData(a) +#define IDirect3DSwapChain9_GetBackBuffer(p,a,b,c) (p)->GetBackBuffer(a,b,c) +#define IDirect3DSwapChain9_GetRasterStatus(p,a) (p)->GetRasterStatus(a) +#define IDirect3DSwapChain9_GetDisplayMode(p,a) (p)->GetDisplayMode(a) +#define IDirect3DSwapChain9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DSwapChain9_GetPresentParameters(p,a) (p)->GetPresentParameters(a) +#endif + + + +#undef INTERFACE +#define INTERFACE IDirect3DResource9 + +DECLARE_INTERFACE_(IDirect3DResource9, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; +}; + +typedef struct IDirect3DResource9 *LPDIRECT3DRESOURCE9, *PDIRECT3DRESOURCE9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DResource9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DResource9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DResource9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DResource9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DResource9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DResource9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DResource9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DResource9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DResource9_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DResource9_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DResource9_GetType(p) (p)->lpVtbl->GetType(p) +#else +#define IDirect3DResource9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DResource9_AddRef(p) (p)->AddRef() +#define IDirect3DResource9_Release(p) (p)->Release() +#define IDirect3DResource9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DResource9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DResource9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DResource9_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DResource9_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DResource9_GetPriority(p) (p)->GetPriority() +#define IDirect3DResource9_PreLoad(p) (p)->PreLoad() +#define IDirect3DResource9_GetType(p) (p)->GetType() +#endif + + + +#undef INTERFACE +#define INTERFACE IDirect3DVertexDeclaration9 + +DECLARE_INTERFACE_(IDirect3DVertexDeclaration9, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DVertexDeclaration9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9*,UINT* pNumElements) PURE; +}; + +typedef struct IDirect3DVertexDeclaration9 *LPDIRECT3DVERTEXDECLARATION9, *PDIRECT3DVERTEXDECLARATION9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DVertexDeclaration9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DVertexDeclaration9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DVertexDeclaration9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DVertexDeclaration9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DVertexDeclaration9_GetDeclaration(p,a,b) (p)->lpVtbl->GetDeclaration(p,a,b) +#else +#define IDirect3DVertexDeclaration9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DVertexDeclaration9_AddRef(p) (p)->AddRef() +#define IDirect3DVertexDeclaration9_Release(p) (p)->Release() +#define IDirect3DVertexDeclaration9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DVertexDeclaration9_GetDeclaration(p,a,b) (p)->GetDeclaration(a,b) +#endif + + + +#undef INTERFACE +#define INTERFACE IDirect3DVertexShader9 + +DECLARE_INTERFACE_(IDirect3DVertexShader9, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DVertexShader9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(GetFunction)(THIS_ void*,UINT* pSizeOfData) PURE; +}; + +typedef struct IDirect3DVertexShader9 *LPDIRECT3DVERTEXSHADER9, *PDIRECT3DVERTEXSHADER9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DVertexShader9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DVertexShader9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DVertexShader9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DVertexShader9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DVertexShader9_GetFunction(p,a,b) (p)->lpVtbl->GetFunction(p,a,b) +#else +#define IDirect3DVertexShader9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DVertexShader9_AddRef(p) (p)->AddRef() +#define IDirect3DVertexShader9_Release(p) (p)->Release() +#define IDirect3DVertexShader9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DVertexShader9_GetFunction(p,a,b) (p)->GetFunction(a,b) +#endif + + + +#undef INTERFACE +#define INTERFACE IDirect3DPixelShader9 + +DECLARE_INTERFACE_(IDirect3DPixelShader9, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DPixelShader9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(GetFunction)(THIS_ void*,UINT* pSizeOfData) PURE; +}; + +typedef struct IDirect3DPixelShader9 *LPDIRECT3DPIXELSHADER9, *PDIRECT3DPIXELSHADER9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DPixelShader9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DPixelShader9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DPixelShader9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DPixelShader9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DPixelShader9_GetFunction(p,a,b) (p)->lpVtbl->GetFunction(p,a,b) +#else +#define IDirect3DPixelShader9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DPixelShader9_AddRef(p) (p)->AddRef() +#define IDirect3DPixelShader9_Release(p) (p)->Release() +#define IDirect3DPixelShader9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DPixelShader9_GetFunction(p,a,b) (p)->GetFunction(a,b) +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DBaseTexture9 + +DECLARE_INTERFACE_(IDirect3DBaseTexture9, IDirect3DResource9) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; + STDMETHOD_(DWORD, GetLOD)(THIS) PURE; + STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; + STDMETHOD(SetAutoGenFilterType)(THIS_ D3DTEXTUREFILTERTYPE FilterType) PURE; + STDMETHOD_(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)(THIS) PURE; + STDMETHOD_(void, GenerateMipSubLevels)(THIS) PURE; +}; + +typedef struct IDirect3DBaseTexture9 *LPDIRECT3DBASETEXTURE9, *PDIRECT3DBASETEXTURE9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DBaseTexture9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DBaseTexture9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DBaseTexture9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DBaseTexture9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DBaseTexture9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DBaseTexture9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DBaseTexture9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DBaseTexture9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DBaseTexture9_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DBaseTexture9_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DBaseTexture9_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DBaseTexture9_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirect3DBaseTexture9_GetLOD(p) (p)->lpVtbl->GetLOD(p) +#define IDirect3DBaseTexture9_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) +#define IDirect3DBaseTexture9_SetAutoGenFilterType(p,a) (p)->lpVtbl->SetAutoGenFilterType(p,a) +#define IDirect3DBaseTexture9_GetAutoGenFilterType(p) (p)->lpVtbl->GetAutoGenFilterType(p) +#define IDirect3DBaseTexture9_GenerateMipSubLevels(p) (p)->lpVtbl->GenerateMipSubLevels(p) +#else +#define IDirect3DBaseTexture9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DBaseTexture9_AddRef(p) (p)->AddRef() +#define IDirect3DBaseTexture9_Release(p) (p)->Release() +#define IDirect3DBaseTexture9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DBaseTexture9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DBaseTexture9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DBaseTexture9_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DBaseTexture9_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DBaseTexture9_GetPriority(p) (p)->GetPriority() +#define IDirect3DBaseTexture9_PreLoad(p) (p)->PreLoad() +#define IDirect3DBaseTexture9_GetType(p) (p)->GetType() +#define IDirect3DBaseTexture9_SetLOD(p,a) (p)->SetLOD(a) +#define IDirect3DBaseTexture9_GetLOD(p) (p)->GetLOD() +#define IDirect3DBaseTexture9_GetLevelCount(p) (p)->GetLevelCount() +#define IDirect3DBaseTexture9_SetAutoGenFilterType(p,a) (p)->SetAutoGenFilterType(a) +#define IDirect3DBaseTexture9_GetAutoGenFilterType(p) (p)->GetAutoGenFilterType() +#define IDirect3DBaseTexture9_GenerateMipSubLevels(p) (p)->GenerateMipSubLevels() +#endif + + + + + +#undef INTERFACE +#define INTERFACE IDirect3DTexture9 + +DECLARE_INTERFACE_(IDirect3DTexture9, IDirect3DBaseTexture9) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DBaseTexture9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; + STDMETHOD_(DWORD, GetLOD)(THIS) PURE; + STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; + STDMETHOD(SetAutoGenFilterType)(THIS_ D3DTEXTUREFILTERTYPE FilterType) PURE; + STDMETHOD_(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)(THIS) PURE; + STDMETHOD_(void, GenerateMipSubLevels)(THIS) PURE; + STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC *pDesc) PURE; + STDMETHOD(GetSurfaceLevel)(THIS_ UINT Level,IDirect3DSurface9** ppSurfaceLevel) PURE; + STDMETHOD(LockRect)(THIS_ UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; + STDMETHOD(UnlockRect)(THIS_ UINT Level) PURE; + STDMETHOD(AddDirtyRect)(THIS_ CONST RECT* pDirtyRect) PURE; +}; + +typedef struct IDirect3DTexture9 *LPDIRECT3DTEXTURE9, *PDIRECT3DTEXTURE9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DTexture9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DTexture9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DTexture9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DTexture9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DTexture9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DTexture9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DTexture9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DTexture9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DTexture9_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DTexture9_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DTexture9_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DTexture9_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirect3DTexture9_GetLOD(p) (p)->lpVtbl->GetLOD(p) +#define IDirect3DTexture9_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) +#define IDirect3DTexture9_SetAutoGenFilterType(p,a) (p)->lpVtbl->SetAutoGenFilterType(p,a) +#define IDirect3DTexture9_GetAutoGenFilterType(p) (p)->lpVtbl->GetAutoGenFilterType(p) +#define IDirect3DTexture9_GenerateMipSubLevels(p) (p)->lpVtbl->GenerateMipSubLevels(p) +#define IDirect3DTexture9_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) +#define IDirect3DTexture9_GetSurfaceLevel(p,a,b) (p)->lpVtbl->GetSurfaceLevel(p,a,b) +#define IDirect3DTexture9_LockRect(p,a,b,c,d) (p)->lpVtbl->LockRect(p,a,b,c,d) +#define IDirect3DTexture9_UnlockRect(p,a) (p)->lpVtbl->UnlockRect(p,a) +#define IDirect3DTexture9_AddDirtyRect(p,a) (p)->lpVtbl->AddDirtyRect(p,a) +#else +#define IDirect3DTexture9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DTexture9_AddRef(p) (p)->AddRef() +#define IDirect3DTexture9_Release(p) (p)->Release() +#define IDirect3DTexture9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DTexture9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DTexture9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DTexture9_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DTexture9_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DTexture9_GetPriority(p) (p)->GetPriority() +#define IDirect3DTexture9_PreLoad(p) (p)->PreLoad() +#define IDirect3DTexture9_GetType(p) (p)->GetType() +#define IDirect3DTexture9_SetLOD(p,a) (p)->SetLOD(a) +#define IDirect3DTexture9_GetLOD(p) (p)->GetLOD() +#define IDirect3DTexture9_GetLevelCount(p) (p)->GetLevelCount() +#define IDirect3DTexture9_SetAutoGenFilterType(p,a) (p)->SetAutoGenFilterType(a) +#define IDirect3DTexture9_GetAutoGenFilterType(p) (p)->GetAutoGenFilterType() +#define IDirect3DTexture9_GenerateMipSubLevels(p) (p)->GenerateMipSubLevels() +#define IDirect3DTexture9_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) +#define IDirect3DTexture9_GetSurfaceLevel(p,a,b) (p)->GetSurfaceLevel(a,b) +#define IDirect3DTexture9_LockRect(p,a,b,c,d) (p)->LockRect(a,b,c,d) +#define IDirect3DTexture9_UnlockRect(p,a) (p)->UnlockRect(a) +#define IDirect3DTexture9_AddDirtyRect(p,a) (p)->AddDirtyRect(a) +#endif + + + + + +#undef INTERFACE +#define INTERFACE IDirect3DVolumeTexture9 + +DECLARE_INTERFACE_(IDirect3DVolumeTexture9, IDirect3DBaseTexture9) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DBaseTexture9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; + STDMETHOD_(DWORD, GetLOD)(THIS) PURE; + STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; + STDMETHOD(SetAutoGenFilterType)(THIS_ D3DTEXTUREFILTERTYPE FilterType) PURE; + STDMETHOD_(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)(THIS) PURE; + STDMETHOD_(void, GenerateMipSubLevels)(THIS) PURE; + STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DVOLUME_DESC *pDesc) PURE; + STDMETHOD(GetVolumeLevel)(THIS_ UINT Level,IDirect3DVolume9** ppVolumeLevel) PURE; + STDMETHOD(LockBox)(THIS_ UINT Level,D3DLOCKED_BOX* pLockedVolume,CONST D3DBOX* pBox,DWORD Flags) PURE; + STDMETHOD(UnlockBox)(THIS_ UINT Level) PURE; + STDMETHOD(AddDirtyBox)(THIS_ CONST D3DBOX* pDirtyBox) PURE; +}; + +typedef struct IDirect3DVolumeTexture9 *LPDIRECT3DVOLUMETEXTURE9, *PDIRECT3DVOLUMETEXTURE9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DVolumeTexture9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DVolumeTexture9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DVolumeTexture9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DVolumeTexture9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DVolumeTexture9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DVolumeTexture9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DVolumeTexture9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DVolumeTexture9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DVolumeTexture9_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DVolumeTexture9_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DVolumeTexture9_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DVolumeTexture9_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirect3DVolumeTexture9_GetLOD(p) (p)->lpVtbl->GetLOD(p) +#define IDirect3DVolumeTexture9_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) +#define IDirect3DVolumeTexture9_SetAutoGenFilterType(p,a) (p)->lpVtbl->SetAutoGenFilterType(p,a) +#define IDirect3DVolumeTexture9_GetAutoGenFilterType(p) (p)->lpVtbl->GetAutoGenFilterType(p) +#define IDirect3DVolumeTexture9_GenerateMipSubLevels(p) (p)->lpVtbl->GenerateMipSubLevels(p) +#define IDirect3DVolumeTexture9_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) +#define IDirect3DVolumeTexture9_GetVolumeLevel(p,a,b) (p)->lpVtbl->GetVolumeLevel(p,a,b) +#define IDirect3DVolumeTexture9_LockBox(p,a,b,c,d) (p)->lpVtbl->LockBox(p,a,b,c,d) +#define IDirect3DVolumeTexture9_UnlockBox(p,a) (p)->lpVtbl->UnlockBox(p,a) +#define IDirect3DVolumeTexture9_AddDirtyBox(p,a) (p)->lpVtbl->AddDirtyBox(p,a) +#else +#define IDirect3DVolumeTexture9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DVolumeTexture9_AddRef(p) (p)->AddRef() +#define IDirect3DVolumeTexture9_Release(p) (p)->Release() +#define IDirect3DVolumeTexture9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DVolumeTexture9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DVolumeTexture9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DVolumeTexture9_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DVolumeTexture9_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DVolumeTexture9_GetPriority(p) (p)->GetPriority() +#define IDirect3DVolumeTexture9_PreLoad(p) (p)->PreLoad() +#define IDirect3DVolumeTexture9_GetType(p) (p)->GetType() +#define IDirect3DVolumeTexture9_SetLOD(p,a) (p)->SetLOD(a) +#define IDirect3DVolumeTexture9_GetLOD(p) (p)->GetLOD() +#define IDirect3DVolumeTexture9_GetLevelCount(p) (p)->GetLevelCount() +#define IDirect3DVolumeTexture9_SetAutoGenFilterType(p,a) (p)->SetAutoGenFilterType(a) +#define IDirect3DVolumeTexture9_GetAutoGenFilterType(p) (p)->GetAutoGenFilterType() +#define IDirect3DVolumeTexture9_GenerateMipSubLevels(p) (p)->GenerateMipSubLevels() +#define IDirect3DVolumeTexture9_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) +#define IDirect3DVolumeTexture9_GetVolumeLevel(p,a,b) (p)->GetVolumeLevel(a,b) +#define IDirect3DVolumeTexture9_LockBox(p,a,b,c,d) (p)->LockBox(a,b,c,d) +#define IDirect3DVolumeTexture9_UnlockBox(p,a) (p)->UnlockBox(a) +#define IDirect3DVolumeTexture9_AddDirtyBox(p,a) (p)->AddDirtyBox(a) +#endif + + + + + +#undef INTERFACE +#define INTERFACE IDirect3DCubeTexture9 + +DECLARE_INTERFACE_(IDirect3DCubeTexture9, IDirect3DBaseTexture9) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DBaseTexture9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; + STDMETHOD_(DWORD, GetLOD)(THIS) PURE; + STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; + STDMETHOD(SetAutoGenFilterType)(THIS_ D3DTEXTUREFILTERTYPE FilterType) PURE; + STDMETHOD_(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)(THIS) PURE; + STDMETHOD_(void, GenerateMipSubLevels)(THIS) PURE; + STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC *pDesc) PURE; + STDMETHOD(GetCubeMapSurface)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level,IDirect3DSurface9** ppCubeMapSurface) PURE; + STDMETHOD(LockRect)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; + STDMETHOD(UnlockRect)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level) PURE; + STDMETHOD(AddDirtyRect)(THIS_ D3DCUBEMAP_FACES FaceType,CONST RECT* pDirtyRect) PURE; +}; + +typedef struct IDirect3DCubeTexture9 *LPDIRECT3DCUBETEXTURE9, *PDIRECT3DCUBETEXTURE9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DCubeTexture9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DCubeTexture9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DCubeTexture9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DCubeTexture9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DCubeTexture9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DCubeTexture9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DCubeTexture9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DCubeTexture9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DCubeTexture9_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DCubeTexture9_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DCubeTexture9_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DCubeTexture9_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirect3DCubeTexture9_GetLOD(p) (p)->lpVtbl->GetLOD(p) +#define IDirect3DCubeTexture9_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) +#define IDirect3DCubeTexture9_SetAutoGenFilterType(p,a) (p)->lpVtbl->SetAutoGenFilterType(p,a) +#define IDirect3DCubeTexture9_GetAutoGenFilterType(p) (p)->lpVtbl->GetAutoGenFilterType(p) +#define IDirect3DCubeTexture9_GenerateMipSubLevels(p) (p)->lpVtbl->GenerateMipSubLevels(p) +#define IDirect3DCubeTexture9_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) +#define IDirect3DCubeTexture9_GetCubeMapSurface(p,a,b,c) (p)->lpVtbl->GetCubeMapSurface(p,a,b,c) +#define IDirect3DCubeTexture9_LockRect(p,a,b,c,d,e) (p)->lpVtbl->LockRect(p,a,b,c,d,e) +#define IDirect3DCubeTexture9_UnlockRect(p,a,b) (p)->lpVtbl->UnlockRect(p,a,b) +#define IDirect3DCubeTexture9_AddDirtyRect(p,a,b) (p)->lpVtbl->AddDirtyRect(p,a,b) +#else +#define IDirect3DCubeTexture9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DCubeTexture9_AddRef(p) (p)->AddRef() +#define IDirect3DCubeTexture9_Release(p) (p)->Release() +#define IDirect3DCubeTexture9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DCubeTexture9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DCubeTexture9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DCubeTexture9_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DCubeTexture9_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DCubeTexture9_GetPriority(p) (p)->GetPriority() +#define IDirect3DCubeTexture9_PreLoad(p) (p)->PreLoad() +#define IDirect3DCubeTexture9_GetType(p) (p)->GetType() +#define IDirect3DCubeTexture9_SetLOD(p,a) (p)->SetLOD(a) +#define IDirect3DCubeTexture9_GetLOD(p) (p)->GetLOD() +#define IDirect3DCubeTexture9_GetLevelCount(p) (p)->GetLevelCount() +#define IDirect3DCubeTexture9_SetAutoGenFilterType(p,a) (p)->SetAutoGenFilterType(a) +#define IDirect3DCubeTexture9_GetAutoGenFilterType(p) (p)->GetAutoGenFilterType() +#define IDirect3DCubeTexture9_GenerateMipSubLevels(p) (p)->GenerateMipSubLevels() +#define IDirect3DCubeTexture9_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) +#define IDirect3DCubeTexture9_GetCubeMapSurface(p,a,b,c) (p)->GetCubeMapSurface(a,b,c) +#define IDirect3DCubeTexture9_LockRect(p,a,b,c,d,e) (p)->LockRect(a,b,c,d,e) +#define IDirect3DCubeTexture9_UnlockRect(p,a,b) (p)->UnlockRect(a,b) +#define IDirect3DCubeTexture9_AddDirtyRect(p,a,b) (p)->AddDirtyRect(a,b) +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DVertexBuffer9 + +DECLARE_INTERFACE_(IDirect3DVertexBuffer9, IDirect3DResource9) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD(Lock)(THIS_ UINT OffsetToLock,UINT SizeToLock,void** ppbData,DWORD Flags) PURE; + STDMETHOD(Unlock)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3DVERTEXBUFFER_DESC *pDesc) PURE; +}; + +typedef struct IDirect3DVertexBuffer9 *LPDIRECT3DVERTEXBUFFER9, *PDIRECT3DVERTEXBUFFER9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DVertexBuffer9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DVertexBuffer9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DVertexBuffer9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DVertexBuffer9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DVertexBuffer9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DVertexBuffer9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DVertexBuffer9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DVertexBuffer9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DVertexBuffer9_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DVertexBuffer9_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DVertexBuffer9_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DVertexBuffer9_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirect3DVertexBuffer9_Unlock(p) (p)->lpVtbl->Unlock(p) +#define IDirect3DVertexBuffer9_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#else +#define IDirect3DVertexBuffer9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DVertexBuffer9_AddRef(p) (p)->AddRef() +#define IDirect3DVertexBuffer9_Release(p) (p)->Release() +#define IDirect3DVertexBuffer9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DVertexBuffer9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DVertexBuffer9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DVertexBuffer9_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DVertexBuffer9_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DVertexBuffer9_GetPriority(p) (p)->GetPriority() +#define IDirect3DVertexBuffer9_PreLoad(p) (p)->PreLoad() +#define IDirect3DVertexBuffer9_GetType(p) (p)->GetType() +#define IDirect3DVertexBuffer9_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirect3DVertexBuffer9_Unlock(p) (p)->Unlock() +#define IDirect3DVertexBuffer9_GetDesc(p,a) (p)->GetDesc(a) +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DIndexBuffer9 + +DECLARE_INTERFACE_(IDirect3DIndexBuffer9, IDirect3DResource9) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD(Lock)(THIS_ UINT OffsetToLock,UINT SizeToLock,void** ppbData,DWORD Flags) PURE; + STDMETHOD(Unlock)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3DINDEXBUFFER_DESC *pDesc) PURE; +}; + +typedef struct IDirect3DIndexBuffer9 *LPDIRECT3DINDEXBUFFER9, *PDIRECT3DINDEXBUFFER9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DIndexBuffer9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DIndexBuffer9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DIndexBuffer9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DIndexBuffer9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DIndexBuffer9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DIndexBuffer9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DIndexBuffer9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DIndexBuffer9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DIndexBuffer9_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DIndexBuffer9_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DIndexBuffer9_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DIndexBuffer9_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirect3DIndexBuffer9_Unlock(p) (p)->lpVtbl->Unlock(p) +#define IDirect3DIndexBuffer9_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#else +#define IDirect3DIndexBuffer9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DIndexBuffer9_AddRef(p) (p)->AddRef() +#define IDirect3DIndexBuffer9_Release(p) (p)->Release() +#define IDirect3DIndexBuffer9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DIndexBuffer9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DIndexBuffer9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DIndexBuffer9_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DIndexBuffer9_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DIndexBuffer9_GetPriority(p) (p)->GetPriority() +#define IDirect3DIndexBuffer9_PreLoad(p) (p)->PreLoad() +#define IDirect3DIndexBuffer9_GetType(p) (p)->GetType() +#define IDirect3DIndexBuffer9_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirect3DIndexBuffer9_Unlock(p) (p)->Unlock() +#define IDirect3DIndexBuffer9_GetDesc(p,a) (p)->GetDesc(a) +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DSurface9 + +DECLARE_INTERFACE_(IDirect3DSurface9, IDirect3DResource9) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD(GetContainer)(THIS_ REFIID riid,void** ppContainer) PURE; + STDMETHOD(GetDesc)(THIS_ D3DSURFACE_DESC *pDesc) PURE; + STDMETHOD(LockRect)(THIS_ D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; + STDMETHOD(UnlockRect)(THIS) PURE; + STDMETHOD(GetDC)(THIS_ HDC *phdc) PURE; + STDMETHOD(ReleaseDC)(THIS_ HDC hdc) PURE; +}; + +typedef struct IDirect3DSurface9 *LPDIRECT3DSURFACE9, *PDIRECT3DSURFACE9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DSurface9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DSurface9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DSurface9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DSurface9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DSurface9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DSurface9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DSurface9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DSurface9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DSurface9_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DSurface9_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DSurface9_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DSurface9_GetContainer(p,a,b) (p)->lpVtbl->GetContainer(p,a,b) +#define IDirect3DSurface9_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#define IDirect3DSurface9_LockRect(p,a,b,c) (p)->lpVtbl->LockRect(p,a,b,c) +#define IDirect3DSurface9_UnlockRect(p) (p)->lpVtbl->UnlockRect(p) +#define IDirect3DSurface9_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) +#define IDirect3DSurface9_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) +#else +#define IDirect3DSurface9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DSurface9_AddRef(p) (p)->AddRef() +#define IDirect3DSurface9_Release(p) (p)->Release() +#define IDirect3DSurface9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DSurface9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DSurface9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DSurface9_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DSurface9_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DSurface9_GetPriority(p) (p)->GetPriority() +#define IDirect3DSurface9_PreLoad(p) (p)->PreLoad() +#define IDirect3DSurface9_GetType(p) (p)->GetType() +#define IDirect3DSurface9_GetContainer(p,a,b) (p)->GetContainer(a,b) +#define IDirect3DSurface9_GetDesc(p,a) (p)->GetDesc(a) +#define IDirect3DSurface9_LockRect(p,a,b,c) (p)->LockRect(a,b,c) +#define IDirect3DSurface9_UnlockRect(p) (p)->UnlockRect() +#define IDirect3DSurface9_GetDC(p,a) (p)->GetDC(a) +#define IDirect3DSurface9_ReleaseDC(p,a) (p)->ReleaseDC(a) +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DVolume9 + +DECLARE_INTERFACE_(IDirect3DVolume9, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DVolume9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD(GetContainer)(THIS_ REFIID riid,void** ppContainer) PURE; + STDMETHOD(GetDesc)(THIS_ D3DVOLUME_DESC *pDesc) PURE; + STDMETHOD(LockBox)(THIS_ D3DLOCKED_BOX * pLockedVolume,CONST D3DBOX* pBox,DWORD Flags) PURE; + STDMETHOD(UnlockBox)(THIS) PURE; +}; + +typedef struct IDirect3DVolume9 *LPDIRECT3DVOLUME9, *PDIRECT3DVOLUME9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DVolume9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DVolume9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DVolume9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DVolume9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DVolume9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DVolume9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DVolume9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DVolume9_GetContainer(p,a,b) (p)->lpVtbl->GetContainer(p,a,b) +#define IDirect3DVolume9_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#define IDirect3DVolume9_LockBox(p,a,b,c) (p)->lpVtbl->LockBox(p,a,b,c) +#define IDirect3DVolume9_UnlockBox(p) (p)->lpVtbl->UnlockBox(p) +#else +#define IDirect3DVolume9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DVolume9_AddRef(p) (p)->AddRef() +#define IDirect3DVolume9_Release(p) (p)->Release() +#define IDirect3DVolume9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DVolume9_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DVolume9_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DVolume9_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DVolume9_GetContainer(p,a,b) (p)->GetContainer(a,b) +#define IDirect3DVolume9_GetDesc(p,a) (p)->GetDesc(a) +#define IDirect3DVolume9_LockBox(p,a,b,c) (p)->LockBox(a,b,c) +#define IDirect3DVolume9_UnlockBox(p) (p)->UnlockBox() +#endif + + + +#undef INTERFACE +#define INTERFACE IDirect3DQuery9 + +DECLARE_INTERFACE_(IDirect3DQuery9, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DQuery9 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE; + STDMETHOD_(D3DQUERYTYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, GetDataSize)(THIS) PURE; + STDMETHOD(Issue)(THIS_ DWORD dwIssueFlags) PURE; + STDMETHOD(GetData)(THIS_ void* pData,DWORD dwSize,DWORD dwGetDataFlags) PURE; +}; + +typedef struct IDirect3DQuery9 *LPDIRECT3DQUERY9, *PDIRECT3DQUERY9; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DQuery9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DQuery9_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DQuery9_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DQuery9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DQuery9_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DQuery9_GetDataSize(p) (p)->lpVtbl->GetDataSize(p) +#define IDirect3DQuery9_Issue(p,a) (p)->lpVtbl->Issue(p,a) +#define IDirect3DQuery9_GetData(p,a,b,c) (p)->lpVtbl->GetData(p,a,b,c) +#else +#define IDirect3DQuery9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DQuery9_AddRef(p) (p)->AddRef() +#define IDirect3DQuery9_Release(p) (p)->Release() +#define IDirect3DQuery9_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DQuery9_GetType(p) (p)->GetType() +#define IDirect3DQuery9_GetDataSize(p) (p)->GetDataSize() +#define IDirect3DQuery9_Issue(p,a) (p)->Issue(a) +#define IDirect3DQuery9_GetData(p,a,b,c) (p)->GetData(a,b,c) +#endif + + +/**************************************************************************** + * Flags for SetPrivateData method on all D3D9 interfaces + * + * The passed pointer is an IUnknown ptr. The SizeOfData argument to SetPrivateData + * must be set to sizeof(IUnknown*). Direct3D will call AddRef through this + * pointer and Release when the private data is destroyed. The data will be + * destroyed when another SetPrivateData with the same GUID is set, when + * FreePrivateData is called, or when the D3D9 object is freed. + ****************************************************************************/ +#define D3DSPD_IUNKNOWN 0x00000001L + +/**************************************************************************** + * + * Flags for IDirect3D9::CreateDevice's BehaviorFlags + * + ****************************************************************************/ + +#define D3DCREATE_FPU_PRESERVE 0x00000002L +#define D3DCREATE_MULTITHREADED 0x00000004L + +#define D3DCREATE_PUREDEVICE 0x00000010L +#define D3DCREATE_SOFTWARE_VERTEXPROCESSING 0x00000020L +#define D3DCREATE_HARDWARE_VERTEXPROCESSING 0x00000040L +#define D3DCREATE_MIXED_VERTEXPROCESSING 0x00000080L + +#define D3DCREATE_DISABLE_DRIVER_MANAGEMENT 0x00000100L +#define D3DCREATE_ADAPTERGROUP_DEVICE 0x00000200L + + +/**************************************************************************** + * + * Parameter for IDirect3D9::CreateDevice's iAdapter + * + ****************************************************************************/ + +#define D3DADAPTER_DEFAULT 0 + +/**************************************************************************** + * + * Flags for IDirect3D9::EnumAdapters + * + ****************************************************************************/ + +#define D3DENUM_WHQL_LEVEL 0x00000002L + +/**************************************************************************** + * + * Maximum number of back-buffers supported in DX8 + * + ****************************************************************************/ + +#define D3DPRESENT_BACK_BUFFERS_MAX 3L + +/**************************************************************************** + * + * Flags for IDirect3DDevice9::SetGammaRamp + * + ****************************************************************************/ + +#define D3DSGR_NO_CALIBRATION 0x00000000L +#define D3DSGR_CALIBRATE 0x00000001L + +/**************************************************************************** + * + * Flags for IDirect3DDevice9::SetCursorPosition + * + ****************************************************************************/ + +#define D3DCURSOR_IMMEDIATE_UPDATE 0x00000001L + +/**************************************************************************** + * + * Flags for IDirect3DSwapChain9::Present + * + ****************************************************************************/ + +#define D3DPRESENT_DONOTWAIT 0x00000001L +#define D3DPRESENT_LINEAR_CONTENT 0x00000002L + +/**************************************************************************** + * + * Flags for DrawPrimitive/DrawIndexedPrimitive + * Also valid for Begin/BeginIndexed + * Also valid for VertexBuffer::CreateVertexBuffer + ****************************************************************************/ + + +/* + * DirectDraw error codes + */ +#define _FACD3D 0x876 +#define MAKE_D3DHRESULT( code ) MAKE_HRESULT( 1, _FACD3D, code ) +#define MAKE_D3DSTATUS( code ) MAKE_HRESULT( 0, _FACD3D, code ) + +/* + * Direct3D Errors + */ +#define D3D_OK S_OK + +#define D3DERR_WRONGTEXTUREFORMAT MAKE_D3DHRESULT(2072) +#define D3DERR_UNSUPPORTEDCOLOROPERATION MAKE_D3DHRESULT(2073) +#define D3DERR_UNSUPPORTEDCOLORARG MAKE_D3DHRESULT(2074) +#define D3DERR_UNSUPPORTEDALPHAOPERATION MAKE_D3DHRESULT(2075) +#define D3DERR_UNSUPPORTEDALPHAARG MAKE_D3DHRESULT(2076) +#define D3DERR_TOOMANYOPERATIONS MAKE_D3DHRESULT(2077) +#define D3DERR_CONFLICTINGTEXTUREFILTER MAKE_D3DHRESULT(2078) +#define D3DERR_UNSUPPORTEDFACTORVALUE MAKE_D3DHRESULT(2079) +#define D3DERR_CONFLICTINGRENDERSTATE MAKE_D3DHRESULT(2081) +#define D3DERR_UNSUPPORTEDTEXTUREFILTER MAKE_D3DHRESULT(2082) +#define D3DERR_CONFLICTINGTEXTUREPALETTE MAKE_D3DHRESULT(2086) +#define D3DERR_DRIVERINTERNALERROR MAKE_D3DHRESULT(2087) + +#define D3DERR_NOTFOUND MAKE_D3DHRESULT(2150) +#define D3DERR_MOREDATA MAKE_D3DHRESULT(2151) +#define D3DERR_DEVICELOST MAKE_D3DHRESULT(2152) +#define D3DERR_DEVICENOTRESET MAKE_D3DHRESULT(2153) +#define D3DERR_NOTAVAILABLE MAKE_D3DHRESULT(2154) +#define D3DERR_OUTOFVIDEOMEMORY MAKE_D3DHRESULT(380) +#define D3DERR_INVALIDDEVICE MAKE_D3DHRESULT(2155) +#define D3DERR_INVALIDCALL MAKE_D3DHRESULT(2156) +#define D3DERR_DRIVERINVALIDCALL MAKE_D3DHRESULT(2157) +#define D3DERR_WASSTILLDRAWING MAKE_D3DHRESULT(540) +#define D3DOK_NOAUTOGEN MAKE_D3DSTATUS(2159) + + +#ifdef __cplusplus +}; +#endif + +#endif /* (DIRECT3D_VERSION >= 0x0900) */ +#endif /* _D3D_H_ */ + diff --git a/proxy_dll/d3dx9.h b/proxy_dll/d3dx9.h new file mode 100644 index 0000000..cbaabcf --- /dev/null +++ b/proxy_dll/d3dx9.h @@ -0,0 +1,71 @@ +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx9.h +// Content: D3DX utility library +// +////////////////////////////////////////////////////////////////////////////// + +#ifdef __D3DX_INTERNAL__ +#error Incorrect D3DX header used +#endif + +#ifndef __D3DX9_H__ +#define __D3DX9_H__ + + +// Defines +#include + +#define D3DX_DEFAULT ((UINT) -1) +#define D3DX_DEFAULT_NONPOW2 ((UINT) -2) +#define D3DX_DEFAULT_FLOAT FLT_MAX + +#ifndef D3DXINLINE +#ifdef _MSC_VER + #if (_MSC_VER >= 1200) + #define D3DXINLINE __forceinline + #else + #define D3DXINLINE __inline + #endif +#else + #ifdef __cplusplus + #define D3DXINLINE inline + #else + #define D3DXINLINE + #endif +#endif +#endif + + +// Includes +#include "d3d9.h" +#include "d3dx9math.h" +#include "d3dx9core.h" +#include "d3dx9mesh.h" +#include "d3dx9tex.h" +#include "d3dx9shader.h" +#include "d3dx9effect.h" +#include "d3dx9shape.h" +#include "d3dx9anim.h" + + +// Errors +#define _FACDD 0x876 +#define MAKE_DDHRESULT( code ) MAKE_HRESULT( 1, _FACDD, code ) + +enum _D3DXERR { + D3DXERR_CANNOTMODIFYINDEXBUFFER = MAKE_DDHRESULT(2900), + D3DXERR_INVALIDMESH = MAKE_DDHRESULT(2901), + D3DXERR_CANNOTATTRSORT = MAKE_DDHRESULT(2902), + D3DXERR_SKINNINGNOTSUPPORTED = MAKE_DDHRESULT(2903), + D3DXERR_TOOMANYINFLUENCES = MAKE_DDHRESULT(2904), + D3DXERR_INVALIDDATA = MAKE_DDHRESULT(2905), + D3DXERR_LOADEDMESHASNODATA = MAKE_DDHRESULT(2906), + D3DXERR_DUPLICATENAMEDFRAGMENT = MAKE_DDHRESULT(2907), +}; + + +#endif //__D3DX9_H__ + diff --git a/proxy_dll/myIDirect3D9.cpp b/proxy_dll/myIDirect3D9.cpp new file mode 100644 index 0000000..e3e904c --- /dev/null +++ b/proxy_dll/myIDirect3D9.cpp @@ -0,0 +1,145 @@ +#include "StdAfx.h" +#include "proxydll.h" + +myIDirect3D9::myIDirect3D9(IDirect3D9 *pOriginal) +{ + m_pIDirect3D9 = pOriginal; +} + +myIDirect3D9::~myIDirect3D9(void) +{ +} + +HRESULT __stdcall myIDirect3D9::QueryInterface(REFIID riid, void** ppvObj) +{ + *ppvObj = NULL; + + // call this to increase AddRef at original object + // and to check if such an interface is there + + HRESULT hRes = m_pIDirect3D9->QueryInterface(riid, ppvObj); + + if (hRes == NOERROR) // if OK, send our "fake" address + { + *ppvObj = this; + } + + return hRes; +} + +ULONG __stdcall myIDirect3D9::AddRef(void) +{ + return(m_pIDirect3D9->AddRef()); +} + +ULONG __stdcall myIDirect3D9::Release(void) +{ + extern myIDirect3D9* gl_pmyIDirect3D9; + + // call original routine + ULONG count = m_pIDirect3D9->Release(); + + // in case no further Ref is there, the Original Object has deleted itself + // so do we here + if (count == 0) + { + gl_pmyIDirect3D9 = NULL; + delete(this); + } + + return(count); +} + +HRESULT __stdcall myIDirect3D9::RegisterSoftwareDevice(void* pInitializeFunction) +{ + return(m_pIDirect3D9->RegisterSoftwareDevice(pInitializeFunction)); +} + +UINT __stdcall myIDirect3D9::GetAdapterCount(void) +{ + return(m_pIDirect3D9->GetAdapterCount()); +} + +HRESULT __stdcall myIDirect3D9::GetAdapterIdentifier(UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER9* pIdentifier) +{ + return(m_pIDirect3D9->GetAdapterIdentifier(Adapter,Flags,pIdentifier)); +} + +UINT __stdcall myIDirect3D9::GetAdapterModeCount(UINT Adapter, D3DFORMAT Format) +{ + return(m_pIDirect3D9->GetAdapterModeCount(Adapter, Format)); +} + +HRESULT __stdcall myIDirect3D9::EnumAdapterModes(UINT Adapter,D3DFORMAT Format,UINT Mode,D3DDISPLAYMODE* pMode) +{ + return(m_pIDirect3D9->EnumAdapterModes(Adapter,Format,Mode,pMode)); +} + +HRESULT __stdcall myIDirect3D9::GetAdapterDisplayMode( UINT Adapter,D3DDISPLAYMODE* pMode) +{ + return(m_pIDirect3D9->GetAdapterDisplayMode(Adapter,pMode)); +} + +HRESULT __stdcall myIDirect3D9::CheckDeviceType(UINT iAdapter,D3DDEVTYPE DevType,D3DFORMAT DisplayFormat,D3DFORMAT BackBufferFormat,BOOL bWindowed) +{ + return(m_pIDirect3D9->CheckDeviceType(iAdapter,DevType,DisplayFormat,BackBufferFormat,bWindowed)); +} + +HRESULT __stdcall myIDirect3D9::CheckDeviceFormat(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat) +{ + return(m_pIDirect3D9->CheckDeviceFormat(Adapter,DeviceType,AdapterFormat,Usage,RType,CheckFormat)); +} + +HRESULT __stdcall myIDirect3D9::CheckDeviceMultiSampleType(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType,DWORD* pQualityLevels) +{ + return(m_pIDirect3D9->CheckDeviceMultiSampleType(Adapter,DeviceType,SurfaceFormat,Windowed,MultiSampleType,pQualityLevels)); +} + +HRESULT __stdcall myIDirect3D9::CheckDepthStencilMatch(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat) +{ + return(m_pIDirect3D9->CheckDepthStencilMatch(Adapter,DeviceType,AdapterFormat,RenderTargetFormat,DepthStencilFormat)); +} + +HRESULT __stdcall myIDirect3D9::CheckDeviceFormatConversion(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SourceFormat,D3DFORMAT TargetFormat) +{ + return(m_pIDirect3D9->CheckDeviceFormatConversion(Adapter,DeviceType,SourceFormat,TargetFormat)); +} + +HRESULT __stdcall myIDirect3D9::GetDeviceCaps(UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS9* pCaps) +{ + return(m_pIDirect3D9->GetDeviceCaps(Adapter,DeviceType,pCaps)); +} + +HMONITOR __stdcall myIDirect3D9::GetAdapterMonitor(UINT Adapter) +{ + return(m_pIDirect3D9->GetAdapterMonitor(Adapter)); +} + +HRESULT __stdcall myIDirect3D9::CreateDevice(UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface) +{ + // global var + extern myIDirect3DDevice9* gl_pmyIDirect3DDevice9; + + // we intercept this call and provide our own "fake" Device Object + HRESULT hres = m_pIDirect3D9->CreateDevice( Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface); + + // Create our own Device object and store it in global pointer + // note: the object will delete itself once Ref count is zero (similar to COM objects) + gl_pmyIDirect3DDevice9 = new myIDirect3DDevice9(*ppReturnedDeviceInterface); + + // store our pointer (the fake one) for returning it to the calling progam + *ppReturnedDeviceInterface = gl_pmyIDirect3DDevice9; + + // Call the rendering plugins + if ( D3D_OK == hres ) + { + std::vector::const_iterator callback_iterator; + for ( callback_iterator = g_init_callbacks.begin(); callback_iterator != g_init_callbacks.end(); callback_iterator++ ) + { + (*callback_iterator)( gl_pmyIDirect3DDevice9 ) ; + } + } + + return(hres); +} + diff --git a/proxy_dll/myIDirect3D9.h b/proxy_dll/myIDirect3D9.h new file mode 100644 index 0000000..11ef823 --- /dev/null +++ b/proxy_dll/myIDirect3D9.h @@ -0,0 +1,31 @@ +#pragma once + +class myIDirect3D9 : public IDirect3D9 +{ +public: + myIDirect3D9(IDirect3D9 *pOriginal); + virtual ~myIDirect3D9(void); + + // The original DX9 function definitions + HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObj); + ULONG __stdcall AddRef(void); + ULONG __stdcall Release(void); + HRESULT __stdcall RegisterSoftwareDevice(void* pInitializeFunction); + UINT __stdcall GetAdapterCount(void); + HRESULT __stdcall GetAdapterIdentifier(UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER9* pIdentifier) ; + UINT __stdcall GetAdapterModeCount(UINT Adapter, D3DFORMAT Format); + HRESULT __stdcall EnumAdapterModes(UINT Adapter,D3DFORMAT Format,UINT Mode,D3DDISPLAYMODE* pMode) ; + HRESULT __stdcall GetAdapterDisplayMode( UINT Adapter,D3DDISPLAYMODE* pMode) ; + HRESULT __stdcall CheckDeviceType(UINT iAdapter,D3DDEVTYPE DevType,D3DFORMAT DisplayFormat,D3DFORMAT BackBufferFormat,BOOL bWindowed) ; + HRESULT __stdcall CheckDeviceFormat(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat) ; + HRESULT __stdcall CheckDeviceMultiSampleType(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType,DWORD* pQualityLevels) ; + HRESULT __stdcall CheckDepthStencilMatch(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat) ; + HRESULT __stdcall CheckDeviceFormatConversion(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SourceFormat,D3DFORMAT TargetFormat); + HRESULT __stdcall GetDeviceCaps(UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS9* pCaps) ; + HMONITOR __stdcall GetAdapterMonitor(UINT Adapter) ; + HRESULT __stdcall CreateDevice(UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface) ; + // The original DX9 function definitions + +private: + IDirect3D9 *m_pIDirect3D9; +}; diff --git a/proxy_dll/myIDirect3DDevice9.cpp b/proxy_dll/myIDirect3DDevice9.cpp new file mode 100644 index 0000000..e58b5f1 --- /dev/null +++ b/proxy_dll/myIDirect3DDevice9.cpp @@ -0,0 +1,684 @@ +#include "StdAfx.h" +#include "proxydll.h" + + +myIDirect3DDevice9::myIDirect3DDevice9(IDirect3DDevice9* pOriginal) +{ + m_pIDirect3DDevice9 = pOriginal; // store the pointer to original object +} + +myIDirect3DDevice9::~myIDirect3DDevice9(void) +{ +} + +HRESULT myIDirect3DDevice9::QueryInterface (REFIID riid, void** ppvObj) +{ + // check if original dll can provide interface. then send *our* address + *ppvObj = NULL; + + HRESULT hRes = m_pIDirect3DDevice9->QueryInterface(riid, ppvObj); + + if (hRes == NOERROR) + { + *ppvObj = this; + } + + return hRes; +} + +ULONG myIDirect3DDevice9::AddRef(void) +{ + return(m_pIDirect3DDevice9->AddRef()); +} + +ULONG myIDirect3DDevice9::Release(void) +{ + // ATTENTION: This is a booby-trap ! Watch out ! + // If we create our own sprites, surfaces, etc. (thus increasing the ref counter + // by external action), we need to delete that objects before calling the original + // Release function + + // global var + extern myIDirect3DDevice9* gl_pmyIDirect3DDevice9; + + // Call the rendering plugins so that they can release/delete own objects + std::vector::const_iterator callback_iterator; + for ( callback_iterator = g_release_callbacks.begin(); callback_iterator != g_release_callbacks.end(); callback_iterator++ ) + { + (*callback_iterator)( this ) ; + } + + // Calling original function now + ULONG count = m_pIDirect3DDevice9->Release(); + + if (count==0) + { + // now, the Original Object has deleted itself, so do we here + gl_pmyIDirect3DDevice9 = NULL; + delete(this); // destructor will be called automatically + } + + return (count); +} + +HRESULT myIDirect3DDevice9::TestCooperativeLevel(void) +{ + return(m_pIDirect3DDevice9->TestCooperativeLevel()); +} + +UINT myIDirect3DDevice9::GetAvailableTextureMem(void) +{ + return(m_pIDirect3DDevice9->GetAvailableTextureMem()); +} + +HRESULT myIDirect3DDevice9::EvictManagedResources(void) +{ + return(m_pIDirect3DDevice9->EvictManagedResources()); +} + +HRESULT myIDirect3DDevice9::GetDirect3D(IDirect3D9** ppD3D9) +{ + return(m_pIDirect3DDevice9->GetDirect3D(ppD3D9)); +} + +HRESULT myIDirect3DDevice9::GetDeviceCaps(D3DCAPS9* pCaps) +{ + return(m_pIDirect3DDevice9->GetDeviceCaps(pCaps)); +} + +HRESULT myIDirect3DDevice9::GetDisplayMode(UINT iSwapChain,D3DDISPLAYMODE* pMode) +{ + return(m_pIDirect3DDevice9->GetDisplayMode(iSwapChain, pMode)); +} + +HRESULT myIDirect3DDevice9::GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS *pParameters) +{ + return(m_pIDirect3DDevice9->GetCreationParameters(pParameters)); +} + +HRESULT myIDirect3DDevice9::SetCursorProperties(UINT XHotSpot,UINT YHotSpot,IDirect3DSurface9* pCursorBitmap) +{ + return(m_pIDirect3DDevice9->SetCursorProperties(XHotSpot,YHotSpot,pCursorBitmap)); +} + +void myIDirect3DDevice9::SetCursorPosition(int X,int Y,DWORD Flags) +{ + return(m_pIDirect3DDevice9->SetCursorPosition(X,Y,Flags)); +} + +BOOL myIDirect3DDevice9::ShowCursor(BOOL bShow) +{ + return(m_pIDirect3DDevice9->ShowCursor(bShow)); +} + +HRESULT myIDirect3DDevice9::CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DSwapChain9** pSwapChain) +{ + return(m_pIDirect3DDevice9->CreateAdditionalSwapChain(pPresentationParameters,pSwapChain)); +} + +HRESULT myIDirect3DDevice9::GetSwapChain(UINT iSwapChain,IDirect3DSwapChain9** pSwapChain) +{ + // global var + extern myIDirect3DSwapChain9* gl_pmyIDirect3DSwapChain9; + + // We only cover swapchain 0 + if (iSwapChain!=0) return(m_pIDirect3DDevice9->GetSwapChain(iSwapChain,pSwapChain)); + + if (gl_pmyIDirect3DSwapChain9) + { + *pSwapChain = gl_pmyIDirect3DSwapChain9; + return(D3D_OK); + } + + // we intercept this call and provide our own "fake" SwapChain Object + IDirect3DSwapChain9* pOriginal = NULL; + HRESULT hres = m_pIDirect3DDevice9->GetSwapChain(iSwapChain,&pOriginal); + + // Create our own SwapChain object and store it in global pointer + // note: the object will delete itself once Ref count is zero (similar to COM objects) + gl_pmyIDirect3DSwapChain9 = new myIDirect3DSwapChain9(pOriginal, m_pIDirect3DDevice9); + + // store our pointer (the fake one) for returning it to the calling progam + *pSwapChain = gl_pmyIDirect3DSwapChain9; + + return(hres); +} + +UINT myIDirect3DDevice9::GetNumberOfSwapChains(void) +{ + return(m_pIDirect3DDevice9->GetNumberOfSwapChains()); +} + +HRESULT myIDirect3DDevice9::Reset(D3DPRESENT_PARAMETERS* pPresentationParameters) +{ + return(m_pIDirect3DDevice9->Reset(pPresentationParameters)); +} + +HRESULT myIDirect3DDevice9::Present(CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) +{ + // we may want to draw own things here before flipping surfaces + // Let the rendering plugins have a last go before the flip happens + std::vector::const_iterator callback_iterator; + for ( callback_iterator = g_present_callbacks.begin(); callback_iterator != g_present_callbacks.end(); callback_iterator++ ) + { + (*callback_iterator)( this ) ; + } + + // call original routine + HRESULT hres = m_pIDirect3DDevice9->Present( pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion); + + return (hres); +} + +HRESULT myIDirect3DDevice9::GetBackBuffer(UINT iSwapChain,UINT iBackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface9** ppBackBuffer) +{ + return(m_pIDirect3DDevice9->GetBackBuffer(iSwapChain,iBackBuffer,Type,ppBackBuffer)); +} + +HRESULT myIDirect3DDevice9::GetRasterStatus(UINT iSwapChain,D3DRASTER_STATUS* pRasterStatus) +{ + return(m_pIDirect3DDevice9->GetRasterStatus(iSwapChain,pRasterStatus)); +} + +HRESULT myIDirect3DDevice9::SetDialogBoxMode(BOOL bEnableDialogs) +{ + return(m_pIDirect3DDevice9->SetDialogBoxMode(bEnableDialogs)); +} + +void myIDirect3DDevice9::SetGammaRamp(UINT iSwapChain,DWORD Flags,CONST D3DGAMMARAMP* pRamp) +{ + return(m_pIDirect3DDevice9->SetGammaRamp(iSwapChain,Flags,pRamp)); +} + +void myIDirect3DDevice9::GetGammaRamp(UINT iSwapChain,D3DGAMMARAMP* pRamp) +{ + return(m_pIDirect3DDevice9->GetGammaRamp(iSwapChain,pRamp)); +} + +HRESULT myIDirect3DDevice9::CreateTexture(UINT Width,UINT Height,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DTexture9** ppTexture,HANDLE* pSharedHandle) +{ + return(m_pIDirect3DDevice9->CreateTexture(Width,Height,Levels,Usage,Format,Pool,ppTexture,pSharedHandle)); +} + +HRESULT myIDirect3DDevice9::CreateVolumeTexture(UINT Width,UINT Height,UINT Depth,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DVolumeTexture9** ppVolumeTexture,HANDLE* pSharedHandle) +{ + return(m_pIDirect3DDevice9->CreateVolumeTexture(Width,Height,Depth,Levels,Usage,Format,Pool,ppVolumeTexture,pSharedHandle)); +} + +HRESULT myIDirect3DDevice9::CreateCubeTexture(UINT EdgeLength,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DCubeTexture9** ppCubeTexture,HANDLE* pSharedHandle) +{ + return(m_pIDirect3DDevice9->CreateCubeTexture(EdgeLength,Levels,Usage,Format,Pool,ppCubeTexture,pSharedHandle)); +} + +HRESULT myIDirect3DDevice9::CreateVertexBuffer(UINT Length,DWORD Usage,DWORD FVF,D3DPOOL Pool,IDirect3DVertexBuffer9** ppVertexBuffer,HANDLE* pSharedHandle) +{ + return(m_pIDirect3DDevice9->CreateVertexBuffer(Length,Usage,FVF,Pool,ppVertexBuffer,pSharedHandle)); +} + +HRESULT myIDirect3DDevice9::CreateIndexBuffer(UINT Length,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DIndexBuffer9** ppIndexBuffer,HANDLE* pSharedHandle) +{ + return(m_pIDirect3DDevice9->CreateIndexBuffer(Length,Usage,Format,Pool,ppIndexBuffer,pSharedHandle)); +} + +HRESULT myIDirect3DDevice9::CreateRenderTarget(UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Lockable,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle) +{ + return(m_pIDirect3DDevice9->CreateRenderTarget(Width,Height,Format,MultiSample,MultisampleQuality,Lockable,ppSurface,pSharedHandle)); +} + +HRESULT myIDirect3DDevice9::CreateDepthStencilSurface(UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Discard,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle) +{ + return(m_pIDirect3DDevice9->CreateDepthStencilSurface(Width,Height,Format,MultiSample,MultisampleQuality,Discard,ppSurface,pSharedHandle)); +} + +HRESULT myIDirect3DDevice9::UpdateSurface(IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect,IDirect3DSurface9* pDestinationSurface,CONST POINT* pDestPoint) +{ + return(m_pIDirect3DDevice9->UpdateSurface(pSourceSurface,pSourceRect,pDestinationSurface,pDestPoint)); +} + +HRESULT myIDirect3DDevice9::UpdateTexture(IDirect3DBaseTexture9* pSourceTexture,IDirect3DBaseTexture9* pDestinationTexture) +{ + return(m_pIDirect3DDevice9->UpdateTexture(pSourceTexture,pDestinationTexture)); +} + +HRESULT myIDirect3DDevice9::GetRenderTargetData(IDirect3DSurface9* pRenderTarget,IDirect3DSurface9* pDestSurface) +{ + return(m_pIDirect3DDevice9->GetRenderTargetData(pRenderTarget,pDestSurface)); +} + +HRESULT myIDirect3DDevice9::GetFrontBufferData(UINT iSwapChain,IDirect3DSurface9* pDestSurface) +{ + return(m_pIDirect3DDevice9->GetFrontBufferData(iSwapChain,pDestSurface)); +} + +HRESULT myIDirect3DDevice9::StretchRect(IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect,IDirect3DSurface9* pDestSurface,CONST RECT* pDestRect,D3DTEXTUREFILTERTYPE Filter) +{ + return(m_pIDirect3DDevice9->StretchRect(pSourceSurface,pSourceRect,pDestSurface,pDestRect,Filter)); +} + +HRESULT myIDirect3DDevice9::ColorFill(IDirect3DSurface9* pSurface,CONST RECT* pRect,D3DCOLOR color) +{ + return(m_pIDirect3DDevice9->ColorFill(pSurface,pRect,color)); +} + +HRESULT myIDirect3DDevice9::CreateOffscreenPlainSurface(UINT Width,UINT Height,D3DFORMAT Format,D3DPOOL Pool,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle) +{ + return(m_pIDirect3DDevice9->CreateOffscreenPlainSurface(Width,Height,Format,Pool,ppSurface,pSharedHandle)); +} + +HRESULT myIDirect3DDevice9::SetRenderTarget(DWORD RenderTargetIndex,IDirect3DSurface9* pRenderTarget) +{ + return(m_pIDirect3DDevice9->SetRenderTarget(RenderTargetIndex,pRenderTarget)); +} + +HRESULT myIDirect3DDevice9::GetRenderTarget(DWORD RenderTargetIndex,IDirect3DSurface9** ppRenderTarget) +{ + return(m_pIDirect3DDevice9->GetRenderTarget(RenderTargetIndex,ppRenderTarget)); +} + +HRESULT myIDirect3DDevice9::SetDepthStencilSurface(IDirect3DSurface9* pNewZStencil) +{ + return(m_pIDirect3DDevice9->SetDepthStencilSurface(pNewZStencil)); +} + +HRESULT myIDirect3DDevice9::GetDepthStencilSurface(IDirect3DSurface9** ppZStencilSurface) +{ + return(m_pIDirect3DDevice9->GetDepthStencilSurface(ppZStencilSurface)); +} + +HRESULT myIDirect3DDevice9::BeginScene(void) +{ + return(m_pIDirect3DDevice9->BeginScene()); +} + +HRESULT myIDirect3DDevice9::EndScene(void) +{ + // Notify the rendering plugins that the scene is about to finish + std::vector::const_iterator callback_iterator; + for ( callback_iterator = g_endscene_callbacks.begin(); callback_iterator != g_endscene_callbacks.end(); callback_iterator++ ) + { + (*callback_iterator)( this ) ; + } + + return (m_pIDirect3DDevice9->EndScene()); +} + +HRESULT myIDirect3DDevice9::Clear(DWORD Count,CONST D3DRECT* pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil) +{ + return(m_pIDirect3DDevice9->Clear(Count,pRects,Flags,Color,Z,Stencil)); +} + +HRESULT myIDirect3DDevice9::SetTransform(D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix) +{ + return(m_pIDirect3DDevice9->SetTransform(State,pMatrix)); +} + +HRESULT myIDirect3DDevice9::GetTransform(D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix) +{ + return(m_pIDirect3DDevice9->GetTransform(State,pMatrix)); +} + +HRESULT myIDirect3DDevice9::MultiplyTransform(D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix) +{ + return(m_pIDirect3DDevice9->MultiplyTransform(State,pMatrix)); +} + +HRESULT myIDirect3DDevice9::SetViewport(CONST D3DVIEWPORT9* pViewport) +{ + return(m_pIDirect3DDevice9->SetViewport(pViewport)); +} + +HRESULT myIDirect3DDevice9::GetViewport(D3DVIEWPORT9* pViewport) +{ + return(m_pIDirect3DDevice9->GetViewport(pViewport)); +} + +HRESULT myIDirect3DDevice9::SetMaterial(CONST D3DMATERIAL9* pMaterial) +{ + return(m_pIDirect3DDevice9->SetMaterial(pMaterial)); +} + +HRESULT myIDirect3DDevice9::GetMaterial(D3DMATERIAL9* pMaterial) +{ + return(m_pIDirect3DDevice9->GetMaterial(pMaterial)); +} + +HRESULT myIDirect3DDevice9::SetLight(DWORD Index,CONST D3DLIGHT9* pLight) +{ + return(m_pIDirect3DDevice9->SetLight(Index,pLight)); +} + +HRESULT myIDirect3DDevice9::GetLight(DWORD Index,D3DLIGHT9* pLight) +{ + return(m_pIDirect3DDevice9->GetLight(Index,pLight)); +} + +HRESULT myIDirect3DDevice9::LightEnable(DWORD Index,BOOL Enable) +{ + return(m_pIDirect3DDevice9->LightEnable(Index,Enable)); +} + +HRESULT myIDirect3DDevice9::GetLightEnable(DWORD Index,BOOL* pEnable) +{ + return(m_pIDirect3DDevice9->GetLightEnable(Index, pEnable)); +} + +HRESULT myIDirect3DDevice9::SetClipPlane(DWORD Index,CONST float* pPlane) +{ + return(m_pIDirect3DDevice9->SetClipPlane(Index, pPlane)); +} + +HRESULT myIDirect3DDevice9::GetClipPlane(DWORD Index,float* pPlane) +{ + return(m_pIDirect3DDevice9->GetClipPlane(Index,pPlane)); +} + +HRESULT myIDirect3DDevice9::SetRenderState(D3DRENDERSTATETYPE State,DWORD Value) +{ + return(m_pIDirect3DDevice9->SetRenderState(State, Value)); +} + +HRESULT myIDirect3DDevice9::GetRenderState(D3DRENDERSTATETYPE State,DWORD* pValue) +{ + return(m_pIDirect3DDevice9->GetRenderState(State, pValue)); +} + +HRESULT myIDirect3DDevice9::CreateStateBlock(D3DSTATEBLOCKTYPE Type,IDirect3DStateBlock9** ppSB) +{ + return(m_pIDirect3DDevice9->CreateStateBlock(Type,ppSB)); +} + +HRESULT myIDirect3DDevice9::BeginStateBlock(void) +{ + return(m_pIDirect3DDevice9->BeginStateBlock()); +} + +HRESULT myIDirect3DDevice9::EndStateBlock(IDirect3DStateBlock9** ppSB) +{ + return(m_pIDirect3DDevice9->EndStateBlock(ppSB)); +} + +HRESULT myIDirect3DDevice9::SetClipStatus(CONST D3DCLIPSTATUS9* pClipStatus) +{ + return(m_pIDirect3DDevice9->SetClipStatus(pClipStatus)); +} + +HRESULT myIDirect3DDevice9::GetClipStatus(D3DCLIPSTATUS9* pClipStatus) +{ + return(m_pIDirect3DDevice9->GetClipStatus( pClipStatus)); +} + +HRESULT myIDirect3DDevice9::GetTexture(DWORD Stage,IDirect3DBaseTexture9** ppTexture) +{ + return(m_pIDirect3DDevice9->GetTexture(Stage,ppTexture)); +} + +HRESULT myIDirect3DDevice9::SetTexture(DWORD Stage,IDirect3DBaseTexture9* pTexture) +{ + return(m_pIDirect3DDevice9->SetTexture(Stage,pTexture)); +} + +HRESULT myIDirect3DDevice9::GetTextureStageState(DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue) +{ + return(m_pIDirect3DDevice9->GetTextureStageState(Stage,Type, pValue)); +} + +HRESULT myIDirect3DDevice9::SetTextureStageState(DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value) +{ + return(m_pIDirect3DDevice9->SetTextureStageState(Stage,Type,Value)); +} + +HRESULT myIDirect3DDevice9::GetSamplerState(DWORD Sampler,D3DSAMPLERSTATETYPE Type,DWORD* pValue) +{ + return(m_pIDirect3DDevice9->GetSamplerState(Sampler,Type, pValue)); +} + +HRESULT myIDirect3DDevice9::SetSamplerState(DWORD Sampler,D3DSAMPLERSTATETYPE Type,DWORD Value) +{ + return(m_pIDirect3DDevice9->SetSamplerState(Sampler,Type,Value)); +} + +HRESULT myIDirect3DDevice9::ValidateDevice(DWORD* pNumPasses) +{ + return(m_pIDirect3DDevice9->ValidateDevice( pNumPasses)); +} + +HRESULT myIDirect3DDevice9::SetPaletteEntries(UINT PaletteNumber,CONST PALETTEENTRY* pEntries) +{ + return(m_pIDirect3DDevice9->SetPaletteEntries(PaletteNumber, pEntries)); +} + +HRESULT myIDirect3DDevice9::GetPaletteEntries(UINT PaletteNumber,PALETTEENTRY* pEntries) +{ + return(m_pIDirect3DDevice9->GetPaletteEntries(PaletteNumber, pEntries)); +} + +HRESULT myIDirect3DDevice9::SetCurrentTexturePalette(UINT PaletteNumber) +{ + return(m_pIDirect3DDevice9->SetCurrentTexturePalette(PaletteNumber)); +} + +HRESULT myIDirect3DDevice9::GetCurrentTexturePalette(UINT *PaletteNumber) +{ + return(m_pIDirect3DDevice9->GetCurrentTexturePalette(PaletteNumber)); +} + +HRESULT myIDirect3DDevice9::SetScissorRect(CONST RECT* pRect) +{ + return(m_pIDirect3DDevice9->SetScissorRect( pRect)); +} + +HRESULT myIDirect3DDevice9::GetScissorRect( RECT* pRect) +{ + return(m_pIDirect3DDevice9->GetScissorRect( pRect)); +} + +HRESULT myIDirect3DDevice9::SetSoftwareVertexProcessing(BOOL bSoftware) +{ + return(m_pIDirect3DDevice9->SetSoftwareVertexProcessing(bSoftware)); +} + +BOOL myIDirect3DDevice9::GetSoftwareVertexProcessing(void) +{ + return(m_pIDirect3DDevice9->GetSoftwareVertexProcessing()); +} + +HRESULT myIDirect3DDevice9::SetNPatchMode(float nSegments) +{ + return(m_pIDirect3DDevice9->SetNPatchMode(nSegments)); +} + +float myIDirect3DDevice9::GetNPatchMode(void) +{ + return(m_pIDirect3DDevice9->GetNPatchMode()); +} + +HRESULT myIDirect3DDevice9::DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount) +{ + return(m_pIDirect3DDevice9->DrawPrimitive(PrimitiveType,StartVertex,PrimitiveCount)); +} + +HRESULT myIDirect3DDevice9::DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount) +{ + return(m_pIDirect3DDevice9->DrawIndexedPrimitive(PrimitiveType,BaseVertexIndex,MinVertexIndex,NumVertices,startIndex,primCount)); +} + +HRESULT myIDirect3DDevice9::DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) +{ + return(m_pIDirect3DDevice9->DrawPrimitiveUP(PrimitiveType,PrimitiveCount,pVertexStreamZeroData,VertexStreamZeroStride)); +} + +HRESULT myIDirect3DDevice9::DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertices,UINT PrimitiveCount,CONST void* pIndexData,D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) +{ + return(m_pIDirect3DDevice9->DrawIndexedPrimitiveUP(PrimitiveType,MinVertexIndex,NumVertices,PrimitiveCount, pIndexData, IndexDataFormat, pVertexStreamZeroData,VertexStreamZeroStride)); +} + +HRESULT myIDirect3DDevice9::ProcessVertices(UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer9* pDestBuffer,IDirect3DVertexDeclaration9* pVertexDecl,DWORD Flags) +{ + return(m_pIDirect3DDevice9->ProcessVertices( SrcStartIndex, DestIndex, VertexCount, pDestBuffer, pVertexDecl, Flags)); +} + +HRESULT myIDirect3DDevice9::CreateVertexDeclaration(CONST D3DVERTEXELEMENT9* pVertexElements,IDirect3DVertexDeclaration9** ppDecl) +{ + return(m_pIDirect3DDevice9->CreateVertexDeclaration( pVertexElements,ppDecl)); +} + +HRESULT myIDirect3DDevice9::SetVertexDeclaration(IDirect3DVertexDeclaration9* pDecl) +{ + return(m_pIDirect3DDevice9->SetVertexDeclaration(pDecl)); +} + +HRESULT myIDirect3DDevice9::GetVertexDeclaration(IDirect3DVertexDeclaration9** ppDecl) +{ + return(m_pIDirect3DDevice9->GetVertexDeclaration(ppDecl)); +} + +HRESULT myIDirect3DDevice9::SetFVF(DWORD FVF) +{ + return(m_pIDirect3DDevice9->SetFVF(FVF)); +} + +HRESULT myIDirect3DDevice9::GetFVF(DWORD* pFVF) +{ + return(m_pIDirect3DDevice9->GetFVF(pFVF)); +} + +HRESULT myIDirect3DDevice9::CreateVertexShader(CONST DWORD* pFunction,IDirect3DVertexShader9** ppShader) +{ + return(m_pIDirect3DDevice9->CreateVertexShader(pFunction,ppShader)); +} + +HRESULT myIDirect3DDevice9::SetVertexShader(IDirect3DVertexShader9* pShader) +{ + return(m_pIDirect3DDevice9->SetVertexShader(pShader)); +} + +HRESULT myIDirect3DDevice9::GetVertexShader(IDirect3DVertexShader9** ppShader) +{ + return(m_pIDirect3DDevice9->GetVertexShader(ppShader)); +} + +HRESULT myIDirect3DDevice9::SetVertexShaderConstantF(UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount) +{ + return(m_pIDirect3DDevice9->SetVertexShaderConstantF(StartRegister,pConstantData, Vector4fCount)); +} + +HRESULT myIDirect3DDevice9::GetVertexShaderConstantF(UINT StartRegister,float* pConstantData,UINT Vector4fCount) +{ + return(m_pIDirect3DDevice9->GetVertexShaderConstantF(StartRegister,pConstantData,Vector4fCount)); +} + +HRESULT myIDirect3DDevice9::SetVertexShaderConstantI(UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount) +{ + return(m_pIDirect3DDevice9->SetVertexShaderConstantI(StartRegister,pConstantData,Vector4iCount)); +} + +HRESULT myIDirect3DDevice9::GetVertexShaderConstantI(UINT StartRegister,int* pConstantData,UINT Vector4iCount) +{ + return(m_pIDirect3DDevice9->GetVertexShaderConstantI(StartRegister,pConstantData,Vector4iCount)); +} + +HRESULT myIDirect3DDevice9::SetVertexShaderConstantB(UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount) +{ + return(m_pIDirect3DDevice9->SetVertexShaderConstantB(StartRegister,pConstantData,BoolCount)); +} + +HRESULT myIDirect3DDevice9::GetVertexShaderConstantB(UINT StartRegister,BOOL* pConstantData,UINT BoolCount) +{ + return(m_pIDirect3DDevice9->GetVertexShaderConstantB(StartRegister,pConstantData,BoolCount)); +} + +HRESULT myIDirect3DDevice9::SetStreamSource(UINT StreamNumber,IDirect3DVertexBuffer9* pStreamData,UINT OffsetInBytes,UINT Stride) +{ + return(m_pIDirect3DDevice9->SetStreamSource(StreamNumber,pStreamData,OffsetInBytes,Stride)); +} + +HRESULT myIDirect3DDevice9::GetStreamSource(UINT StreamNumber,IDirect3DVertexBuffer9** ppStreamData,UINT* OffsetInBytes,UINT* pStride) +{ + return(m_pIDirect3DDevice9->GetStreamSource(StreamNumber,ppStreamData,OffsetInBytes,pStride)); +} + +HRESULT myIDirect3DDevice9::SetStreamSourceFreq(UINT StreamNumber,UINT Divider) +{ + return(m_pIDirect3DDevice9->SetStreamSourceFreq(StreamNumber,Divider)); +} + +HRESULT myIDirect3DDevice9::GetStreamSourceFreq(UINT StreamNumber,UINT* Divider) +{ + return(m_pIDirect3DDevice9->GetStreamSourceFreq(StreamNumber,Divider)); +} + +HRESULT myIDirect3DDevice9::SetIndices(IDirect3DIndexBuffer9* pIndexData) +{ + return(m_pIDirect3DDevice9->SetIndices(pIndexData)); +} + +HRESULT myIDirect3DDevice9::GetIndices(IDirect3DIndexBuffer9** ppIndexData) +{ + return(m_pIDirect3DDevice9->GetIndices(ppIndexData)); +} + +HRESULT myIDirect3DDevice9::CreatePixelShader(CONST DWORD* pFunction,IDirect3DPixelShader9** ppShader) +{ + return(m_pIDirect3DDevice9->CreatePixelShader(pFunction,ppShader)); +} + +HRESULT myIDirect3DDevice9::SetPixelShader(IDirect3DPixelShader9* pShader) +{ + return(m_pIDirect3DDevice9->SetPixelShader(pShader)); +} + +HRESULT myIDirect3DDevice9::GetPixelShader(IDirect3DPixelShader9** ppShader) +{ + return(m_pIDirect3DDevice9->GetPixelShader(ppShader)); +} + +HRESULT myIDirect3DDevice9::SetPixelShaderConstantF(UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount) +{ + return(m_pIDirect3DDevice9->SetPixelShaderConstantF(StartRegister,pConstantData,Vector4fCount)); +} + +HRESULT myIDirect3DDevice9::GetPixelShaderConstantF(UINT StartRegister,float* pConstantData,UINT Vector4fCount) +{ + return(m_pIDirect3DDevice9->GetPixelShaderConstantF(StartRegister,pConstantData,Vector4fCount)); +} + +HRESULT myIDirect3DDevice9::SetPixelShaderConstantI(UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount) +{ + return(m_pIDirect3DDevice9->SetPixelShaderConstantI(StartRegister,pConstantData,Vector4iCount)); +} + +HRESULT myIDirect3DDevice9::GetPixelShaderConstantI(UINT StartRegister,int* pConstantData,UINT Vector4iCount) +{ + return(m_pIDirect3DDevice9->GetPixelShaderConstantI(StartRegister,pConstantData,Vector4iCount)); +} + +HRESULT myIDirect3DDevice9::SetPixelShaderConstantB(UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount) +{ + return(m_pIDirect3DDevice9->SetPixelShaderConstantB(StartRegister,pConstantData,BoolCount)); +} + +HRESULT myIDirect3DDevice9::GetPixelShaderConstantB(UINT StartRegister,BOOL* pConstantData,UINT BoolCount) +{ + return(m_pIDirect3DDevice9->GetPixelShaderConstantB(StartRegister,pConstantData,BoolCount)); +} + +HRESULT myIDirect3DDevice9::DrawRectPatch(UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo) +{ + return(m_pIDirect3DDevice9->DrawRectPatch(Handle,pNumSegs, pRectPatchInfo)); +} + +HRESULT myIDirect3DDevice9::DrawTriPatch(UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo) +{ + return(m_pIDirect3DDevice9->DrawTriPatch(Handle, pNumSegs, pTriPatchInfo)); +} + +HRESULT myIDirect3DDevice9::DeletePatch(UINT Handle) +{ + return(m_pIDirect3DDevice9->DeletePatch(Handle)); +} + +HRESULT myIDirect3DDevice9::CreateQuery(D3DQUERYTYPE Type,IDirect3DQuery9** ppQuery) +{ + return(m_pIDirect3DDevice9->CreateQuery(Type,ppQuery)); +} + diff --git a/proxy_dll/myIDirect3DDevice9.h b/proxy_dll/myIDirect3DDevice9.h new file mode 100644 index 0000000..534925f --- /dev/null +++ b/proxy_dll/myIDirect3DDevice9.h @@ -0,0 +1,133 @@ +#pragma once + +class myIDirect3DDevice9 : public IDirect3DDevice9 +{ +public: + myIDirect3DDevice9(IDirect3DDevice9* pOriginal); + virtual ~myIDirect3DDevice9(void); + + // START: The original DX9 function definitions + HRESULT __stdcall QueryInterface (REFIID riid, void** ppvObj); + ULONG __stdcall AddRef(void); + ULONG __stdcall Release(void); + HRESULT __stdcall TestCooperativeLevel(void); + UINT __stdcall GetAvailableTextureMem(void); + HRESULT __stdcall EvictManagedResources(void); + HRESULT __stdcall GetDirect3D(IDirect3D9** ppD3D9); + HRESULT __stdcall GetDeviceCaps(D3DCAPS9* pCaps); + HRESULT __stdcall GetDisplayMode(UINT iSwapChain,D3DDISPLAYMODE* pMode); + HRESULT __stdcall GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS *pParameters); + HRESULT __stdcall SetCursorProperties(UINT XHotSpot,UINT YHotSpot,IDirect3DSurface9* pCursorBitmap); + void __stdcall SetCursorPosition(int X,int Y,DWORD Flags); + BOOL __stdcall ShowCursor(BOOL bShow); + HRESULT __stdcall CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DSwapChain9** pSwapChain) ; + HRESULT __stdcall GetSwapChain(UINT iSwapChain,IDirect3DSwapChain9** pSwapChain); + UINT __stdcall GetNumberOfSwapChains(void); + HRESULT __stdcall Reset(D3DPRESENT_PARAMETERS* pPresentationParameters); + HRESULT __stdcall Present(CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion); + HRESULT __stdcall GetBackBuffer(UINT iSwapChain,UINT iBackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface9** ppBackBuffer); + HRESULT __stdcall GetRasterStatus(UINT iSwapChain,D3DRASTER_STATUS* pRasterStatus); + HRESULT __stdcall SetDialogBoxMode(BOOL bEnableDialogs); + void __stdcall SetGammaRamp(UINT iSwapChain,DWORD Flags,CONST D3DGAMMARAMP* pRamp); + void __stdcall GetGammaRamp(UINT iSwapChain,D3DGAMMARAMP* pRamp); + HRESULT __stdcall CreateTexture(UINT Width,UINT Height,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DTexture9** ppTexture,HANDLE* pSharedHandle); + HRESULT __stdcall CreateVolumeTexture(UINT Width,UINT Height,UINT Depth,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DVolumeTexture9** ppVolumeTexture,HANDLE* pSharedHandle); + HRESULT __stdcall CreateCubeTexture(UINT EdgeLength,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DCubeTexture9** ppCubeTexture,HANDLE* pSharedHandle); + HRESULT __stdcall CreateVertexBuffer(UINT Length,DWORD Usage,DWORD FVF,D3DPOOL Pool,IDirect3DVertexBuffer9** ppVertexBuffer,HANDLE* pSharedHandle); + HRESULT __stdcall CreateIndexBuffer(UINT Length,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DIndexBuffer9** ppIndexBuffer,HANDLE* pSharedHandle); + HRESULT __stdcall CreateRenderTarget(UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Lockable,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle); + HRESULT __stdcall CreateDepthStencilSurface(UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Discard,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle); + HRESULT __stdcall UpdateSurface(IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect,IDirect3DSurface9* pDestinationSurface,CONST POINT* pDestPoint); + HRESULT __stdcall UpdateTexture(IDirect3DBaseTexture9* pSourceTexture,IDirect3DBaseTexture9* pDestinationTexture); + HRESULT __stdcall GetRenderTargetData(IDirect3DSurface9* pRenderTarget,IDirect3DSurface9* pDestSurface); + HRESULT __stdcall GetFrontBufferData(UINT iSwapChain,IDirect3DSurface9* pDestSurface); + HRESULT __stdcall StretchRect(IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect,IDirect3DSurface9* pDestSurface,CONST RECT* pDestRect,D3DTEXTUREFILTERTYPE Filter); + HRESULT __stdcall ColorFill(IDirect3DSurface9* pSurface,CONST RECT* pRect,D3DCOLOR color); + HRESULT __stdcall CreateOffscreenPlainSurface(UINT Width,UINT Height,D3DFORMAT Format,D3DPOOL Pool,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle); + HRESULT __stdcall SetRenderTarget(DWORD RenderTargetIndex,IDirect3DSurface9* pRenderTarget); + HRESULT __stdcall GetRenderTarget(DWORD RenderTargetIndex,IDirect3DSurface9** ppRenderTarget); + HRESULT __stdcall SetDepthStencilSurface(IDirect3DSurface9* pNewZStencil); + HRESULT __stdcall GetDepthStencilSurface(IDirect3DSurface9** ppZStencilSurface); + HRESULT __stdcall BeginScene(void); + HRESULT __stdcall EndScene(void); + HRESULT __stdcall Clear(DWORD Count,CONST D3DRECT* pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil); + HRESULT __stdcall SetTransform(D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix); + HRESULT __stdcall GetTransform(D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix); + HRESULT __stdcall MultiplyTransform(D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix); + HRESULT __stdcall SetViewport(CONST D3DVIEWPORT9* pViewport); + HRESULT __stdcall GetViewport(D3DVIEWPORT9* pViewport); + HRESULT __stdcall SetMaterial(CONST D3DMATERIAL9* pMaterial); + HRESULT __stdcall GetMaterial(D3DMATERIAL9* pMaterial); + HRESULT __stdcall SetLight(DWORD Index,CONST D3DLIGHT9* pLight); + HRESULT __stdcall GetLight(DWORD Index,D3DLIGHT9* pLight); + HRESULT __stdcall LightEnable(DWORD Index,BOOL Enable); + HRESULT __stdcall GetLightEnable(DWORD Index,BOOL* pEnable); + HRESULT __stdcall SetClipPlane(DWORD Index,CONST float* pPlane); + HRESULT __stdcall GetClipPlane(DWORD Index,float* pPlane); + HRESULT __stdcall SetRenderState(D3DRENDERSTATETYPE State,DWORD Value); + HRESULT __stdcall GetRenderState(D3DRENDERSTATETYPE State,DWORD* pValue); + HRESULT __stdcall CreateStateBlock(D3DSTATEBLOCKTYPE Type,IDirect3DStateBlock9** ppSB); + HRESULT __stdcall BeginStateBlock(void); + HRESULT __stdcall EndStateBlock(IDirect3DStateBlock9** ppSB); + HRESULT __stdcall SetClipStatus(CONST D3DCLIPSTATUS9* pClipStatus); + HRESULT __stdcall GetClipStatus(D3DCLIPSTATUS9* pClipStatus); + HRESULT __stdcall GetTexture(DWORD Stage,IDirect3DBaseTexture9** ppTexture); + HRESULT __stdcall SetTexture(DWORD Stage,IDirect3DBaseTexture9* pTexture); + HRESULT __stdcall GetTextureStageState(DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue); + HRESULT __stdcall SetTextureStageState(DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value); + HRESULT __stdcall GetSamplerState(DWORD Sampler,D3DSAMPLERSTATETYPE Type,DWORD* pValue); + HRESULT __stdcall SetSamplerState(DWORD Sampler,D3DSAMPLERSTATETYPE Type,DWORD Value); + HRESULT __stdcall ValidateDevice(DWORD* pNumPasses); + HRESULT __stdcall SetPaletteEntries(UINT PaletteNumber,CONST PALETTEENTRY* pEntries); + HRESULT __stdcall GetPaletteEntries(UINT PaletteNumber,PALETTEENTRY* pEntries); + HRESULT __stdcall SetCurrentTexturePalette(UINT PaletteNumber); + HRESULT __stdcall GetCurrentTexturePalette(UINT *PaletteNumber); + HRESULT __stdcall SetScissorRect(CONST RECT* pRect); + HRESULT __stdcall GetScissorRect( RECT* pRect); + HRESULT __stdcall SetSoftwareVertexProcessing(BOOL bSoftware); + BOOL __stdcall GetSoftwareVertexProcessing(void); + HRESULT __stdcall SetNPatchMode(float nSegments); + float __stdcall GetNPatchMode(void); + HRESULT __stdcall DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount); + HRESULT __stdcall DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount); + HRESULT __stdcall DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride); + HRESULT __stdcall DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertices,UINT PrimitiveCount,CONST void* pIndexData,D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride); + HRESULT __stdcall ProcessVertices(UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer9* pDestBuffer,IDirect3DVertexDeclaration9* pVertexDecl,DWORD Flags); + HRESULT __stdcall CreateVertexDeclaration(CONST D3DVERTEXELEMENT9* pVertexElements,IDirect3DVertexDeclaration9** ppDecl); + HRESULT __stdcall SetVertexDeclaration(IDirect3DVertexDeclaration9* pDecl); + HRESULT __stdcall GetVertexDeclaration(IDirect3DVertexDeclaration9** ppDecl); + HRESULT __stdcall SetFVF(DWORD FVF); + HRESULT __stdcall GetFVF(DWORD* pFVF); + HRESULT __stdcall CreateVertexShader(CONST DWORD* pFunction,IDirect3DVertexShader9** ppShader); + HRESULT __stdcall SetVertexShader(IDirect3DVertexShader9* pShader); + HRESULT __stdcall GetVertexShader(IDirect3DVertexShader9** ppShader); + HRESULT __stdcall SetVertexShaderConstantF(UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount); + HRESULT __stdcall GetVertexShaderConstantF(UINT StartRegister,float* pConstantData,UINT Vector4fCount); + HRESULT __stdcall SetVertexShaderConstantI(UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount); + HRESULT __stdcall GetVertexShaderConstantI(UINT StartRegister,int* pConstantData,UINT Vector4iCount); + HRESULT __stdcall SetVertexShaderConstantB(UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount); + HRESULT __stdcall GetVertexShaderConstantB(UINT StartRegister,BOOL* pConstantData,UINT BoolCount); + HRESULT __stdcall SetStreamSource(UINT StreamNumber,IDirect3DVertexBuffer9* pStreamData,UINT OffsetInBytes,UINT Stride); + HRESULT __stdcall GetStreamSource(UINT StreamNumber,IDirect3DVertexBuffer9** ppStreamData,UINT* OffsetInBytes,UINT* pStride); + HRESULT __stdcall SetStreamSourceFreq(UINT StreamNumber,UINT Divider); + HRESULT __stdcall GetStreamSourceFreq(UINT StreamNumber,UINT* Divider); + HRESULT __stdcall SetIndices(IDirect3DIndexBuffer9* pIndexData); + HRESULT __stdcall GetIndices(IDirect3DIndexBuffer9** ppIndexData); + HRESULT __stdcall CreatePixelShader(CONST DWORD* pFunction,IDirect3DPixelShader9** ppShader); + HRESULT __stdcall SetPixelShader(IDirect3DPixelShader9* pShader); + HRESULT __stdcall GetPixelShader(IDirect3DPixelShader9** ppShader); + HRESULT __stdcall SetPixelShaderConstantF(UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount); + HRESULT __stdcall GetPixelShaderConstantF(UINT StartRegister,float* pConstantData,UINT Vector4fCount); + HRESULT __stdcall SetPixelShaderConstantI(UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount); + HRESULT __stdcall GetPixelShaderConstantI(UINT StartRegister,int* pConstantData,UINT Vector4iCount); + HRESULT __stdcall SetPixelShaderConstantB(UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount); + HRESULT __stdcall GetPixelShaderConstantB(UINT StartRegister,BOOL* pConstantData,UINT BoolCount); + HRESULT __stdcall DrawRectPatch(UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo); + HRESULT __stdcall DrawTriPatch(UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo); + HRESULT __stdcall DeletePatch(UINT Handle); + HRESULT __stdcall CreateQuery(D3DQUERYTYPE Type,IDirect3DQuery9** ppQuery); + // END: The original DX9 function definitions + +private: + IDirect3DDevice9 *m_pIDirect3DDevice9; +}; diff --git a/proxy_dll/myIDirect3DSwapChain9.cpp b/proxy_dll/myIDirect3DSwapChain9.cpp new file mode 100644 index 0000000..665c10c --- /dev/null +++ b/proxy_dll/myIDirect3DSwapChain9.cpp @@ -0,0 +1,102 @@ +#include "StdAfx.h" + +myIDirect3DSwapChain9::myIDirect3DSwapChain9(IDirect3DSwapChain9* pOriginal, IDirect3DDevice9* pDevice) +{ + m_pIDirect3DSwapChain9 = pOriginal; // store the pointer to original object + m_pIDirect3DDevice9 = pDevice; +} + +myIDirect3DSwapChain9::~myIDirect3DSwapChain9(void) +{ + m_pIDirect3DSwapChain9 = NULL; +} + +HRESULT myIDirect3DSwapChain9::QueryInterface (REFIID riid, void** ppvObj) +{ + // check if original dll can provide interface. then send *our* address + *ppvObj = NULL; + + HRESULT hRes = m_pIDirect3DSwapChain9->QueryInterface(riid, ppvObj); + + if (hRes == NOERROR) + { + *ppvObj = this; + } + + return hRes; +} + +ULONG myIDirect3DSwapChain9::AddRef(void) +{ + return(m_pIDirect3DSwapChain9->AddRef()); +} + +ULONG myIDirect3DSwapChain9::Release(void) +{ + // ATTENTION: This is a booby-trap ! Watch out ! + // If we create our own sprites, surfaces, etc. (thus increasing the ref counter + // by external action), we need to delete that objects before calling the original + // Release function + + // global var + extern myIDirect3DSwapChain9* gl_pmyIDirect3DSwapChain9; + + // release/delete own objects + // ..... + + // Calling original function now + ULONG count = m_pIDirect3DSwapChain9->Release(); + + if (count==0) + { + // now, the Original Object has deleted itself, so do we here + gl_pmyIDirect3DSwapChain9 = NULL; + delete(this); // destructor will be called automatically + } + + return (count); +} + +HRESULT myIDirect3DSwapChain9::Present(CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion,DWORD dwFlags) +{ + // Some games use this one for presenting. They ignore the Device's Present routine + + // we may want to draw own things here before flipping surfaces + // ... we would draw own stuff here, but I don't think rF uses this D3D feature ... + + // call original routine + HRESULT hres = m_pIDirect3DSwapChain9->Present(pSourceRect,pDestRect,hDestWindowOverride,pDirtyRegion,dwFlags); + + return (hres); +} + +HRESULT myIDirect3DSwapChain9::GetFrontBufferData(IDirect3DSurface9* pDestSurface) +{ + return(m_pIDirect3DSwapChain9->GetFrontBufferData(pDestSurface)); +} + +HRESULT myIDirect3DSwapChain9::GetBackBuffer(UINT iBackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface9** ppBackBuffer) +{ + return(m_pIDirect3DSwapChain9->GetBackBuffer(iBackBuffer,Type,ppBackBuffer)); +} + +HRESULT myIDirect3DSwapChain9::GetRasterStatus(D3DRASTER_STATUS* pRasterStatus) +{ + return(m_pIDirect3DSwapChain9->GetRasterStatus(pRasterStatus)); +} + +HRESULT myIDirect3DSwapChain9::GetDisplayMode(D3DDISPLAYMODE* pMode) +{ + return(m_pIDirect3DSwapChain9->GetDisplayMode(pMode)); +} + +HRESULT myIDirect3DSwapChain9::GetDevice(IDirect3DDevice9** ppDevice) +{ + return(m_pIDirect3DSwapChain9->GetDevice(ppDevice)); +} + +HRESULT myIDirect3DSwapChain9::GetPresentParameters(D3DPRESENT_PARAMETERS* pPresentationParameters) +{ + return(m_pIDirect3DSwapChain9->GetPresentParameters(pPresentationParameters)); +} + diff --git a/proxy_dll/myIDirect3DSwapChain9.h b/proxy_dll/myIDirect3DSwapChain9.h new file mode 100644 index 0000000..8765633 --- /dev/null +++ b/proxy_dll/myIDirect3DSwapChain9.h @@ -0,0 +1,25 @@ +#pragma once + +class myIDirect3DSwapChain9 : public IDirect3DSwapChain9 +{ +public: + myIDirect3DSwapChain9(IDirect3DSwapChain9* pOriginal, IDirect3DDevice9* pDevice); + virtual ~myIDirect3DSwapChain9(void); + + // START: The original DX9 function definitions + HRESULT __stdcall QueryInterface (REFIID riid, void** ppvObj); + ULONG __stdcall AddRef(void); + ULONG __stdcall Release(void); + HRESULT __stdcall Present(CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion,DWORD dwFlags); + HRESULT __stdcall GetFrontBufferData(IDirect3DSurface9* pDestSurface); + HRESULT __stdcall GetBackBuffer(UINT iBackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface9** ppBackBuffer); + HRESULT __stdcall GetRasterStatus(D3DRASTER_STATUS* pRasterStatus); + HRESULT __stdcall GetDisplayMode(D3DDISPLAYMODE* pMode); + HRESULT __stdcall GetDevice(IDirect3DDevice9** ppDevice); + HRESULT __stdcall GetPresentParameters(D3DPRESENT_PARAMETERS* pPresentationParameters); + // END: The original DX9 function definitions + +private: + IDirect3DSwapChain9 *m_pIDirect3DSwapChain9; + IDirect3DDevice9 *m_pIDirect3DDevice9; +}; diff --git a/proxy_dll/proxydll.cpp b/proxy_dll/proxydll.cpp new file mode 100644 index 0000000..33eb5ab --- /dev/null +++ b/proxy_dll/proxydll.cpp @@ -0,0 +1,197 @@ +// proxydll.cpp +#include "stdafx.h" +#include "proxydll.h" + +#include +#include +using namespace std ; + +// Handles to the various plugin's functions +vector g_plugin_dlls ; +vector g_init_callbacks ; +vector g_release_callbacks ; +vector g_endscene_callbacks ; +vector g_present_callbacks ; + +// global variables +myIDirect3DSwapChain9* gl_pmyIDirect3DSwapChain9; +myIDirect3DDevice9* gl_pmyIDirect3DDevice9; +myIDirect3D9* gl_pmyIDirect3D9; +HINSTANCE gl_hOriginalDll; +HINSTANCE gl_hThisInstance; + +BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) +{ + // to avoid compiler lvl4 warnings + LPVOID lpDummy = lpReserved; + lpDummy = NULL; + + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: InitInstance(hModule); break; + case DLL_PROCESS_DETACH: ExitInstance(); break; + + case DLL_THREAD_ATTACH: break; + case DLL_THREAD_DETACH: break; + } + return TRUE; +} + +// Exported function (faking d3d9.dll's one-and-only export) +IDirect3D9* WINAPI Direct3DCreate9(UINT SDKVersion) +{ + if (!gl_hOriginalDll) + { + LoadOriginalDll(); // looking for the "right d3d9.dll" + } + + // Hooking IDirect3D Object from Original Library + typedef IDirect3D9 *(WINAPI* D3D9_Type)(UINT SDKVersion); + D3D9_Type D3DCreate9_fn = (D3D9_Type) GetProcAddress( gl_hOriginalDll, "Direct3DCreate9"); + + // Debug + if (!D3DCreate9_fn) + { + OutputDebugString("PROXYDLL: Pointer to original D3DCreate9 function not received ERROR ****\r\n"); + ::ExitProcess(0); // exit the hard way + } + + // Request pointer from Original Dll. + IDirect3D9 *pIDirect3D9_orig = D3DCreate9_fn(SDKVersion); + + // Create my IDirect3D8 object and store pointer to original object there. + // note: the object will delete itself once Ref count is zero (similar to COM objects) + gl_pmyIDirect3D9 = new myIDirect3D9(pIDirect3D9_orig); + + // Return pointer to hooking Object instead of "real one" + return (gl_pmyIDirect3D9); +} + +void InitInstance(HANDLE hModule) +{ + OutputDebugString("PROXYDLL: InitInstance called.\r\n"); + + // Initialisation + gl_hOriginalDll = NULL; + gl_hThisInstance = NULL; + gl_pmyIDirect3D9 = NULL; + gl_pmyIDirect3DDevice9 = NULL; + gl_pmyIDirect3DSwapChain9 = NULL; + + // Storing Instance handle into global var + gl_hThisInstance = (HINSTANCE) hModule; + + // Scan for any rendering plugin dlls + LoadPluginDlls() ; +} + +void LoadOriginalDll(void) +{ + char buffer[MAX_PATH]; + + // Getting path to system dir and to d3d8.dll + ::GetSystemDirectory(buffer,MAX_PATH); + + // Append dll name + strcat(buffer,"\\d3d9.dll"); + + // try to load the system's d3d9.dll, if pointer empty + if (!gl_hOriginalDll) + { + gl_hOriginalDll = ::LoadLibrary(buffer); + } + + // Debug + if (!gl_hOriginalDll) + { + OutputDebugString("PROXYDLL: Original d3d9.dll not loaded ERROR ****\r\n"); + ::ExitProcess(0); // exit the hard way + } +} + + +static void RegisterPluginDLL( const char *dll_filename ) +{ + HINSTANCE plugin_dll = ::LoadLibrary( dll_filename ); + if ( plugin_dll ) + { + BOOL_FN_T dll_wants_d3d_updates = (BOOL_FN_T) GetProcAddress( plugin_dll, "WantsD3D9Updates" ); + if ( dll_wants_d3d_updates && dll_wants_d3d_updates() ) + { + g_plugin_dlls.push_back( plugin_dll ) ; + + D3D9_CALLBACK_T plugin_callback ; + plugin_callback = (D3D9_CALLBACK_T) ::GetProcAddress( plugin_dll, "Init" ); + if ( plugin_callback ) + { + g_init_callbacks.push_back( plugin_callback ) ; + } + + plugin_callback = (D3D9_CALLBACK_T) ::GetProcAddress( plugin_dll, "Release" ); + if ( plugin_callback ) + { + g_release_callbacks.push_back( plugin_callback ) ; + } + + plugin_callback = (D3D9_CALLBACK_T) ::GetProcAddress( plugin_dll, "EndScene" ); + if ( plugin_callback ) + { + g_endscene_callbacks.push_back( plugin_callback ) ; + } + + plugin_callback = (D3D9_CALLBACK_T) ::GetProcAddress( plugin_dll, "Present" ); + if ( plugin_callback ) + { + g_present_callbacks.push_back( plugin_callback ) ; + } + } + else + { + ::FreeLibrary( plugin_dll ) ; + } + } +} + +void LoadPluginDlls(void) +{ + struct _finddata_t c_file; + long hFile; + string plugin_path ; + + if ( ( hFile = _findfirst("Plugins\\*.dll", &c_file) ) != -1L ) + { + do + { + plugin_path = "Plugins\\" ; + plugin_path.append( c_file.name ) ; + RegisterPluginDLL( plugin_path.c_str() ); + } while ( _findnext(hFile, &c_file) == 0 ) ; + + _findclose( hFile ) ; + } +} + +void ExitInstance() +{ + OutputDebugString("PROXYDLL: ExitInstance called.\r\n"); + + // Release the system's d3d9.dll + if (gl_hOriginalDll) + { + ::FreeLibrary(gl_hOriginalDll); + gl_hOriginalDll = NULL; + } + + g_init_callbacks.clear() ; + g_release_callbacks.clear() ; + g_endscene_callbacks.clear() ; + g_present_callbacks.clear() ; + + vector::const_iterator dll_iterator; + for ( dll_iterator = g_plugin_dlls.begin(); dll_iterator != g_plugin_dlls.end(); dll_iterator++ ) + { + ::FreeLibrary( *dll_iterator ) ; + } + g_plugin_dlls.clear() ; +} + diff --git a/proxy_dll/proxydll.h b/proxy_dll/proxydll.h new file mode 100644 index 0000000..0566bd8 --- /dev/null +++ b/proxy_dll/proxydll.h @@ -0,0 +1,20 @@ +// proxydll.h +#pragma once + +// Exported function +IDirect3D9* WINAPI Direct3DCreate9 (UINT SDKVersion); + +// regular functions +void InitInstance(HANDLE hModule); +void ExitInstance(void); +void LoadOriginalDll(void); +void LoadPluginDlls(void); + +typedef bool (__cdecl *BOOL_FN_T)( void ); +typedef void (__cdecl *D3D9_CALLBACK_T)( IDirect3DDevice9 * ); + +extern std::vector g_init_callbacks ; +extern std::vector g_release_callbacks ; +extern std::vector g_endscene_callbacks ; +extern std::vector g_present_callbacks ; + diff --git a/proxy_dll/proxydll.sln b/proxy_dll/proxydll.sln new file mode 100644 index 0000000..08379d4 --- /dev/null +++ b/proxy_dll/proxydll.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual C++ Express 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "proxydll", "proxydll.vcproj", "{02EB97D5-B1C5-411E-8274-83A95985DE6F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {02EB97D5-B1C5-411E-8274-83A95985DE6F}.Debug|Win32.ActiveCfg = Debug|Win32 + {02EB97D5-B1C5-411E-8274-83A95985DE6F}.Debug|Win32.Build.0 = Debug|Win32 + {02EB97D5-B1C5-411E-8274-83A95985DE6F}.Release|Win32.ActiveCfg = Release|Win32 + {02EB97D5-B1C5-411E-8274-83A95985DE6F}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/proxy_dll/stdafx.cpp b/proxy_dll/stdafx.cpp new file mode 100644 index 0000000..2a015f2 --- /dev/null +++ b/proxy_dll/stdafx.cpp @@ -0,0 +1,2 @@ +// stdafx.cpp +#include "stdafx.h" \ No newline at end of file diff --git a/proxy_dll/stdafx.h b/proxy_dll/stdafx.h new file mode 100644 index 0000000..a8a0340 --- /dev/null +++ b/proxy_dll/stdafx.h @@ -0,0 +1,11 @@ +// stdafx.h +#pragma once + +#define WIN32_LEAN_AND_MEAN +#include +#include + +#include "d3d9.h" +#include "myIDirect3D9.h" +#include "myIDirect3DDevice9.h" +#include "myIDirect3DSwapChain9.h"