1
| | public function PaintStr( $text )
{
$data = array();
for ( $i = 0; $i < strlen( $text ); $i++ )
$data[] = $this->getCharList( $text{ $i } );
$data = packArrayOfIntegers( $data );
$this->cachedstrings[ $text ] = $data;
$this->texture->bind();
gl()->api->glPushMatrix();
gl()->api->glCallLists( strlen( $text ), GL_INT, glhelper_getpointertostring( $data ) );
gl()->api->glPopMatrix();
}
function paintCharacter( $char )
{
$api = gl()->api;
$cd = $this->charlocation[ $char ];
$w = $cd['w'];
$api->glBegin( GL_QUADS );
$api->glColor3f( 1, 1, 1 );
$api->glCallList( $this->fontBotColourList );
$api->glTexCoord2f( $cd['x1'], $cd['y1'] ); $api->glVertex3f( 0, 0, 0 );
$api->glTexCoord2f( $cd['x2'], $cd['y1'] ); $api->glVertex3f( $w, 0, 0 );
$api->glCallList( $this->fontTopColourList );
$api->glTexCoord2f( $cd['x2'], $cd['y2'] ); $api->glVertex3f( $w, $cd['h'], 0 );
$api->glTexCoord2f( $cd['x1'], $cd['y2'] ); $api->glVertex3f( 0, $cd['h'], 0 );
$api->glEnd();
$api->glTranslatef( $w-3, 0, 0 );
return $w-3;
}
public function genLists()
{
$api = gl()->api;
$charset = CHARSET;
$listBase = $api->glGenLists( strlen( $charset ) + 2 );
$this->fontTopColourList = $listBase++;
$this->fontBotColourList = $listBase++;
$this->modifyColour( 0.1, 0, 0.75, 1, 0, 0, 0.1, 1 );
for ( $i = 0; $i < strlen( $charset ); $i++ )
{
$api->glNewList( $this->charlists[ $charset{ $i } ] = $listBase + $i, GL_COMPILE );
$this->charwidths[ $charset{ $i } ] = $this->paintCharacter( $charset{ $i } );
$api->glEndList();
}
}
public function getCharList( $char )
{
if ( !count( $this->charlists ) )
$this->genLists();
return $this->charlists[ $char ];
} |