Guest User

Untitled

a guest
Dec 14th, 2011
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. void FGAPIENTRY glutBitmapString( void* fontID, const unsigned char *string )
  2. {
  3. unsigned char c;
  4. float x = 0.0f ;
  5. SFG_Font* font;
  6. FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapString" );
  7. font = fghFontByID( fontID );
  8. freeglut_return_if_fail( font );
  9. if ( !string || ! *string )
  10. return;
  11.  
  12. glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT );
  13. glPixelStorei( GL_UNPACK_SWAP_BYTES, GL_FALSE );
  14. glPixelStorei( GL_UNPACK_LSB_FIRST, GL_FALSE );
  15. glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
  16. glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
  17. glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
  18. glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
  19.  
  20. /*
  21. * Step through the string, drawing each character.
  22. * A newline will simply translate the next character's insertion
  23. * point back to the start of the line and down one line.
  24. */
  25. while( ( c = *string++) )
  26. if( c == '\n' )
  27. {
  28. glBitmap ( 0, 0, 0, 0, -x, (float) -font->Height, NULL );
  29. x = 0.0f;
  30. }
  31. else /* Not an EOL, draw the bitmap character */
  32. {
  33. const GLubyte* face = font->Characters[ c ];
  34.  
  35. glBitmap(
  36. face[ 0 ], font->Height, /* Bitmap's width and height */
  37. font->xorig, font->yorig, /* The origin in the font glyph */
  38. ( float )( face[ 0 ] ), 0.0, /* The raster advance; inc. x,y */
  39. ( face + 1 ) /* The packed bitmap data... */
  40. );
  41.  
  42. x += ( float )( face[ 0 ] );
  43. }
  44.  
  45. glPopClientAttrib( );
  46. }
Advertisement
Add Comment
Please, Sign In to add comment