Section Index


1. OpenAL || 2. Debugging || 3. String Manipulation || 4. Networking || 5. Console || 6. Device I/O || 7. File I/O
8. Packages || 9. Objects || 10. Event Scheduling || 11. Datablocks || 12. Video / Texturing || 13. Special || 14. Resource Management
15. Scene || 16. Containers and Raycasts || 17. Editors || 18. Build || 19. Time || 20. GUIs || 21. Math


This quick reference guide was taken directly out of The Game Programmer's Guide to Torque by Edward Maurina. It's an outstanding resource - a must for anyone wanting to get serious about programming in Torque.


Contents

Video / Texturing

addMaterialMapping( materialName, map0 [ , ... , map97 ])

Purpose
Use the addMaterialMapping function to create a new material map instance. These maps are used by terrain and interiors for creating proper footstep sounds and dust puffs when an avatar treads upon a terrain block or interior surface using the associated texture.

Syntax
materialName
– The unadorned texture name this map is associated with. For example, "sand.jpg" would have a materialName of "sand".
map0 – At least one (required) map. See map chart below for format of these maps.
... , map97 – Up to 96 additional maps.

Returns
No return value.

Notes
There are fewer mapping types than the maximum number of maps this function will accept.

addMaterialMapping( "sand" , "sound: 0" , "color: 0.46 0.36 0.26 0.4 0.0" );



Map Type
Format
Purpose
SoundType
"sound:#"
 Map this surface to the numeric sound type #: 0 – Soft, 1  – Hard, 2 – Metal, 3 – Snow.
DetailTexture
"detail:texture"
 A texture name to be used for a detail texture on  surfaces using this material map.
EnvironmentMap
"environment:texturereflect"
 This material map has an environment map and it should  use texture for the mapping and give it a reflective factor  of reflect, where reflect is in the range [0.25, 1.0].
SmokePuffColor
"color: R G B StartA EndA"
 When a player treads on this surface and has smoke  puffs enabled, the smoke will have the color specified in  R, G, and B, where these values are floating point values  in the range [0.0, 1.0]. StartA is a floating point value in  the range [0.0, 1.0] specifying the puff's starting alpha.  EndA is of the same format and specifies the puff's  ending Alpha.



clearTextureHolds()

Purpose
Use the clearTextureHolds function to free and release any held textures, returning the size of the held textures free.

Returns
Returns the space freed.

Notes
As long as a texture is not currently in use, it will be released.

See Also
dumpTextureStats, flushTextureCache, purgeResources

clearTextureHolds();



dumpTextureStats()

Purpose
Use the dumpTextureStats function to dump information about each texture currently in use to the console. This information will be printed in this format:

aaa type: (refCount, holding) textureSpace (filename)

Output Syntax
type:
- Type of this texture. See 'Texture Types' list below.
refCount – Number of references to this texture.
holding – Is this texture being held? "yes" or "no"
textureSpace – Bytes used by this texture.
filename – Full path to this texture.

Returns
No return value.

Notes
For this to work, the engine must have been compiled with TORQUE_DEBUG defined.

See Also
clearTextureHolds, flushTextureCache

dumpTextureStats();



flushTextureCache()

Purpose
Use the flushTextureCache function to flush the texture cache.

Returns
No return value.

See Also
clearTextureHolds, dumpTextureStats, purgeResources

flushTextureCache();



getDesktopResolution()

Purpose
Use the getDesktopResolution function to determine the current resolution of the desktop (not the application).

Returns
Returns a string containing the current desktop resolution, including the width height and the current bits per pixel.

Notes
To get the current resolution of a windowed display of the torque game engine, simply examine the global variable '$pref::Video::resolution'.

See Also
getDisplayDeviceList, getResolutionList, nextResolution, prevResolution, setDisplayDevice, setRes, setScreenMode, switchBitDepth

%res = getDesktopResolution();



getDisplayDeviceList()

Purpose
Use the getDisplayDeviceList function to get a list of valid display devices.

Returns
Returns a tab separated list of valid display devices.

See Also
getDesktopResolution, getResolutionList, setRes, setScreenMode, switchBitDepth

echo(“Display Device(s) :” @ getDisplayDeviceList() );



getResolutionList( devicename )

Purpose
Use the getResolutionList function to get a semicolon separated list of legal resolutions for a specified device.

Syntax
deviceName
– A string containing a supported display device.

Returns
Returns a tab separated list of valid display resolutions for devicename.

Notes
Resolutions are always in the form: width height bpp, where width and height are in pixels and bpp is bits-per-pixel.

See Also
getDesktopResolution, getDisplayDeviceList, setRes, setScreenMode, switchBitDepth

echo("Possible resolutions :” @ getResolutionList( "OpenGL" ) );



getVideoDriverInfo()

Purpose
Use the getVideoDriverInfo function to dump information on the video driver to the console.

Returns
No return value.

echo(“Device driver info :” @ getVideoDriverInfo() );



isDeviceFullScreenOnly( devicename )

Purpose
Use the isDeviceFullScreenOnly function to determine if the device specified in devicename is for full screen display only, or whether it supports windowed mode too.

Syntax
deviceName
– A string containing a supported display device.

Returns
Returns true if the device can only display full scree, false otherwise.

See Also
getResolutionList



isFullScreen()

Purpose
Use the isFullScreen function to determine if the current application is displayed in full-screen mode.

Returns
Returns true if the engine is currently displaying full-screen, otherwise returns false.



nextResolution()

Purpose
Use the nextResolution function to switch to the next valid (higher) resolution for the current display device.

Returns
Returns true if switch was successful, false otherwise.

See Also
getDesktopResolution, prevResolution, getResolutionList, setRes, setScreenMode, switchBitDepth



png2jpg( pngFilename [ , quality ] )

Purpose
Use the png2jpg function to save a PNG file specified by pngFilename as a similarly named JPEG file with the optionally specified qualitiy.

Syntax
pngFilename
– The path and file name of the PNG file to convert.
quality – An optional quality between 0 and 100. The default quality is 90.


Returns
Returns -1 if the file could not be openned, 0 on other failures, and 1 if the conversion worked.



prevResolution()

Purpose
Use the prevResolution function to switch to the previous valid (lower) resolution for the current display device.

Returns
Returns true if switch was successful, false otherwise.

See Also
getDesktopResolution, nextResolution, getResolutionList, setRes, setScreenMode, switchBitDepth



screenShot( filename , format )

Purpose
Use the screenShot function to capture a screenshot and store it in the file specified by filename.

Syntax
filename
– Path to file in which to save screenshot.
format – The format to save the file in, PNG or JPG.

Returns
No return value.

See Also
panoramaScreenShot

screenshot("capture0.png", "PNG" );



setDefaultFov( defaultFOV )

Purpose
Use the setDefaultFov function to set the default field-of-view (FOV).

Syntax
defaultFOV
– A FOV value between 0.0 and 180.0.

Returns
No return value.

See Also
SetFOV



setDisplayDevice( deviceName [, width [ , height [, bpp [, fullScreen] ] ] ] )

Purpose
Use the setDisplayDevice function to select a display device and to set the initial width, height and bits-per-pixel (bpp) setting, as well as whether the application is windowed or in fullScreen.

Syntax
deviceName
– A supported display device name.
width – Resolution width in pixels.
height - Resolution height in pixels.
bpp – Pixel resolution in bits-per-pixel (16 or 32).
fullScreen – A boolean value. If set to true, the application displays in full-screen mode, otherwise it will attempt to display in windowed mode.

Returns
Returns true on success, false otherwise.

Notes
If no resolution information is specified, the first legal resolution on this device's resolution list will be used. Furthermore, for each optional argument if the subsequent arguments are not specified, the first matching case will be used. Lastly, if the application is not told to display in full screen, but the device only supports windowed, the application will be forced into windowed mode.

See Also
getDesktopResolution, getDisplayDeviceList, getResolutionList, nextResolution, prevResolution, setRes, setScreenMode, switchBitDepth



setFov( FOV )

Purpose
Use the setFov function to set the current field-of-view (FOV).

Syntax
FOV
– A FOV value between 0.0 and 180.0.

Returns
No return value.

See Also
setDefaultFov



setOpenGLAnisotropy( 0.0 .. max.f )

Purpose
Use the setOpenGLAnisotropy function to enable or disable anisotropic filtering.

Syntax
0.0 .. max.f
- A value between 0.0 and the maximum anisotropic level supported by the current machine. Selecting a value higher than max.f results in max.f.

Returns
No return value.

Notes
Anisotropic filtering is somewhat 'expensive' filtering technique that uses more texels than your average filtering technique (bilinear or trilinear) for determining the color of a pixel for cases where more than one texel may be responsible for that pixels color.



setOpenGLInteriorMipReduction( reductionVal )

Purpose
Use the setOpenGLInteriorMipReduction function to set the texture quality for interiors.

Syntax
reductionVal
– An integer value between 0 and 5, with 0 being the lowest quality and 5 being the highest quality.

Returns
No return value.

See Also
setOpenGLMipReduction ,setOpenGLSkyMipReduction



setOpenGLMipReduction( reductionVal )

Purpose
Use the setOpenGLMipReduction function to control shape texture detail

Syntax
reductionVal
– An integer value between 0 and 5, with 0 being the lowest quality and 5 being the highest quality.

Returns
No return value.

See Also
setOpenGLInteriorMipReduction, setOpenGLSkyMipReduction



setOpenGLSkyMipReduction( reductionVal )

Purpose
Use the setOpenGLSkyMipReduction function to control texture detail for the skybox and clouds.

Syntax
reductionVal
– An integer value between 0 and 5, with 0 being the lowest quality and 5 being the highest quality.

Returns
No return value.

See Also
setOpenGLInteriorMipReduction, setOpenGLMipReduction



setOpenGLTextureCompressionHint ( hint )

Purpose
Use the setOpenGLTextureCompressionHint function to select the OpenGL texture compression method.

Syntax
hint
- "GL_DONT_CARE", "GL_FASTEST", or "GL_NICEST". (Please refer to an OpenGL text for information on what these mean.)

Returns
No return value.

setOpenGLTextureCompressionHint(GL_NICEST);



setRes( width , height , bpp )

Purpose
Use the setRes function to set the screen to the specified width, height, and bits-per-pixel (bpp).

Syntax
width
– Resolution width in pixels.
height - Resolution height in pixels.
bpp – Pixel resolution in bits-per-pixel (16 or 32).

Returns
Returns true if successful, otherwise false.

See Also
getDesktopResolution, getDisplayDeviceList, getResolutionList, nextResolution, prevResolution, setDisplayDevice, setScreenMode, switchBitDepth



setScreenMode( width , height , bpp , fullScreen )

Purpose
Use the setScreenMode function to set the screen to the specified width, height, and bits-per-pixel (bpp). Additionally, if fullScreen is set to true the engine will attempt to display the application in full-screen mode, otherwise it will attempt to used windowed mode.

Syntax
width
– Resolution width in pixels.
height - Resolution height in pixels.
bpp – Pixel resolution in bits-per-pixel (16 or 32).
fullScreen – A boolean value. If set to true, the application displays in full-screen mode, otherwise it will attempt to display in windowed mode.

Returns
Returns true if successful, otherwise false.

See Also
getDesktopResolution, getDisplayDeviceList, getResolutionList, nextResolution, prevResolution, setDisplayDevice, setRes, switchBitDepth

setScreenMode( 1024 , 768 , 32 , false ); // 1024x768 32bpp windowed mode



setVerticalSync( enable )

Purpose
Use the setVerticalSync function to force the framerate to sync up with the vertical refresh rate.

Syntax
enable
– A boolean value. If set to true, the engine will only swap front and back buffers on or before a vertical refresh pass.

Returns
Returns true on success, false otherwise.

Notes
This is used to reduce excessive swapping/rendering. There is generally no purpose in rendering any faster than the monitor will support. Those extra 'ergs' can be used for something else.



switchBitDepth()

Purpose
Use the switchBitDepth function to toggle the bits-per-pixel (bpp) pixel resolutoin between 16 and 32.

Returns
Returns true on success, false otherwise.

See Also
getDesktopResolution, getDisplayDeviceList, getResolutionList, nextResolution, prevResolution, setDisplayDevice, setRes,



toggleFullScreen()

Purpose
Use the toggleFullScreen function to swith from full-screen mode to windowed, or vice versa.

Returns
Returns true on success, false otherwise.



videoSetGammaCorrection( gamma )

Purpose
Use the videoSetGammaCorrection function to adjust the gamma for the video card.

Syntax
gamma
– A floating-point value between 0.0 and 1.0.

Returns
No return value.

Notes
The card will revert to it's default gamma setting as long as the application closes normally.

videoSetGammaCorrection($pref::OpenGL::gammaCorrection);



Type
Description
0
Regular bitmap
1
Same as 1, but the data will be kept after creation
2
Same as 1 except data will not be loaded to OpenGL and cannot be "bound"
3
Internal ONLY.
4
Same as 1, but has "small textures"
5
Terrain texture.
6
Sky Texture
7
Interior Texture
8
Bump Texture
9
Inverted Bump Texture
10
Detail Texture
11
Zero Border Texture


Section Index


1. OpenAL || 2. Debugging || 3. String Manipulation || 4. Networking || 5. Console || 6. Device I/O || 7. File I/O
8. Packages || 9. Objects || 10. Event Scheduling || 11. Datablocks || 12. Video / Texturing || 13. Special || 14. Resource Management
15. Scene || 16. Containers and Raycasts || 17. Editors || 18. Build || 19. Time || 20. GUIs || 21. Math