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
00039 #include <GL/glut.h>
00040 #include <string.h>
00041
00042 void DEBUGPRINT(char* txt, ...);
00043
00044 char* glutxStrokeStringExpert(const char* txt, const void* font) {
00045 glPushMatrix();
00046 char *p;
00047 for (p = (char*)txt; *p && *p!='\n'; 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 char* fromwhere=(char*)txt;
00056 do {
00057 if (fromwhere!=txt) fromwhere++;
00058 glPushMatrix();
00059 glTranslatef(x,y,0);
00060
00061
00062
00063
00064 glScalef(.0075, .0075, .0075);
00065 fromwhere = glutxStrokeStringExpert(fromwhere,font);
00066 glPopMatrix();
00067 y -= 1;
00068 } while (*fromwhere);
00069 printf("Rendered %s\n", txt);
00070 }
00071
00072 void glutxBitmapString(char* txt, void* font,int x,int y) {
00073 int len, i;
00074
00075
00076
00077 glRasterPos2f(x, y);
00078 len = (int) strlen(txt);
00079 for (i = 0; i < len; i++) {
00080 glutBitmapCharacter(font, txt[i]);
00081 }
00082
00083 }
00084 float glutxBitmapSize(char* txt, void* font) {
00085 int size=0, len=strlen(txt);
00086 for (int i=0;i<len;i++) {
00087 size+=glutBitmapWidth(font,txt[i]);
00088 }
00089 return (float)size;
00090 }
00091
00092
00093 float glutxStrokeSize(const char* txt, const void* font) {
00094
00095
00096 printf(" SIZE OF %s\n", txt);
00097
00098 int size=0, len=strlen(txt);
00099 int maxsize=0;
00100 for (int i=0;i<len;i++) {
00101 size+=glutStrokeWidth((void*)font,txt[i]);
00102 if (txt[i]=='\n') {
00103 if (size>maxsize) maxsize=size;
00104 size=0;
00105 }
00106 }
00107 if (size>maxsize) maxsize=size;
00108 size = maxsize;
00109
00110
00111
00112
00113
00114
00115
00116 return (float)size * .0075;
00117
00118 }
00119 int glutxNumberOfLines(const char* txt) {
00120 int count=1;
00121
00122 for (unsigned int i=0;i<strlen(txt);i++) {
00123 if (txt[i]=='\n') {
00124 count++;
00125 }
00126 }
00127
00128 return count;
00129 }