00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include <GL/glut.h>
00039 #include <string.h>
00040
00041 void DEBUGPRINT(char* txt, ...);
00042
00043 char* glutxStrokeStringExpert(const char* txt, const void* font) {
00044
00045 glPushMatrix();
00046 char *p;
00047 for (p = (char*)txt; *p && *p!='\n' && *p!='\r'; p++) {
00048 glutStrokeCharacter((void*)font,*p);
00049 }
00050 glPopMatrix();
00051 return p;
00052 }
00053 #include <stdio.h>
00054 void glutxStrokeString(const char* txt, const void* font, float x, float y) {
00055
00056
00057 glRotatef(180.0, 1.0, 0.0, 0.0);
00058
00059
00060 printf("%s %g %g\n", txt, x, y);
00061 char* fromwhere=(char*)txt;
00062 do {
00063 if (fromwhere!=txt) fromwhere++;
00064
00065 glTranslatef(x,-y-1,0);
00066
00067
00068
00069
00070 glScalef(.0075, .0075, .0075);
00071
00072 fromwhere = glutxStrokeStringExpert(fromwhere,font);
00073
00074 glScalef(1./.0075, 1./.0075, 1./.0075);
00075 glTranslatef(-x,y+1,0);
00076 y += 1;
00077 } while (*fromwhere);
00078
00079
00080
00081
00082 glRotatef(180.0, -1.0, 0.0, 0.0);
00083
00084 }
00085
00086 void glutxBitmapString(char* txt, void* font,int x,int y) {
00087 int len, i;
00088
00089
00090
00091 glRasterPos2f(x, y);
00092 len = (int) strlen(txt);
00093 for (i = 0; i < len; i++) {
00094 glutBitmapCharacter(font, txt[i]);
00095 }
00096
00097 }
00098 float glutxBitmapSize(char* txt, void* font) {
00099 int size=0, len=strlen(txt);
00100 for (int i=0;i<len;i++) {
00101 size+=glutBitmapWidth(font,txt[i]);
00102 }
00103 return (float)size;
00104 }
00105
00106
00107 float glutxStrokeSize(const char* txt, const void* font) {
00108
00109
00110
00111
00112 int size=0, len=strlen(txt);
00113 int maxsize=0;
00114 for (int i=0;i<len;i++) {
00115 size+=glutStrokeWidth((void*)font,txt[i]);
00116 if (txt[i]=='\n' || txt[i]=='\r') {
00117 if (size>maxsize) maxsize=size;
00118 if (i < len && (txt[i]=='\n' && txt[i+1]=='\r' || txt[i]=='\r' && txt[i+1]=='\n')) i++;
00119 size=0;
00120 }
00121
00122 }
00123 if (size>maxsize) maxsize=size;
00124 size = maxsize;
00125
00126
00127
00128
00129
00130
00131
00132 return (float)size * .0075;
00133
00134 }
00135 int glutxNumberOfLines(const char* txt) {
00136 int count=1;
00137
00138 for (unsigned int i=0;i<strlen(txt);i++) {
00139 if (txt[i]=='\n') {
00140 count++;
00141 }
00142 }
00143
00144 return count;
00145 }