KrisLibrary  1.0.0
GLUTString.h
1 #ifndef GLDRAW_GLUT_STRING_H
2 #define GLDRAW_GLUT_STRING_H
3 
4 #if HAVE_GLUT
5 
6 #if defined (__APPLE__) || defined (MACOSX)
7 #include <KrisLibrary/Logger.h>
8 #include <GLUT/glut.h>
9 #else
10 #include <GL/glut.h>
11 #endif
12 
13 inline void glutBitmapString(void* fontface,const char* str)
14 {
15  while(*str) {
16  glutBitmapCharacter(fontface,*str);
17  str++;
18  }
19 }
20 
21 inline void glutStrokeString(void* fontface,const char* str)
22 {
23  while(*str) {
24  glutStrokeCharacter(fontface,*str);
25  str++;
26  }
27 }
28 
29 inline int glutBitmapStringWidth(void* fontface,const char* str)
30 {
31  int w=0;
32  while(*str) {
33  w += glutBitmapWidth(fontface,*str);
34  str++;
35  }
36  return w;
37 }
38 
39 inline int glutStrokeStringWidth(void* fontface,const char* str)
40 {
41  int w=0;
42  while(*str) {
43  w += glutStrokeWidth(fontface,*str);
44  str++;
45  }
46  return w;
47 }
48 
49 #else
50 
51 inline void glutBitmapString(void* fontface,const char* str)
52 {}
53 
54 inline void glutStrokeString(void* fontface,const char* str)
55 {}
56 
57 inline int glutBitmapStringWidth(void* fontface,const char* str)
58 {
59  return 0;
60 }
61 
62 inline int glutStrokeStringWidth(void* fontface,const char* str)
63 {
64  return 0;
65 }
66 
67 
68 #endif //HAVE_GLUT
69 
70 
71 inline void glutBitmapInt(void* fontface,int i)
72 {
73  char buf[64];
74  snprintf(buf,64,"%d",i);
75  glutBitmapString(fontface,buf);
76 }
77 
78 inline void glutStrokeInt(void* fontface,int i)
79 {
80  char buf[64];
81  snprintf(buf,64,"%d",i);
82  glutStrokeString(fontface,buf);
83 }
84 
85 inline int glutBitmapIntWidth(void* fontface,int i)
86 {
87  char buf[64];
88  snprintf(buf,64,"%d",i);
89  return glutBitmapStringWidth(fontface,buf);
90 }
91 
92 inline int glutStrokeIntWidth(void* fontface,int i)
93 {
94  char buf[64];
95  snprintf(buf,64,"%d",i);
96  return glutStrokeStringWidth(fontface,buf);
97 }
98 
99 inline void glutBitmapFloat(void* fontface,float i)
100 {
101  char buf[64];
102  snprintf(buf,64,"%.2f",i);
103  glutBitmapString(fontface,buf);
104 }
105 
106 inline void glutStrokeFloat(void* fontface,float i)
107 {
108  char buf[64];
109  snprintf(buf,64,"%.2f",i);
110  glutStrokeString(fontface,buf);
111 }
112 
113 inline int glutBitmapFloatWidth(void* fontface,float i)
114 {
115  char buf[64];
116  snprintf(buf,64,"%.2f",i);
117  return glutBitmapStringWidth(fontface,buf);
118 }
119 
120 inline int glutStrokeFloatWidth(void* fontface,float i)
121 {
122  char buf[64];
123  snprintf(buf,64,"%.2f",i);
124  return glutStrokeStringWidth(fontface,buf);
125 }
126 
127 inline void glutBitmapDouble(void* fontface,double i)
128 {
129  char buf[64];
130  snprintf(buf,64,"%.2g",i);
131  glutBitmapString(fontface,buf);
132 }
133 
134 inline void glutStrokeDouble(void* fontface,double i)
135 {
136  char buf[64];
137  snprintf(buf,64,"%.2g",i);
138  glutStrokeString(fontface,buf);
139 }
140 
141 inline int glutBitmapDoubleWidth(void* fontface,double i)
142 {
143  char buf[64];
144  snprintf(buf,64,"%.2g",i);
145  return glutBitmapStringWidth(fontface,buf);
146 }
147 
148 inline int glutStrokeDoubleWidth(void* fontface,double i)
149 {
150  char buf[64];
151  snprintf(buf,64,"%.2g",i);
152  return glutStrokeStringWidth(fontface,buf);
153 }
154 
155 #endif
The logging system used in KrisLibrary.