Differences From Artifact [d117eaf6b5]:
- File src/rendertext.mm — part of check-in [753ff34122] at 2025-03-08 03:05:16 on branch trunk — More style cleanup (user: js, size: 6532) [annotate] [blame] [check-ins using]
To Artifact [4a2a0ee6d3]:
- File src/rendertext.m — part of check-in [12cac9666a] at 2025-03-20 22:22:40 on branch trunk — Convert remaining files to pure Objective-C (user: js, size: 6369) [annotate] [blame] [check-ins using]
- File
src/rendertext.mm
— part of check-in
[489124a92f]
at
2025-03-16 10:11:39
on branch trunk
— Use one autorelease pool per frame
This way, nowhere else autorelease pools need to be managed. (user: js, size: 6369) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
98 99 100 101 102 103 104 | { 270, 448, 310, 512 }, //} { 310, 448, 363, 512 }, //~ }; int text_width(OFString *string) { | < | | | | | | | | | | | | | | | | | | | | | | < < | | | | | | < < | | | | | | | | | | | | | | < < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | { 270, 448, 310, 512 }, //} { 310, 448, 363, 512 }, //~ }; int text_width(OFString *string) { const char *str = string.UTF8String; size_t len = string.UTF8StringLength; int x = 0; for (int i = 0; i < len; i++) { int c = str[i]; if (c == '\t') { x = (x + PIXELTAB) / PIXELTAB * PIXELTAB; continue; } if (c == '\f') continue; if (c == ' ') { x += FONTH / 2; continue; } c -= 33; if (c < 0 || c >= 95) continue; int in_width = char_coords[c][2] - char_coords[c][0]; x += in_width + 1; } return x; } void draw_textf(OFConstantString *format, int left, int top, int gl_num, ...) { va_list arguments; va_start(arguments, gl_num); OFString *str = [[OFString alloc] initWithFormat:format arguments:arguments]; va_end(arguments); draw_text(str, left, top, gl_num); } void draw_text(OFString *string, int left, int top, int gl_num) { glBlendFunc(GL_ONE, GL_ONE); glBindTexture(GL_TEXTURE_2D, gl_num); glColor3ub(255, 255, 255); int x = left; int y = top; int i; float in_left, in_top, in_right, in_bottom; int in_width, in_height; const char *str = string.UTF8String; size_t len = string.UTF8StringLength; for (i = 0; i < len; i++) { int c = str[i]; if (c == '\t') { x = (x - left + PIXELTAB) / PIXELTAB * PIXELTAB + left; continue; } if (c == '\f') { glColor3ub(64, 255, 128); continue; } if (c == ' ') { x += FONTH / 2; continue; } c -= 33; if (c < 0 || c >= 95) continue; in_left = ((float)char_coords[c][0]) / 512.0f; in_top = ((float)char_coords[c][1] + 2) / 512.0f; in_right = ((float)char_coords[c][2]) / 512.0f; in_bottom = ((float)char_coords[c][3] - 2) / 512.0f; in_width = char_coords[c][2] - char_coords[c][0]; in_height = char_coords[c][3] - char_coords[c][1]; glBegin(GL_QUADS); glTexCoord2f(in_left, in_top); glVertex2i(x, y); glTexCoord2f(in_right, in_top); glVertex2i(x + in_width, y); glTexCoord2f(in_right, in_bottom); glVertex2i(x + in_width, y + in_height); glTexCoord2f(in_left, in_bottom); glVertex2i(x, y + in_height); glEnd(); xtraverts += 4; x += in_width + 1; } } // also Don's code, so goes in here too :) void draw_envbox_aux(float s0, float t0, int x0, int y0, int z0, float s1, float t1, |
︙ | ︙ |