A start on the tinygl stuff

This commit is contained in:
Joel Teichroeb 2011-05-23 15:08:27 -07:00
parent 65eb5d8ea2
commit fad79d609a
4 changed files with 53 additions and 4 deletions

View file

@ -86,9 +86,9 @@ public:
virtual void drawBitmap(const Bitmap *bitmap) = 0;
virtual void destroyBitmap(BitmapData *bitmap) = 0;
virtual void createFont(Font *font) { }
virtual void destroyFont(Font *font) { }
virtual void drawText(int x, int y, const Common::String &text, Font *font, Color &color) { }
virtual void createFont(Font *font) = 0;
virtual void destroyFont(Font *font) = 0;
virtual void drawText(int x, int y, const Common::String &text, Font *font, Color &color) = 0;
virtual Bitmap *getScreenshot(int w, int h) = 0;
virtual void storeDisplay() = 0;

View file

@ -883,9 +883,10 @@ void GfxOpenGL::drawText(int x, int y, const Common::String &text, Font *font, C
glColor3f(color.getRed()/255.f, color.getGreen()/255.f, color.getBlue()/255.f);
uint8 size = ((uint8 *)font->_sizes)[0];
GLuint texture = *((GLuint *)font->_texIds);
y += font->getBaseOffsetY();
for (uint i = 0; i < text.size(); ++i) {
uint8 character = text[i];
int w = y + font->getCharStartingLine(character) + font->getBaseOffsetY();
int w = y + font->getCharStartingLine(character);
glBindTexture(GL_TEXTURE_2D, texture);

View file

@ -693,6 +693,50 @@ void GfxTinyGL::drawBitmap(const Bitmap *bitmap) {
void GfxTinyGL::destroyBitmap(BitmapData *) { }
void GfxTinyGL::createFont(Font *font) {
}
void GfxTinyGL::destroyFont(Font *font) {
}
void GfxTinyGL::drawText(int x, int y, const Common::String &text, Font *font, Color &fgColor) {
y += font->getBaseOffsetY();
uint16 *texData = new uint16[32 * 32];
for (uint i = 0; i < text.size(); ++i) {
uint8 character = text[i];
int width = font->getCharDataWidth(character), height = font->getCharDataHeight(character);
byte *data = (byte *)font->getCharData(character);
uint16 *texDataPtr = texData;
uint8 *bitmapData = data;
uint8 r = fgColor.getRed();
uint8 g = fgColor.getGreen();
uint8 b = fgColor.getBlue();
uint16 color = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);
if (color == 0xf81f)
color = 0xf81e;
for (int i = 0; i < width * height; i++, texDataPtr++, bitmapData++) {
byte pixel = *bitmapData;
if (pixel == 0x00) {
WRITE_UINT16(texDataPtr, 0xf81f);
} else if (pixel == 0x80) {
*texDataPtr = 0;
} else if (pixel == 0xFF) {
WRITE_UINT16(texDataPtr, color);
}
}
TinyGLBlit((byte *)_zb->pbuf, (byte *)texData, x, y + font->getCharStartingLine(character), width, height, true);
x += font->getCharWidth(character);
}
delete[] texData;
}
void GfxTinyGL::createMaterial(Material *material, const char *data, const CMap *cmap) {
material->_textures = new TGLuint[material->_numImages];
tglGenTextures(material->_numImages, (TGLuint *)material->_textures);

View file

@ -77,6 +77,10 @@ public:
void drawBitmap(const Bitmap *bitmap);
void destroyBitmap(BitmapData *bitmap);
void createFont(Font *font);
void destroyFont(Font *font);
void drawText(int x, int y, const Common::String &text, Font *font, Color &color);
void dimScreen();
void dimRegion(int x, int y, int w, int h, float level);