/* * Draw a stroke character */ void FGAPIENTRY glutStrokeCharacter( void* fontID, int character ) { const SFG_StrokeChar *schar; const SFG_StrokeStrip *strip; int i, j; SFG_StrokeFont* font; FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeCharacter" ); font = fghStrokeByID( fontID ); freeglut_return_if_fail( character >= 0 ); freeglut_return_if_fail( character < font->Quantity ); freeglut_return_if_fail( font ); schar = font->Characters[ character ]; freeglut_return_if_fail( schar ); strip = schar->Strips; for( i = 0; i < schar->Number; i++, strip++ ) { glBegin( GL_LINE_STRIP ); for( j = 0; j < strip->Number; j++ ) glVertex2f( strip->Vertices[ j ].X, strip->Vertices[ j ].Y ); glEnd( ); glBegin( GL_POINTS ); for( j = 0; j < strip->Number; j++ ) glVertex2f( strip->Vertices[ j ].X, strip->Vertices[ j ].Y ); glEnd( ); } glTranslatef( schar->Right, 0.0, 0.0 ); }
/* * Return the width of a string drawn using a stroke font */ int glutStrokeLength( void* fontID, const unsigned char* string ) { int c; float length = 0.0; float this_line_length = 0.0; SFG_StrokeFont* font = fghStrokeByID( fontID ); int numchar = strlen( string ); for( c = 0; c < numchar; c++ ) if( string[ c ] < font->Quantity ) { if( string[ c ] == '\n' ) /* EOL; reset the length of this line */ { if( length < this_line_length ) length = this_line_length; this_line_length = 0.0; } else /* Not an EOL, increment the length of this line */ { const SFG_StrokeChar *schar = font->Characters[ string[ c ] ]; if( schar ) this_line_length += schar->Right; } } if( length < this_line_length ) length = this_line_length; return( int )( length + 0.5 ); }
/* * Return the width of a string drawn using a stroke font */ int FGAPIENTRY glutStrokeLength(void* fontID, const char* string) { int c; GLfixed length = 0; GLfixed this_line_length = 0; SFG_StrokeFont* font = fghStrokeByID(fontID); int numchar = (int)strlen((char*) string); for(c = 0; c < numchar; c++) if(string[ c ] < font->Quantity) { if(string[ c ] == '\n') /* EOL; reset the length of this line */ { if(length < this_line_length) length = this_line_length; this_line_length = 0; } else /* Not an EOL, increment the length of this line */ { const SFG_StrokeChar *schar = font->Characters[ string[ c ] ]; if(schar) this_line_length += schar->Right; } } if(length < this_line_length) length = this_line_length; return (int)(length / 65536); }
/* * Return the width of a string drawn using a stroke font */ int FGAPIENTRY glutStrokeLength( void* fontID, const unsigned char* string ) { unsigned char c; float length = 0.0; float this_line_length = 0.0; SFG_StrokeFont* font; FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeLength" ); font = fghStrokeByID( fontID ); freeglut_return_val_if_fail( font, 0 ); if ( !string || ! *string ) return 0; while( ( c = *string++) ) if( c < font->Quantity ) { if( c == '\n' ) /* EOL; reset the length of this line */ { if( length < this_line_length ) length = this_line_length; this_line_length = 0.0; } else /* Not an EOL, increment the length of this line */ { const SFG_StrokeChar *schar = font->Characters[ c ]; if( schar ) this_line_length += schar->Right; } } if( length < this_line_length ) length = this_line_length; return( int )( length + 0.5 ); }
/* * Draw a stroke character */ void FGAPIENTRY glutStrokeCharacter( void* fontID, int character ) { const SFG_StrokeChar *schar; const SFG_StrokeStrip *strip; int i; SFG_StrokeFont* font; FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeCharacter" ); font = fghStrokeByID( fontID ); if (!font) { fgWarning("glutStrokeCharacter: stroke font 0x%08x not found. Make sure you're not passing a bitmap font.\n",fontID); return; } freeglut_return_if_fail( character >= 0 ); freeglut_return_if_fail( character < font->Quantity ); schar = font->Characters[ character ]; freeglut_return_if_fail( schar ); strip = schar->Strips; for( i = 0; i < schar->Number; i++, strip++ ) { glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, 0, &strip->Vertices[0].X); glDrawArrays(GL_LINE_STRIP, 0, strip->Number); glDisableClientState(GL_VERTEX_ARRAY); } glTranslatef( schar->Right, 0.0, 0.0 ); }
/* * Returns the height of a stroke font */ GLfloat FGAPIENTRY glutStrokeHeight( void* fontID ) { SFG_StrokeFont* font; FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeHeight" ); font = fghStrokeByID( fontID ); freeglut_return_val_if_fail( font, 0.0 ); return font->Height; }
void glutStrokeCharacter( void* fontID, int character ) { const SFG_StrokeChar *schar; const SFG_StrokeStrip *strip; int i, j; SFG_StrokeFont* font; font = fghStrokeByID( fontID ); if ( character < 0 ) {return;} if (character >= font->Quantity) { dbg_msg( "failed at: %c %d \n", character,character); return; } //_freeglut_return_if_fail( character < font->Quantity ); _freeglut_return_if_fail( font ); schar = font->Characters[ character ]; _freeglut_return_if_fail( schar ); strip = schar->Strips; #if 1 glEnableClientState( GL_VERTEX_ARRAY ); for( i = 0; i < schar->Number; i++, strip++ ) { float v[128][2]; const int ptCount = strip->Number < 128? strip->Number : 128; for( j = 0; j < ptCount; j++ ) { v[ j ][0] = strip->Vertices[ j ].X; v[ j ][1] = strip->Vertices[ j ].Y; } glVertexPointer( 2, GL_FLOAT, 0, v ); glDrawArrays( GL_LINE_STRIP, 0, ptCount ); } glDisableClientState( GL_VERTEX_ARRAY ); #else for( i = 0; i < schar->Number; i++, strip++ ) { glBegin( GL_LINE_STRIP ); for( j = 0; j < strip->Number; j++ ) glVertex2f( strip->Vertices[ j ].X, strip->Vertices[ j ].Y ); glEnd( ); glBegin( GL_POINTS ); for( j = 0; j < strip->Number; j++ ) glVertex2f( strip->Vertices[ j ].X, strip->Vertices[ j ].Y ); glEnd( ); } #endif glTranslatef( schar->Right, 0.0, 0.0 ); }
void FGAPIENTRY glutStrokeString( void* fontID, const unsigned char *string ) { unsigned char c; int i; float length = 0.0; SFG_StrokeFont* font; FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeString" ); font = fghStrokeByID( fontID ); if (!font) { fgWarning("glutStrokeString: stroke font 0x%08x not found. Make sure you're not passing a bitmap font.\n",fontID); return; } if ( !string || ! *string ) return; /* * Step through the string, drawing each character. * A newline will simply translate the next character's insertion * point back to the start of the line and down one line. */ glEnableClientState(GL_VERTEX_ARRAY); while( ( c = *string++) ) if( c < font->Quantity ) { if( c == '\n' ) { glTranslatef ( -length, -( float )( font->Height ), 0.0 ); length = 0.0; } else /* Not an EOL, draw the bitmap character */ { const SFG_StrokeChar *schar = font->Characters[ c ]; if( schar ) { const SFG_StrokeStrip *strip = schar->Strips; for( i = 0; i < schar->Number; i++, strip++ ) { glVertexPointer(2, GL_FLOAT, 0, &strip->Vertices[0].X); glDrawArrays(GL_LINE_STRIP, 0, strip->Number); } length += schar->Right; glTranslatef( schar->Right, 0.0, 0.0 ); } } } glDisableClientState(GL_VERTEX_ARRAY); }
/* * Returns the height of a stroke font */ GLfloat FGAPIENTRY glutStrokeHeight( void* fontID ) { SFG_StrokeFont* font; FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeHeight" ); font = fghStrokeByID( fontID ); if (!font) { fgWarning("glutStrokeHeight: stroke font 0x%08x not found. Make sure you're not passing a bitmap font.\n",fontID); return 0.f; } return font->Height; }
void FGAPIENTRY glutStrokeString(void* fontID, const char *string) { int c, i; int numchar = (int)strlen((char*) string); GLfixed length = 0; GLbyte indices[255]; SFG_StrokeFont* font = fghStrokeByID(fontID); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glEnableClientState (GL_VERTEX_ARRAY); for(i = 0; i < 255; i++) indices[i] = i; /* * Step through the string, drawing each character. * A newline will simply translate the next character's insertion * point back to the start of the line and down one line. */ for(c = 0; c < numchar; c++) if(string[ c ] < font->Quantity) { if(string[ c ] == '\n') { glTranslatex(-length, -font->Height, 0); length = 0; } else /* Not an EOL, draw the bitmap character */ { const SFG_StrokeChar *schar = font->Characters[ string[ c ] ]; if(schar) { const SFG_StrokeStrip *strip = schar->Strips; for(i = 0; i < schar->Number; i++, strip++) { glVertexPointer(2, GL_FIXED, 0, strip->Vertices); glDrawElements(GL_LINE_STRIP, strip->Number, GL_UNSIGNED_BYTE, indices); } length += schar->Right; glTranslatex(schar->Right, 0, 0); } } } }
/* * Return the width in pixels of a stroke character */ int glutStrokeWidth( void* fontID, int character ) { const SFG_StrokeChar *schar; SFG_StrokeFont* font = fghStrokeByID( fontID ); freeglut_return_val_if_fail( ( character >= 0 ) && ( character < font->Quantity ), 0 ); schar = font->Characters[ character ]; freeglut_return_val_if_fail( schar, 0 ); return ( int )( schar->Right + 0.5 ); }
/* * Return the width in pixels of a stroke character */ int FGAPIENTRY glutStrokeWidth(void* fontID, int character) { const SFG_StrokeChar *schar; SFG_StrokeFont* font = fghStrokeByID(fontID); if(! ((character >= 0) && (character < font->Quantity))) return 0; schar = font->Characters[ character ]; if(!schar) return 0; return (int)(schar->Right / 65536); }
void FGAPIENTRY glutStrokeString( void* fontID, const unsigned char *string ) { unsigned char c; int i, j; float length = 0.0; SFG_StrokeFont* font; FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeString" ); font = fghStrokeByID( fontID ); freeglut_return_if_fail( font ); if ( !string || ! *string ) return; /* * Step through the string, drawing each character. * A newline will simply translate the next character's insertion * point back to the start of the line and down one line. */ while( ( c = *string++) ) if( c < font->Quantity ) { if( c == '\n' ) { glTranslatef ( -length, -( float )( font->Height ), 0.0 ); length = 0.0; } else /* Not an EOL, draw the bitmap character */ { const SFG_StrokeChar *schar = font->Characters[ c ]; if( schar ) { const SFG_StrokeStrip *strip = schar->Strips; for( i = 0; i < schar->Number; i++, strip++ ) { glBegin( GL_LINE_STRIP ); for( j = 0; j < strip->Number; j++ ) glVertex2f( strip->Vertices[ j ].X, strip->Vertices[ j ].Y); glEnd( ); } length += schar->Right; glTranslatef( schar->Right, 0.0, 0.0 ); } } } }
/* * Return the width in pixels of a stroke character */ int FGAPIENTRY glutStrokeWidth( void* fontID, int character ) { const SFG_StrokeChar *schar; SFG_StrokeFont* font; FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeWidth" ); font = fghStrokeByID( fontID ); freeglut_return_val_if_fail( ( character >= 0 ) && ( character < font->Quantity ), 0 ); freeglut_return_val_if_fail( font, 0 ); schar = font->Characters[ character ]; freeglut_return_val_if_fail( schar, 0 ); return ( int )( schar->Right + 0.5 ); }
void glutStrokeString( void* fontID, const unsigned char *string ) { int c, i, j; int numchar = strlen( string ); float length = 0.0; SFG_StrokeFont* font = fghStrokeByID( fontID ); /* * Step through the string, drawing each character. * A newline will simply translate the next character's insertion * point back to the start of the line and down one line. */ for( c = 0; c < numchar; c++ ) if( string[ c ] < font->Quantity ) { if( string[ c ] == '\n' ) { glTranslatef ( -length, -( float )( font->Height ), 0.0 ); length = 0.0; } else /* Not an EOL, draw the bitmap character */ { const SFG_StrokeChar *schar = font->Characters[ string[ c ] ]; if( schar ) { const SFG_StrokeStrip *strip = schar->Strips; for( i = 0; i < schar->Number; i++, strip++ ) { glBegin( GL_LINE_STRIP ); for( j = 0; j < strip->Number; j++ ) glVertex2f( strip->Vertices[ j ].X, strip->Vertices[ j ].Y); glEnd( ); } length += schar->Right; glTranslatef( schar->Right, 0.0, 0.0 ); } } } }
/* * Return the width in pixels of a stroke character */ int FGAPIENTRY glutStrokeWidth( void* fontID, int character ) { const SFG_StrokeChar *schar; SFG_StrokeFont* font; FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeWidth" ); font = fghStrokeByID( fontID ); if (!font) { fgWarning("glutStrokeWidth: stroke font 0x%08x not found. Make sure you're not passing a bitmap font.\n",fontID); return 0; } freeglut_return_val_if_fail( ( character >= 0 ) && ( character < font->Quantity ), 0 ); schar = font->Characters[ character ]; freeglut_return_val_if_fail( schar, 0 ); return ( int )( schar->Right + 0.5 ); }
/* * Return the width of a string drawn using a stroke font */ int FGAPIENTRY glutStrokeLength( void* fontID, const unsigned char* string ) { unsigned char c; float length = 0.0; float this_line_length = 0.0; SFG_StrokeFont* font; FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeLength" ); font = fghStrokeByID( fontID ); if (!font) { fgWarning("glutStrokeLength: stroke font 0x%08x not found. Make sure you're not passing a bitmap font.\n",fontID); return 0; } if ( !string || ! *string ) return 0; while( ( c = *string++) ) if( c < font->Quantity ) { if( c == '\n' ) /* EOL; reset the length of this line */ { if( length < this_line_length ) length = this_line_length; this_line_length = 0.0; } else /* Not an EOL, increment the length of this line */ { const SFG_StrokeChar *schar = font->Characters[ c ]; if( schar ) this_line_length += schar->Right; } } if( length < this_line_length ) length = this_line_length; return( int )( length + 0.5 ); }
/* * Draw a stroke character */ void FGAPIENTRY glutStrokeCharacter(void* fontID, int character) { const SFG_StrokeChar *schar; const SFG_StrokeStrip *strip; int i; SFG_StrokeFont* font = fghStrokeByID(fontID); GLbyte indices[255]; if(! (character >= 0) && (character < font->Quantity)) return; schar = font->Characters[ character ]; if(! schar) return; strip = schar->Strips; glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glEnableClientState (GL_VERTEX_ARRAY); for(i = 0; i < 255; i++) indices[i] = i; for(i = 0; i < schar->Number; i++, strip++) { glVertexPointer(2, GL_FIXED, 0, strip->Vertices); glDrawElements(GL_LINE_STRIP, strip->Number, GL_UNSIGNED_BYTE, indices); } glTranslatex((GLfixed)schar->Right, 0, 0); }
/* * Returns the height of a stroke font */ GLfloat glutStrokeHeight( void* fontID ) { SFG_StrokeFont* font = fghStrokeByID( fontID ); return font->Height; }
/* * Returns the height of a stroke font */ GLfloat FGAPIENTRY glutStrokeHeight(void* fontID) { SFG_StrokeFont* font = fghStrokeByID(fontID); return _FIXED2FLOAT(font->Height); }