From 3e2e4fe9e05d73ba1c1b5de93160bb1cdb7cb56e Mon Sep 17 00:00:00 2001 From: pixel Date: Fri, 28 Mar 2003 13:36:38 +0000 Subject: SDL backend mostly finished --- lib/font.cc | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) (limited to 'lib/font.cc') diff --git a/lib/font.cc b/lib/font.cc index 9e77ae2..93588bf 100644 --- a/lib/font.cc +++ b/lib/font.cc @@ -1,10 +1,12 @@ #include +#include +#include #include "base.h" #include "font.h" -#include "Input.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif +#include "engine.h" Uint8 prescale2[4] = { 0, 85, 170, 255 }, prescale3[8] = { 0, 36, 72, 109, 145, 182, 218, 255 }; @@ -163,16 +165,16 @@ mogltk::font::~font() { } void mogltk::font::drawentry(Uint16 entry, int x, int y, ColorP c) { - bool was2D; + bool locked = false; int trueentry, cx, cy, px, py; + SDL_Rect src, dst; - return; -#if 0 - was2D = mogltk::glbase::is2D(); - - if (!was2D) - mogltk::glbase::Enter2DMode(); - + if (SDL_MUSTLOCK(mogltk::engine::base_o->getsurface())) { + locked = true; + SDL_LockSurface(mogltk::engine::base_o->getsurface()); + } + +#if 0 if (shadow) { int os = shadow; shadow = 0; @@ -181,27 +183,23 @@ void mogltk::font::drawentry(Uint16 entry, int x, int y, ColorP c) { shadow = os; } - +#endif + 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(); + src.x = px; src.y = py; src.w = maxX; src.h = maxY; + dst.x = x; dst.y = y; dst.w = maxX; dst.h = maxY; - if (!was2D) - mogltk::glbase::Leave2DMode(); -#endif + SDL_BlitSurface(fonttex[entry / nbcT]->GetSurface(), &src, mogltk::engine::base_o->getsurface(), &dst); + + if (locked) + SDL_UnlockSurface(mogltk::engine::base_o->getsurface()); } void mogltk::font::putcursor(int x, int y) { -- cgit v1.2.3