summaryrefslogtreecommitdiff
path: root/lib/glfont.cc
blob: cd2fca3c83f8ea54bf9cf7217f86fde852c80a8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "engine.h"
#include "glbase.h"
#include "glfont.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

mogltk::glfont::glfont(Handle * ffont) : font(ffont) {
}

mogltk::glfont::~glfont() {
}

void mogltk::glfont::drawentry(Uint16 entry, int x, int y, ColorP c) {
    bool was2D;
    int trueentry, cx, cy, px, py;
    
    was2D = mogltk::engine::glbase_o->is2D();
    
    if (!was2D)
	mogltk::engine::glbase_o->Enter2DMode();
    
    if (shadow) {
	int os = shadow;
	shadow = 0;
	
	drawentry(entry, x + os, y + os, BLACK);
	
	shadow = os;
    }
    
    y -= base;
    
    Bind(entry / nbcT);
    c.Bind();
    trueentry = entry % nbcT;
    cx = trueentry % nbcU;
    cy = trueentry / nbcU;
    px = cx * maxX;
    py = cy * maxY;
    
    glBegin(GL_TRIANGLE_STRIP);
    glTexCoord2i(px           , py           ); glVertex2i(x           , y           );
    glTexCoord2i(px + maxX - 1, py           ); glVertex2i(x + maxX - 1, y           );
    glTexCoord2i(px           , py + maxY - 1); glVertex2i(x           , y + maxY - 1);
    glTexCoord2i(px + maxX - 1, py + maxY - 1); glVertex2i(x + maxX - 1, y + maxY - 1);
    glEnd();
    
    if (!was2D)
	mogltk::engine::glbase_o->Leave2DMode();
}