Hudbot's ScriptGL documentation

Quick Links

ScriptGL

ScriptGL is a hudbot extension which allows you to use a subset of OpenGL commands from Tribes Script; It also implements a few custom OpenGL commands for textures and fonts.

Using ScriptGL

Drawing with ScriptGL is only allowed inside special callback functions. Currently only the playGui GUI is supported so that is where your drawing will have to take place. ScriptGL will call ScriptGL::playGui::onPreDraw( %dimensions ) and ScriptGL::playGui::onPostDraw( %dimensions ) before and after the playGui is rendered, allowing you to draw under or over the default HUDs. %dimensions will hold the resolution of the screen in the form of "width height".

function ScriptGL::playGui::onPreDraw( %dimensions ) {
	glDisable( $GL_TEXTURE_2D );
	glColor4ub( 255, 255, 255, 128 );
	glBegin( $GL_TRIANGLES );
		glVertex2i( 40, 40 );
		glVertex2i( 60, 20 );
		glVertex2i( 80, 40 );
	glEnd( );
	...
}

function ScriptGL::playGui::onPostDraw( %dimensions ) {
	...
}

Since the Tribes Scripting engine is fairly slow, calling these functions once a frame will bog you down quickly if you are doing anything non-trivial. To combat this, ScriptGL will only call the onDraw functions every $ScriptGL::Latency milliseconds (default 100, i.e. 10 times a second). Since there obviously needs to be something displayed in the interim, the onDraw OpenGL calls are compiled in to an intermediate bytecode so your HUDs will be "carbon copied", so to speak, until the next update.

A setting of 15 should be the absolute lowest interval you would need, being slightly higher than 60 times a second. If you are not displaying anything that requires constant updating, a large value such as 1000 (once every second) would be good. After a certain point the overhead of the script calls evaporates and higher latencies have no effect.

Textures & Fonts

ScriptGL can use any TrueType font a) available to Windows or b) in the "Hudbot/Fonts" directory. All .ttf files in "Hudbot/Fonts" are temporarily loaded to Windows using AddFontResource when Hudbot is started so you may distribute non-standard fonts without requiring the user to manually install them. Fonts may not be zipped.

ScriptGL textures (used by glBindTexture, glDrawTexture, and glGetTextureDimensions) are stored in "Hudbot/ScriptGL". They may be in subdirectories or zipped, but path names are not used when loading textures. Files not in zips will take precedence over zipped files, but no guarantee is made if multiple files with the same name are present in multiple directories and/or zips.

Note: Fonts and textures will be garbage collected if they are not used for 30 seconds. "Using" means calling glBindTexture, glDrawTexture, or glSetFont. The current font and texture are not saved between onDraw calls, i.e. even if you are only using a single font you still need to use glSetFont each onDraw call.

ScriptGL Function List

ScriptGL Functions

The following ScriptGL functions behave like their OpenGL counterparts. Documenation should be fairly easy to find for them if you need more information

ScriptGL Extensions