Mercurial > projects > mde
comparison mde/gl/basic.d @ 48:a98ffb64f066
Implemented font rendering (grayscale only; i.e. non-LCD).
FontTexture creates a texture and caches glyphs.
Font supports multiple styles/faces, loaded from config file (should probably be loaded via Options instead).
TextBlock cache for glyph placement within a string.
committer: Diggory Hardy <diggory.hardy@gmail.com>
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Sat, 31 May 2008 12:40:26 +0100 |
parents | 0fd51d2c6c8a |
children | 9e1f05fbbcef |
comparison
equal
deleted
inserted
replaced
47:e0839643ff52 | 48:a98ffb64f066 |
---|---|
23 import tango.time.Time; // TimeSpan (type only; unused) | 23 import tango.time.Time; // TimeSpan (type only; unused) |
24 | 24 |
25 //BEGIN GL & window setup | 25 //BEGIN GL & window setup |
26 void glSetup () { | 26 void glSetup () { |
27 glDisable(GL_DEPTH_TEST); | 27 glDisable(GL_DEPTH_TEST); |
28 glEnable (GL_TEXTURE_2D); | 28 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); |
29 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); | |
30 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | |
31 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | |
32 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); | |
33 glEnable(GL_TEXTURE_2D); | |
34 glShadeModel(GL_FLAT); | |
29 | 35 |
30 glClearColor (0.0f, 0.0f, 0.0f, 0.0f); | 36 glClearColor (0.0f, 0.0f, 0.0f, 0.0f); |
31 | 37 |
32 glMatrixMode(GL_MODELVIEW); | 38 glMatrixMode(GL_MODELVIEW); |
33 glLoadIdentity(); | 39 glLoadIdentity(); |
40 | |
41 // Used for font rendering: | |
42 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | |
43 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | |
44 //NOTE: wrap mode may have an effect, but shouldn't be noticed... | |
34 } | 45 } |
35 | 46 |
36 void setProjection (int w, int h) { | 47 void setProjection (int w, int h) { |
37 glMatrixMode (GL_PROJECTION); | 48 glMatrixMode (GL_PROJECTION); |
38 glLoadIdentity (); | 49 glLoadIdentity (); |
53 // (temporary) | 64 // (temporary) |
54 void setColor (float r, float g, float b) { | 65 void setColor (float r, float g, float b) { |
55 glColor3f (r, g, b); | 66 glColor3f (r, g, b); |
56 } | 67 } |
57 void drawBox (int x, int y, int w, int h) { | 68 void drawBox (int x, int y, int w, int h) { |
69 glDisable(GL_TEXTURE_2D); | |
58 glRecti(x, y+h, x+w, y); | 70 glRecti(x, y+h, x+w, y); |
59 } | 71 } |
60 //END Drawing utils | 72 //END Drawing utils |