core/vgui/vgui_text_put.cxx
Go to the documentation of this file.
00001 // This is core/vgui/vgui_text_put.cxx
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005 //:
00006 // \file
00007 // \author Philip C. Pritchett, RRG, University of Oxford
00008 // \date   19 Oct 99
00009 // \brief  See vgui_text_put.h for a description of this file.
00010 
00011 
00012 #include "vgui_text_put.h"
00013 #include <vgui/vgui_gl.h>
00014 #include <vgui/vgui_config.h>
00015 
00016 #if defined(HAS_GLUT) && defined(VGUI_USE_GLUT)
00017 #include <vgui/vgui_glut.h>
00018 
00019 // This ugliness is used to make sure we don't try to initialize GLUT
00020 // multiple times if glut is used as the toolkit too.
00021 bool glut_was_initialized = false;
00022 
00023 void vgui_text_put(char const *str, unsigned size)
00024 {
00025   if( ! glut_was_initialized ) {
00026     glut_was_initialized = true;
00027     int argc = 0;
00028     char* argv[1] = { 0 };
00029     glutInit( &argc, argv );
00030   }
00031 
00032   if (size > 17) {
00033     for (unsigned k=0; str[k]; ++k)
00034       glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, str[k]);
00035   } else {
00036     for (unsigned k=0; str[k]; ++k)
00037       glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_10, str[k]);
00038   }
00039 }
00040 #else
00041 #include <vgui/vgui_font_bitmap.h>
00042 void vgui_text_put(char const *str, unsigned int size)
00043 {
00044   vgui_font_bitmap font(vgui_font_bitmap::BITMAP_FONT_8_13);
00045   font.draw(str);
00046 }
00047 #endif