Lines 26-36
Link Here
|
26 |
*/ |
26 |
*/ |
27 |
|
27 |
|
28 |
#include <GL/glut.h> |
28 |
#include <GL/glut.h> |
|
|
29 |
#include <string.h> |
29 |
|
30 |
|
30 |
#include "TexFont.h" |
31 |
#include "TexFont.h" |
31 |
|
32 |
|
32 |
#include "enum.h" |
33 |
#include "enum.h" |
33 |
#include "extern.h" |
34 |
#include "extern.h" |
|
|
35 |
#include <string.h> |
36 |
#include <stdlib.h> |
37 |
|
34 |
|
38 |
|
35 |
/*--------------------------------------------------------*/ |
39 |
/*--------------------------------------------------------*/ |
36 |
void drawstring (int x, int y, char *str) |
40 |
void drawstring (int x, int y, char *str) |
Lines 89-105
Link Here
|
89 |
} |
93 |
} |
90 |
|
94 |
|
91 |
/*--------------------------------------------------------*/ |
95 |
/*--------------------------------------------------------*/ |
92 |
void drawstringright (int x, int y, char *str, float width) |
96 |
void drawstringright (int x, int y, const char *str, float width) |
93 |
{ |
97 |
{ |
94 |
int len, i; |
98 |
int len, i; |
95 |
|
99 |
|
96 |
|
100 |
|
97 |
len = strlen(str); |
101 |
len = strlen(str); |
|
|
102 |
char *str_ = strdup(str); |
98 |
|
103 |
|
99 |
switch(g_drawText) |
104 |
switch(g_drawText) |
100 |
{ |
105 |
{ |
101 |
case BitmapText: |
106 |
case BitmapText: |
102 |
glRasterPos2f(x+(width-glutBitmapLength(GLUT_BITMAP_HELVETICA_12, str)), y); |
107 |
glRasterPos2f(x+(width-glutBitmapLength(GLUT_BITMAP_HELVETICA_12, (const unsigned char*)str)), y); |
103 |
for (i=0; i<len; i++) |
108 |
for (i=0; i<len; i++) |
104 |
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str[i]); |
109 |
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str[i]); |
105 |
break; |
110 |
break; |
Lines 107-134
Link Here
|
107 |
glEnable(GL_TEXTURE_2D); |
112 |
glEnable(GL_TEXTURE_2D); |
108 |
glPushMatrix(); |
113 |
glPushMatrix(); |
109 |
glTranslatef((float)x, (float)y, 0); |
114 |
glTranslatef((float)x, (float)y, 0); |
110 |
txfRenderStringRightJustify(helv_txf, str, len, width); |
115 |
txfRenderStringRightJustify(helv_txf, str_, len, width); |
111 |
glPopMatrix(); |
116 |
glPopMatrix(); |
112 |
glDisable(GL_TEXTURE_2D); |
117 |
glDisable(GL_TEXTURE_2D); |
113 |
break; |
118 |
break; |
114 |
default: |
119 |
default: |
115 |
break; |
120 |
break; |
116 |
} |
121 |
} |
|
|
122 |
|
123 |
free(str_); |
117 |
} |
124 |
} |
118 |
|
125 |
|
119 |
|
126 |
|
120 |
/*--------------------------------------------------------*/ |
127 |
/*--------------------------------------------------------*/ |
121 |
void drawstringcenter (int x, int y, char *str, float width) |
128 |
void drawstringcenter (int x, int y, const char *str, float width) |
122 |
{ |
129 |
{ |
123 |
int len, i; |
130 |
int len, i; |
124 |
|
131 |
|
125 |
|
132 |
|
126 |
len = strlen(str); |
133 |
len = strlen(str); |
|
|
134 |
char *str_ = strdup(str); |
127 |
|
135 |
|
128 |
switch(g_drawText) |
136 |
switch(g_drawText) |
129 |
{ |
137 |
{ |
130 |
case BitmapText: |
138 |
case BitmapText: |
131 |
glRasterPos2f(x+(width-glutBitmapLength(GLUT_BITMAP_HELVETICA_12, str))/2, y); |
139 |
glRasterPos2f(x+(width-glutBitmapLength(GLUT_BITMAP_HELVETICA_12, (const unsigned char*)str))/2, y); |
132 |
for (i=0; i<len; i++) |
140 |
for (i=0; i<len; i++) |
133 |
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str[i]); |
141 |
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str[i]); |
134 |
break; |
142 |
break; |
Lines 136-147
Link Here
|
136 |
glEnable(GL_TEXTURE_2D); |
144 |
glEnable(GL_TEXTURE_2D); |
137 |
glPushMatrix(); |
145 |
glPushMatrix(); |
138 |
glTranslatef(x, y, 0); |
146 |
glTranslatef(x, y, 0); |
139 |
txfRenderStringCenterJustify(helv_txf, str, len, width); |
147 |
txfRenderStringCenterJustify(helv_txf, str_, len, width); |
140 |
glPopMatrix(); |
148 |
glPopMatrix(); |
141 |
glDisable(GL_TEXTURE_2D); |
149 |
glDisable(GL_TEXTURE_2D); |
142 |
break; |
150 |
break; |
143 |
default: |
151 |
default: |
144 |
break; |
152 |
break; |
145 |
} |
153 |
} |
|
|
154 |
|
155 |
free(str_); |
146 |
} |
156 |
} |