summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorpixel <pixel>2002-12-09 01:39:02 +0000
committerpixel <pixel>2002-12-09 01:39:02 +0000
commit8125f1f4ee8215a4486acd514b1c96a2957fa809 (patch)
tree37a3e2dbe1ac003ad33e684f5a953af159d207f4 /lib
parent4fde43181e0c726a1e0de1e26ffe1983774d1ed0 (diff)
zou, some changes.
Diffstat (limited to 'lib')
-rw-r--r--lib/glfont.cc48
-rw-r--r--lib/gltexture.cc9
2 files changed, 45 insertions, 12 deletions
diff --git a/lib/glfont.cc b/lib/glfont.cc
index 833d18d..e58feaf 100644
--- a/lib/glfont.cc
+++ b/lib/glfont.cc
@@ -11,24 +11,55 @@ font file format
off|siz|description
---+---+-------------------------------
- 0 | 2 | Number of entries
+ 0 | 2 | Number of entries = nbentries
2 | 1 | Flags
3 | 1 | maxX (maximum width)
4 | 1 | maxY (maximum height)
5 | X | char entries
5+X| Y | char map
+X = (maxX * maxY + 1) * nbentries
+Y = nbentries * 4
+
+
Flags:
------
+=====
0000000R
R = RGBA (=1) or Alpha (=0)
-ABGR in 1232 format:
+RGBA in 1232 format:
ABBGGGRR
-variables comments
+
+Each entries:
+============
+
+off|siz|description
+---+---+-------------------------------
+ 0 | 1 | True size of the entry
+ 1 | Z | Datas
+
+Z = maxX * maxY
+
+
+Char map:
+========
+
+nbentries entries, each entry = 4 bytes = 2 uint16
+
+off|siz|description
+---+---+-------------------------------
+ 0 | 2 | Unicode (?)
+ 2 | 2 | Corresponding char entry
+
+I'm not sure about Unicode. I write this only to say it's an attempt to
+make the fonts "internationals". If the "unicode" is < 255, then it should
+match only one byte in the string. Otherwise, it should match two bytes.
+
+
+Variables comments
==================
nbcU = number of chars on X by texture
@@ -94,14 +125,11 @@ mogltk::font::font(const String & file) {
}
}
}
- curU += maxX;
- if (curU >= 256) {
+ if ((curU += maxX) >= 256) {
curU = 0;
- curV += maxY;
- if (curV >= 256) {
+ if ((curV += maxY) >= 256) {
curV = 0;
- curT++;
- curtex = (Uint8 *) fonttex[curT]->GetSurface()->pixels;
+ curtex = (Uint8 *) fonttex[++curT]->GetSurface()->pixels;
}
}
}
diff --git a/lib/gltexture.cc b/lib/gltexture.cc
index b96184f..2758c05 100644
--- a/lib/gltexture.cc
+++ b/lib/gltexture.cc
@@ -10,7 +10,7 @@ mogltk::texture * mogltk::texture::footer = 0;
#endif
mogltk::texture::texture(int w, int h, bool plane) throw (GeneralException) : width(w), height(h),
- texture_allocated(false), planar(plane) {
+ texture_allocated(false), planar(plane), tainted(true) {
if ((BITCOUNT(w) != 1) || (BITCOUNT(h) != 1))
throw GeneralException("Size of the texture not a power of 2!");
@@ -96,10 +96,11 @@ void mogltk::texture::Generate() {
}
texture_allocated = true;
+ tainted = false;
}
void mogltk::texture::Bind(bool expand) {
- if (!texture_allocated)
+ if ((!texture_allocated) || tainted)
Generate();
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, tex);
@@ -142,3 +143,7 @@ GLuint mogltk::texture::GetHeight() {
void mogltk::texture::Unbind(void) {
glDisable(GL_TEXTURE_2D);
}
+
+void mogltk::texture::Taint(void) {
+ tainted = true;
+}