Interface

Introduction

The following categories represent the GFX interface in TorqueScript.

Core Global Variables

default values

  • $pref::Video::displayDevice = “D3D9”;
    • User’s preference for device
  • $pref::Video::disableVerticalSync = 1;
    • Toggles adapter to wait for vsync
  • $pref::Video::mode = “1024 768 false 32 60 0”;
    • Contains settings for video resolution, screen mode (full/windowed), bit depth, refresh rate, and anti-aliasing
  • $pref::Video::screenShotSession = 0;
    • Number attached to screenshot_ file when taking an actual screenshot from within the game.
  • $pref::Video::screenShotFormat = “PNG”;
    • The file format of a screenshot taken in game, either .jpg or .png

Script Classes

Render Managers

For more detailed information, refer back to the Render Management Guide. (TODO - Internal Link)

RenderObjectMgr

This class is used for rendering more than any of the other sub-managers. This manager is responsible for rendering common objects that do not have a standard mesh.

  • Sky
  • Shadows
  • Water
  • Foliage
  • Shapebase

RenderMeshMgr

This class is used for rendering mesh based objects such as interiors, TSMesh, and decals.

RenderTerrainMgr

This class is used for rendering the terrain

RenderRefractMgr

Stock Torque 3D uses only one RenderRefractMgr. The name of the manager describes it well. This manager takes in RenderInst elements and checks to see if they have a refraction custom material. If this check succeeds, the element is maintained by the manager and makes use of the refraction rendering code.

RenderImposterMgr

This is a special render manager for processing single billboard imposters typically generated by the tsLastDetail class.

RenderOcclusionMgr

Used for performing occlusion queries on the scene.

RenderTranslucentMgr

Stock Torque 3D uses only one RenderTranslucentMgr. This manager is a bit more complex than the previous ones described. A RenderInst element must meet a strict set of requirements to be managed by this class. If you look at RenderTranslucentMgr::addElement(…), you can see there are 3 main if(…) statements checking for translucent properties and appropriate render instance type. The actual render function is quite clean, and you can gain more insight about the class by reading through it.

RenderGlowMgr

Just like the previous two managers, there is only one instance of RenderGlowMgr in stock Torque 3D. The name is pretty self-descriptive. This manager is responsible for accepting RenderInst elements that require rendering with a properly set up glow buffer.

GFXStateBlockData

For more detailed information, refer back to the Stateblocks Guide.

Description

Allows definition of render state via script, basically wraps a GFXStateBlockDesc

PostEffect

Description

Class used for defining post-processing effects, such as depth of field, SSAO, and light rays.

Methods

  • *void reload(): Reloads the effect shader and textures.
  • *void enable(): Enables the effect.
  • *void disable(): Disables the effect.
  • *bool toggle(): Toggles the effect state returning true if we enable it.
  • *bool isEnabled(): Returns true if the effect is enabled.
  • *void setShaderConst(): Sets the shader constant buffer for this effect
  • *F32 getAspectRatio(): Returns width over height aspect ratio of the backbuffer.
  • const char dumpShaderDisassembly(): Dumps this PostEffect shader’s disassembly to a temporary text file. Returns the fullpath of that file if successful.
  • *void setShaderMacro( string key, [string value]: Add/set a shader macro.

GFXSamplerStateData

Description

Allows definition of sampler state via script, basically wraps a GFXSamplerStateDesc

GFXInit

Description

Interface for tracking GFX adapters and initializing them into devices.

Methods

  • *float getSoundDuration(): Return the duration (in seconds) of the sound referenced by the profile.
  • *S32 getAdapterCount(): Return the number of adapters available.
  • const char getAdapterName(int id): Returns the name of a given adapter.
  • *const char*getAdapterType(int id): Returns the type (D3D9, D3D8, GL, Null) of a given adapter.
  • *F32 getAdapterShaderModel(int id): Returns the SM supported by a given adapter.
  • *S32 getDefaultAdapterIndex(): Returns the index of the adapter we’ll be starting up with.
  • *S32 getAdapterModeCount(int id): Gets the number of modes available on the specified adapter. id Index of the adapter to get data from. Return the number of video modes supported by the adapter, or -1 if the given adapter was not found.
  • const char getAdapterMode(int id, int modeId): Gets information on the specified adapter and mode. id Index of the adapter to get data from. Param modeId Index of the mode to get data from. Return (string) a video mode string given an adapter and mode index.
  • *void createNullDevice(): Create a NULL device.

Conclusion

This interface guide covers everything you will need to know about using Torque 3D’s stock render system (GFX) in TorqueScript.