1 |
|
#include <functional> |
2 |
|
|
3 |
#include <freetype/freetype.h> |
#include <freetype/freetype.h> |
4 |
|
|
5 |
#include <libmosaic/Mosaic.hxx> |
#include <libmosaic/Mosaic.hxx> |
247 |
} |
} |
248 |
}; |
}; |
249 |
|
|
250 |
|
inline void normalBindTexture(const Mosaic::Id &t) { |
251 |
|
t.bind(GL_TEXTURE_2D); |
252 |
|
} |
253 |
|
|
254 |
|
inline void normalBindTexture_01(const Mosaic::Id &t) { |
255 |
|
glActiveTextureARB(GL_TEXTURE1); |
256 |
|
t.bind(); |
257 |
|
glActiveTextureARB(GL_TEXTURE0); |
258 |
|
t.bind(); |
259 |
|
} |
260 |
|
|
261 |
template<class Glyphs, class Char> class Renderer { |
template<class Glyphs, class Char> class Renderer { |
262 |
Mosaic::Id curtex; |
Mosaic::Id curtex; |
263 |
public: |
public: |
276 |
/** Render a single character. |
/** Render a single character. |
277 |
* @return New x position. |
* @return New x position. |
278 |
*/ |
*/ |
279 |
template<class Vertex> float renderChar(Char c, float x, float y, Vertex &vertex) |
template<class Vertex, class TexBind> |
280 |
|
float renderChar(Char c, float x, float y, Vertex &vertex, |
281 |
|
const TexBind &t) |
282 |
{ // returns new x pos |
{ // returns new x pos |
283 |
QuadGlyph &glyph = g[(unsigned)c]; |
QuadGlyph &glyph = g[(unsigned)c]; |
284 |
if(!glyph.valid()) return x; |
if(!glyph.valid()) return x; |
285 |
if(glyph.rect.tex != curtex) { |
if(glyph.rect.tex != curtex) { |
286 |
glEnd(); |
glEnd(); |
287 |
glyph.rect.tex.bind(); |
t(glyph.rect.tex); |
288 |
glBegin(GL_QUADS); |
glBegin(GL_QUADS); |
289 |
} |
} |
290 |
glyph.draw(x, y, vertex); |
glyph.draw(x, y, vertex); |
303 |
* in order to allow nonlinear transforms of vertices, |
* in order to allow nonlinear transforms of vertices, |
304 |
* all vertex commands are routed through the Vertex object. |
* all vertex commands are routed through the Vertex object. |
305 |
*/ |
*/ |
306 |
template<class Iterator, class RandomRenderer, class Vertex> |
template<class Iterator, class RandomRenderer, class Vertex, class TexBind> |
307 |
float renderIter( |
float renderIter( |
308 |
RandomRenderer &r, |
RandomRenderer &r, |
309 |
Iterator begin, Iterator end, |
Iterator begin, Iterator end, |
310 |
float x, float y, |
float x, float y, |
311 |
Vertex &vertex) { |
Vertex &vertex, const TexBind &t) { |
312 |
r.startRendering(); |
r.startRendering(); |
313 |
while(begin != end) { |
while(begin != end) { |
314 |
x = r.renderChar(*begin, x, y, vertex); |
x = r.renderChar(*begin, x, y, vertex, t); |
315 |
begin++; |
begin++; |
316 |
} |
} |
317 |
r.endRendering(); |
r.endRendering(); |