From 8125f1f4ee8215a4486acd514b1c96a2957fa809 Mon Sep 17 00:00:00 2001 From: pixel Date: Mon, 9 Dec 2002 01:39:02 +0000 Subject: zou, some changes. --- include/gltexture.h | 3 ++- lib/glfont.cc | 48 ++++++++++++++++++++++++++++++++++++++---------- lib/gltexture.cc | 9 +++++++-- src/Makefile.am | 12 ++++++++++++ 4 files changed, 59 insertions(+), 13 deletions(-) diff --git a/include/gltexture.h b/include/gltexture.h index 7305eb5..1e4c3d2 100644 --- a/include/gltexture.h +++ b/include/gltexture.h @@ -16,11 +16,12 @@ namespace mogltk { GLuint GetWidth(); GLuint GetHeight(); static void Unbind(void); + void Taint(void); private: GLuint width, height, tex; bool texture_allocated; SDL_Surface * surface; - bool planar; + bool planar, tainted; #ifdef TRACE_TEXTURES static texture * header; static texture * footer; 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; +} diff --git a/src/Makefile.am b/src/Makefile.am index e69de29..59b7e19 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -0,0 +1,12 @@ +localedir = $(datadir)/locale +DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@ +AM_CPPFLAGS = -Wall -Wstrict-prototypes @SDL_CFLAGS@ @BALTISOT_CFLAGS@ +INCLUDES = -I.. -I../include -I$(includedir) + +noinst_PROGRAMS = test + +test_SOURCES = test.cc + +LDADD = ../lib/libmogltk.la -lefence + +test_LDADD = $(LDADD) -- cgit v1.2.3