Namespace: d3d8

The d3d8 namespace contains functions that implement the IDirect3D8 interface from the Direct3D SDK. These functions are adjusted to specifically work with the current IDirect3D8 interface of the game client. Meaning, you do not need to pass the pointer to the device for these calls.

Due to Lua limitations with variables passed as references or pointers, things are handled a little differently for some of these functions. These try to closely match the Direct3D interface from C as close as possible to it is easy to understand. If a function expects a parameter that would normally hold a result, it is instead returned as an additional return value. For example:

-- In C++
D3DDISPLAYMODE mode; 
auto hres = g_Direct3D8->GetAdapterDisplayMode(0, &mode);

-- In Lua
local hres, mode = ashita.d3d8.GetAdapterDisplayMode(0);

Some functions are not implemented as well due to limitations with how the API can interact with the game client. For example, IDirect3D8::CreateDevice is not implemented because it is not possible to use another device with FFXI.

You can access this namespace via:

ashita.d3d8.

Below are the functions available in this namespace.


IDirect3D8 Interface Functions

QueryInterface

Determines whether the object supports a particular COM interface.

function ashita.d3d8.QueryInterface(iid);
  • Parameters
    • iid - (string) The iid to query for.
  • Returns
    • number - The HRESULT of the call.
    • object|nil - The queried object on success, nil otherwise.

AddRef

Increases the reference count of the object by 1.

function ashita.d3d8.AddRef(); -- Uses the IDirect3D8 interface directly.
function ashita.d3d8.AddRef(parent); -- Uses the given parent object.
  • Parameters
    • parent - (object) The parent object. (If using override implementation.)
  • Returns
    • number - The reference count of the object.

Release

Decreases the reference count of the object by 1.

function ashita.d3d8.Release(); -- Uses the IDirect3D8 interface directly.
function ashita.d3d8.Release(parent); -- Uses the given parent object.
  • Parameters
    • parent - (object) The parent object. (If using override implementation.)
  • Returns
    • number - The reference count of the object.

GetAdapterCount

Returns the number of adapters on the system.

function ashita.d3d8.GetAdapterCount();
  • Parameters
    • None.
  • Returns
    • number - The number of adapters present.

GetAdapterIdentifier

Describes the physical display adapters present in the system when the IDirect3D8 interface was instantiated.

function ashita.d3d8.GetAdapterIdentifier(adapter, flags);
  • Parameters
    • adapter - (number) The adapter number to identify.
    • flags - (number) The flags to use while identifying.
  • Returns
    • number - The HRESULT of the call.
    • object|nil - The D3DADAPTER_IDENTIFIER8 structure of the adapter on success, nil otherwise.

GetAdapterModeCount

Returns the number of display modes available on this adapter.

function ashita.d3d8.GetAdapterModeCount(adapter);
  • Parameters
    • adapter - (number) The adapter number.
  • Returns
    • number - The mode count of the adapter.

EnumAdapterModes

Enumerates the display modes of an adapter.

function ashita.d3d8.EnumAdapterModes(adapter, mode);
  • Parameters
    • adapter - (number) The adapter number.
    • mode - (number) The current mode to enumerate.
  • Returns
    • number - The HRESULT of the call.
    • object|nil - The D3DDISPLAYMODE structure of the mode on success, nil otherwise.

GetAdapterDisplayMode

Retrieves the current display mode of the adapter.

function ashita.d3d8.GetAdapterDisplayMode(adapter);
  • Parameters
    • adapter - (number) The adapter number.
  • Returns
    • number - The HRESULT of the call.
    • object|nil - The D3DDISPLAYMODE structure of the mode on success, nil otherwise.

CheckDeviceType

Verifies whether or not a certain device type can be used on this adapter and expect hardware acceleration using the given formats.

function ashita.d3d8.CheckDeviceType(adapter, checkType, displayFormat, backBufferFormat, windowed);
  • Parameters
    • adapter - (number) The adapter number.
    • checkType - (number) The device type to check.
    • displayFormat - (number) The display format to check.
    • backBufferFormat - (number) The back buffer format to check.
    • windowed - (bool) The windowed flag to check with.
  • Returns
    • number - The HRESULT of the call.

CheckDeviceFormat

Determines whether a surface format is available as a specified resource type and can be used as a texture, depth-stencil buffer, or render target, or any combination of the three, on a device representing this adapter.

function ashita.d3d8.CheckDeviceFormat(adapter, deviceType, adapterFormat, usage, rtype, checkFormat);
  • Parameters
    • adapter - (number) The adapter number.
    • deviceType - (number) The device type to check.
    • adapterFormat - (number) The adapter format to check.
    • usage - (number) The usage flags to check against.
    • rtype - (number) The resource type to check against.
    • checkFormat - (number) The surface format to check against.
  • Returns
    • number - The HRESULT of the call.

CheckDeviceMultiSampleType

Determines if a multisampling technique is available on this device.

function ashita.d3d8.CheckDeviceMultiSampleType(adapter, deviceType, surfaceFormat, windowed, multiSampleType);
  • Parameters
    • adapter - (number) The adapter number.
    • deviceType - (number) The device type to check.
    • surfaceFormat - (number) The surface format to check.
    • windowed - (bool) The windowed flag to check with.
    • multiSampleType - (number) The multisample type to check.
  • Returns
    • number - The HRESULT of the call.

CheckDepthStencilMatch

Determines whether or not a depth-stencil format is compatible with a render target format in a particular display mode.

function ashita.d3d8.CheckDepthStencilMatch(adapter, deviceType, adapterFormat, renderTargetFormat, depthStencilFormat);
  • Parameters
    • adapter - (number) The adapter number.
    • deviceType - (number) The device type to check.
    • adapterFormat - (number) The adapter format to check.
    • renderTargetFormat - (number) The render target format to check.
    • depthStencilFormat - (number) The depth stencil format to check.
  • Returns
    • number - The HRESULT of the call.

GetDeviceCaps

Retrieves device-specific information about a device.

function ashita.d3d8.GetDeviceCaps(adapter, deviceType);
  • Parameters
    • adapter - (number) The adapter number.
    • deviceType - (number) The device type to check.
  • Returns
    • number - The HRESULT of the call.
    • object|nil - The D3DCAPS8 structure of the device on success, nil otherwise.

GetAdapterMonitor

Returns the handle of the monitor associated with the Microsoft® Direct3D® object.

function ashita.d3d8.GetAdapterMonitor(adapter);
  • Parameters
    • adapter - (number) The adapter number.
    • deviceType - (number) The device type to check.
  • Returns
    • number - The monitor handle on success, HRESULT error otherwise.