ScriptGL

From TribalWar

Jump to: navigation, search

ScriptGL is another one of Andrews crazy wonders. 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. Its functionality is accessable by installing HudBot 0.5. It's functionality is meant to create more comfort when creating heads-up displays.

Contents

Naive Sum-up

ScriptGl allows you to:

  • render True-Type Font text.
  • render *.tga files
  • create resolution independent Hud setups.

Benefits

ScriptGL offers scripters a wide spread range of features. The framework shipped with HudBot already features handling for rendering, positioning of registerd Hud-elements. Due to the design concept each vHud has to deliver a rendering function which will be executed every $ScriptGL::Latency milliseconds. This behavior bypasses the use of scheduler-functions that have been used to keep Huds that display changing values up to date. Huds created with ScriptGL can be aligned dynamically according to the ingame resolutions and thus make hud designs reolution independent. Last but not least, it's now possible to use custom textures in huds without having to bother with Phoenix Bmps anymore.

Function List

Following functions are revealed to Tribes Script. Some of them do exactly what the corresponding OpenGl functions would, others are wrapper functions to simulate the expected functionality.

  • glBegin( mode )
  • glBindTexture( texture )
  • glBlendFunc( sfactor, dfactor )
  • glColor4ub( r, g, b, a )
  • glDisable( cap )
  • glDrawString( x, y, string )
  • glDrawTexture( texture, mode, x, y, [scale_x], [scale_y], [radians] )
  • glEnd( )
  • glGetStringDimensions( string )( )
  • glGetTextureDimensions( texture )
  • glRectangle( x, y, width, height )
  • glRescanTextureDirectory( )
  • glSetFont( font, pixel_height, [render_mode], [glow_radius] )
  • glTexCoord2f( x, y )
  • glTexEnvi( mode )
  • glVertex2i( x, y )

Hello World

The following code will display the text "Hello World!" in the left upper corned of the screen using the True-Type Font "verdana". The variables used are just for readability so they could also be stated directly. This example should show how little code is required to create simple vHuds.

$vhud::hw[name] = "Hello_World_example";
$vhud::hw[hud,size] = "5% 5%";
$vhud::hw[hud,pos] = "0% 0%";
$vhud::hw[font] = "verdana";
$vhud::hw[text] = "Hello World!";
$vhud::hw[onrender] = "vhud::hw::onrender();";

function vhud::hw::create( ) {
	vhud::create( $vhud::hw[name], $vhud::hw[hud,size], $vhud::hw[hud,pos], $vhud::hw[onrender]);
	
	vhud::add_item( "text_size", "100%");
	vhud::add_item( "text_pos", "0% 0%" );
}

function vhud::hw::onrender( ) {
	vhud::render_text( "text_pos", $vhud::hw[font], "text_size", $GLEX_SMOOTH,  $vhud::hw[text]);
}

vhud::hw::create( );

References

Also See

Personal tools
Ads: