From 121e7c772cfc7b3e1305a03144264fc5b66564c2 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Thu, 26 Jul 2012 15:06:06 +0100 Subject: Rename .inc files to inl diff --git a/src/graphics/OpenGLDrawMethods.inc b/src/graphics/OpenGLDrawMethods.inc deleted file mode 100644 index 8d94a14..0000000 --- a/src/graphics/OpenGLDrawMethods.inc +++ /dev/null @@ -1,334 +0,0 @@ -int Graphics::drawtext(int x, int y, const char *s, int r, int g, int b, int a) -{ - if(!strlen(s)) - return 0; - int oR = r, oG = g, oB = b; - int width, height; - Graphics::textsize(s, width, height); - VideoBuffer texture(width, height); - int characterX = 0, characterY = 0; - int startX = characterX; - for (; *s; s++) - { - if (*s == '\n') - { - characterX = startX; - characterY += FONT_H+2; - } - else if (*s == '\x0F') - { - if(!s[1] || !s[2] || !s[3]) break; - oR = r; - oG = g; - oB = b; - r = s[1]; - g = s[2]; - b = s[3]; - s += 3; - } - else if (*s == '\x0E') - { - r = oR; - g = oG; - b = oB; - } - else if (*s == '\b') - { - if(!s[1]) break; - switch (s[1]) - { - case 'w': - r = g = b = 255; - break; - case 'g': - r = g = b = 192; - break; - case 'o': - r = 255; - g = 216; - b = 32; - break; - case 'r': - r = 255; - g = b = 0; - break; - case 'l': - r = 255; - g = b = 75; - break; - case 'b': - r = g = 0; - b = 255; - break; - case 't': - b = 255; - g = 170; - r = 32; - break; - } - s++; - } - else - { - characterX = texture.SetCharacter(characterX, characterY, *(unsigned char *)s, r, g, b, a); - } - } - glEnable(GL_TEXTURE_2D); - - //Generate texture - glBindTexture(GL_TEXTURE_2D, textTexture); - - //Draw texture - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture.Width, texture.Height, 0, GL_BGRA, GL_UNSIGNED_BYTE, texture.Buffer); - - //glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texture.Width, texture.Height, GL_BGRA, GL_UNSIGNED_BYTE, texture.Buffer); - glBegin(GL_QUADS); - glTexCoord2d(0, 0); - glVertex2f(x, y); - glTexCoord2d(1, 0); - glVertex2f(x+texture.Width, y); - glTexCoord2d(1, 1); - glVertex2f(x+texture.Width, y+texture.Height); - glTexCoord2d(0, 1); - glVertex2f(x, y+texture.Height); - glEnd(); - - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); - - return x; -} - -int Graphics::drawtext(int x, int y, std::string s, int r, int g, int b, int a) -{ - return drawtext(x, y, s.c_str(), r, g, b, a); -} - -TPT_INLINE int Graphics::drawchar(int x, int y, int c, int r, int g, int b, int a) -{ - int i, j, w, bn = 0, ba = 0; - char *rp = font_data + font_ptrs[c]; - w = *(rp++); - VideoBuffer texture(w, 12); - texture.SetCharacter(0, 0, c, r, g, b, a); - - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, textTexture); - - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture.Width, texture.Height, 0, GL_BGRA, GL_UNSIGNED_BYTE, texture.Buffer); - glBegin(GL_QUADS); - glTexCoord2d(0, 0); - glVertex2f(x, y); - glTexCoord2d(1, 0); - glVertex2f(x+texture.Width, y); - glTexCoord2d(1, 1); - glVertex2f(x+texture.Width, y+texture.Height); - glTexCoord2d(0, 1); - glVertex2f(x, y+texture.Height); - glEnd(); - - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); - - return x + w; -} - -TPT_INLINE int Graphics::addchar(int x, int y, int c, int r, int g, int b, int a) -{ - int i, j, w, bn = 0, ba = 0; - char *rp = font_data + font_ptrs[c]; - w = *(rp++); - VideoBuffer texture(w, 12); - texture.AddCharacter(0, 0, c, r, g, b, a); - - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, textTexture); - glBlendFunc(GL_ONE, GL_ONE); - - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture.Width, texture.Height, 0, GL_BGRA, GL_UNSIGNED_BYTE, texture.Buffer); - glBegin(GL_QUADS); - glTexCoord2d(0, 0); - glVertex2f(x, y); - glTexCoord2d(1, 0); - glVertex2f(x+texture.Width, y); - glTexCoord2d(1, 1); - glVertex2f(x+texture.Width, y+texture.Height); - glTexCoord2d(0, 1); - glVertex2f(x, y+texture.Height); - glEnd(); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); - - return x + w; -} - -TPT_INLINE void Graphics::xor_pixel(int x, int y) -{ - //OpenGL doesn't support single pixel manipulation, there are ways around it, but with poor performance -} - -TPT_INLINE void Graphics::blendpixel(int x, int y, int r, int g, int b, int a) -{ - //OpenGL doesn't support single pixel manipulation, there are ways around it, but with poor performance -} - -TPT_INLINE void Graphics::addpixel(int x, int y, int r, int g, int b, int a) -{ - //OpenGL doesn't support single pixel manipulation, there are ways around it, but with poor performance -} - -void Graphics::xor_line(int x, int y, int x2, int y2) -{ - glEnable(GL_COLOR_LOGIC_OP); - //glEnable(GL_LINE_SMOOTH); - glLogicOp(GL_XOR); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glBegin(GL_LINES); - glVertex2i(x, y); - glVertex2i(x2, y2); - glEnd(); - glDisable(GL_COLOR_LOGIC_OP); -} - -void Graphics::xor_rect(int x, int y, int width, int height) -{ - glEnable(GL_COLOR_LOGIC_OP); - //glEnable(GL_LINE_SMOOTH); - glLogicOp(GL_XOR); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glBegin(GL_LINE_STRIP); - glVertex2i(x, y); - glVertex2i(x+width, y); - glVertex2i(x+width, y+height); - glVertex2i(x, y+height); - glVertex2i(x, y); - glEnd(); - glDisable(GL_COLOR_LOGIC_OP); -} - -void Graphics::xor_bitmap(unsigned char * bitmap, int x, int y, int w, int h) -{ - //glEnable(GL_COLOR_LOGIC_OP); - //glLogicOp(GL_XOR); - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, textTexture); - - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_ALPHA, GL_UNSIGNED_BYTE, bitmap); - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - - glBegin(GL_QUADS); - glTexCoord2d(0, 0); - glVertex2f(x, y); - glTexCoord2d(1, 0); - glVertex2f(x+w, y); - glTexCoord2d(1, 1); - glVertex2f(x+w, y+h); - glTexCoord2d(0, 1); - glVertex2f(x, y+h); - glEnd(); - - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); - //glDisable(GL_COLOR_LOGIC_OP); -} - -void Graphics::draw_line(int x, int y, int x2, int y2, int r, int g, int b, int a) -{ - a = 255; - glColor4ub(r, g, b, a); - glBegin(GL_LINES); - glVertex2i(x, y); - glVertex2i(x2, y2); - glEnd(); -} - -void Graphics::drawrect(int x, int y, int width, int height, int r, int g, int b, int a) -{ - float fx = float(x)+0.5f; - float fy = float(y)+0.5f; - float fwidth = width-1.0f; - float fheight = height-1.0f; - //x++; - //y++; - //height-=2; - //width-=2; - glColor4ub(r, g, b, a); - glBegin(GL_LINE_STRIP); - glVertex2f(fx, fy); - glVertex2f(fx+fwidth, fy); - glVertex2f(fx+fwidth, fy+fheight); - glVertex2f(fx, fy+fheight); //+1 is a hack to prevent squares from missing their corners, will make smoothed lines look like SHIT - glVertex2f(fx, fy); - glEnd(); -} - -void Graphics::fillrect(int x, int y, int width, int height, int r, int g, int b, int a) -{ - /*x++; - y++; - width-=1; - height-=1;*/ - - glColor4ub(r, g, b, a); - glBegin(GL_QUADS); - glVertex2i(x, y); - glVertex2i(x+width, y); - glVertex2i(x+width, y+height); - glVertex2i(x, y+height); - glEnd(); -} - -void Graphics::gradientrect(int x, int y, int width, int height, int r, int g, int b, int a, int r2, int g2, int b2, int a2) -{ - glBegin(GL_QUADS); - glColor4ub(r, g, b, a); - glVertex2i(x, y); - glColor4ub(r2, g2, b2, a2); - glVertex2i(x+width, y); - glColor4ub(r2, g2, b2, a2); - glVertex2i(x+width, y+height); - glColor4ub(r, g, b, a); - glVertex2i(x, y+height); - glEnd(); -} - -void Graphics::clearrect(int x, int y, int width, int height) -{ - glColor4ub(0, 0, 0, 255); - glBegin(GL_QUADS); - glVertex2i(x, y); - glVertex2i(x+width, y); - glVertex2i(x+width, y+height); - glVertex2i(x, y+height); - glEnd(); -} - -void Graphics::draw_image(pixel *img, int x, int y, int w, int h, int a) -{ - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, textTexture); - - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, img); - glBegin(GL_QUADS); - glTexCoord2d(0, 0); - glVertex2f(x, y); - glTexCoord2d(1, 0); - glVertex2f(x+w, y); - glTexCoord2d(1, 1); - glVertex2f(x+w, y+h); - glTexCoord2d(0, 1); - glVertex2f(x, y+h); - glEnd(); - - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); -} \ No newline at end of file diff --git a/src/graphics/OpenGLDrawMethods.inl b/src/graphics/OpenGLDrawMethods.inl new file mode 100644 index 0000000..8d94a14 --- /dev/null +++ b/src/graphics/OpenGLDrawMethods.inl @@ -0,0 +1,334 @@ +int Graphics::drawtext(int x, int y, const char *s, int r, int g, int b, int a) +{ + if(!strlen(s)) + return 0; + int oR = r, oG = g, oB = b; + int width, height; + Graphics::textsize(s, width, height); + VideoBuffer texture(width, height); + int characterX = 0, characterY = 0; + int startX = characterX; + for (; *s; s++) + { + if (*s == '\n') + { + characterX = startX; + characterY += FONT_H+2; + } + else if (*s == '\x0F') + { + if(!s[1] || !s[2] || !s[3]) break; + oR = r; + oG = g; + oB = b; + r = s[1]; + g = s[2]; + b = s[3]; + s += 3; + } + else if (*s == '\x0E') + { + r = oR; + g = oG; + b = oB; + } + else if (*s == '\b') + { + if(!s[1]) break; + switch (s[1]) + { + case 'w': + r = g = b = 255; + break; + case 'g': + r = g = b = 192; + break; + case 'o': + r = 255; + g = 216; + b = 32; + break; + case 'r': + r = 255; + g = b = 0; + break; + case 'l': + r = 255; + g = b = 75; + break; + case 'b': + r = g = 0; + b = 255; + break; + case 't': + b = 255; + g = 170; + r = 32; + break; + } + s++; + } + else + { + characterX = texture.SetCharacter(characterX, characterY, *(unsigned char *)s, r, g, b, a); + } + } + glEnable(GL_TEXTURE_2D); + + //Generate texture + glBindTexture(GL_TEXTURE_2D, textTexture); + + //Draw texture + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture.Width, texture.Height, 0, GL_BGRA, GL_UNSIGNED_BYTE, texture.Buffer); + + //glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texture.Width, texture.Height, GL_BGRA, GL_UNSIGNED_BYTE, texture.Buffer); + glBegin(GL_QUADS); + glTexCoord2d(0, 0); + glVertex2f(x, y); + glTexCoord2d(1, 0); + glVertex2f(x+texture.Width, y); + glTexCoord2d(1, 1); + glVertex2f(x+texture.Width, y+texture.Height); + glTexCoord2d(0, 1); + glVertex2f(x, y+texture.Height); + glEnd(); + + glBindTexture(GL_TEXTURE_2D, 0); + glDisable(GL_TEXTURE_2D); + + return x; +} + +int Graphics::drawtext(int x, int y, std::string s, int r, int g, int b, int a) +{ + return drawtext(x, y, s.c_str(), r, g, b, a); +} + +TPT_INLINE int Graphics::drawchar(int x, int y, int c, int r, int g, int b, int a) +{ + int i, j, w, bn = 0, ba = 0; + char *rp = font_data + font_ptrs[c]; + w = *(rp++); + VideoBuffer texture(w, 12); + texture.SetCharacter(0, 0, c, r, g, b, a); + + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, textTexture); + + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture.Width, texture.Height, 0, GL_BGRA, GL_UNSIGNED_BYTE, texture.Buffer); + glBegin(GL_QUADS); + glTexCoord2d(0, 0); + glVertex2f(x, y); + glTexCoord2d(1, 0); + glVertex2f(x+texture.Width, y); + glTexCoord2d(1, 1); + glVertex2f(x+texture.Width, y+texture.Height); + glTexCoord2d(0, 1); + glVertex2f(x, y+texture.Height); + glEnd(); + + glBindTexture(GL_TEXTURE_2D, 0); + glDisable(GL_TEXTURE_2D); + + return x + w; +} + +TPT_INLINE int Graphics::addchar(int x, int y, int c, int r, int g, int b, int a) +{ + int i, j, w, bn = 0, ba = 0; + char *rp = font_data + font_ptrs[c]; + w = *(rp++); + VideoBuffer texture(w, 12); + texture.AddCharacter(0, 0, c, r, g, b, a); + + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, textTexture); + glBlendFunc(GL_ONE, GL_ONE); + + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture.Width, texture.Height, 0, GL_BGRA, GL_UNSIGNED_BYTE, texture.Buffer); + glBegin(GL_QUADS); + glTexCoord2d(0, 0); + glVertex2f(x, y); + glTexCoord2d(1, 0); + glVertex2f(x+texture.Width, y); + glTexCoord2d(1, 1); + glVertex2f(x+texture.Width, y+texture.Height); + glTexCoord2d(0, 1); + glVertex2f(x, y+texture.Height); + glEnd(); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBindTexture(GL_TEXTURE_2D, 0); + glDisable(GL_TEXTURE_2D); + + return x + w; +} + +TPT_INLINE void Graphics::xor_pixel(int x, int y) +{ + //OpenGL doesn't support single pixel manipulation, there are ways around it, but with poor performance +} + +TPT_INLINE void Graphics::blendpixel(int x, int y, int r, int g, int b, int a) +{ + //OpenGL doesn't support single pixel manipulation, there are ways around it, but with poor performance +} + +TPT_INLINE void Graphics::addpixel(int x, int y, int r, int g, int b, int a) +{ + //OpenGL doesn't support single pixel manipulation, there are ways around it, but with poor performance +} + +void Graphics::xor_line(int x, int y, int x2, int y2) +{ + glEnable(GL_COLOR_LOGIC_OP); + //glEnable(GL_LINE_SMOOTH); + glLogicOp(GL_XOR); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glBegin(GL_LINES); + glVertex2i(x, y); + glVertex2i(x2, y2); + glEnd(); + glDisable(GL_COLOR_LOGIC_OP); +} + +void Graphics::xor_rect(int x, int y, int width, int height) +{ + glEnable(GL_COLOR_LOGIC_OP); + //glEnable(GL_LINE_SMOOTH); + glLogicOp(GL_XOR); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glBegin(GL_LINE_STRIP); + glVertex2i(x, y); + glVertex2i(x+width, y); + glVertex2i(x+width, y+height); + glVertex2i(x, y+height); + glVertex2i(x, y); + glEnd(); + glDisable(GL_COLOR_LOGIC_OP); +} + +void Graphics::xor_bitmap(unsigned char * bitmap, int x, int y, int w, int h) +{ + //glEnable(GL_COLOR_LOGIC_OP); + //glLogicOp(GL_XOR); + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, textTexture); + + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_ALPHA, GL_UNSIGNED_BYTE, bitmap); + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + + glBegin(GL_QUADS); + glTexCoord2d(0, 0); + glVertex2f(x, y); + glTexCoord2d(1, 0); + glVertex2f(x+w, y); + glTexCoord2d(1, 1); + glVertex2f(x+w, y+h); + glTexCoord2d(0, 1); + glVertex2f(x, y+h); + glEnd(); + + glBindTexture(GL_TEXTURE_2D, 0); + glDisable(GL_TEXTURE_2D); + //glDisable(GL_COLOR_LOGIC_OP); +} + +void Graphics::draw_line(int x, int y, int x2, int y2, int r, int g, int b, int a) +{ + a = 255; + glColor4ub(r, g, b, a); + glBegin(GL_LINES); + glVertex2i(x, y); + glVertex2i(x2, y2); + glEnd(); +} + +void Graphics::drawrect(int x, int y, int width, int height, int r, int g, int b, int a) +{ + float fx = float(x)+0.5f; + float fy = float(y)+0.5f; + float fwidth = width-1.0f; + float fheight = height-1.0f; + //x++; + //y++; + //height-=2; + //width-=2; + glColor4ub(r, g, b, a); + glBegin(GL_LINE_STRIP); + glVertex2f(fx, fy); + glVertex2f(fx+fwidth, fy); + glVertex2f(fx+fwidth, fy+fheight); + glVertex2f(fx, fy+fheight); //+1 is a hack to prevent squares from missing their corners, will make smoothed lines look like SHIT + glVertex2f(fx, fy); + glEnd(); +} + +void Graphics::fillrect(int x, int y, int width, int height, int r, int g, int b, int a) +{ + /*x++; + y++; + width-=1; + height-=1;*/ + + glColor4ub(r, g, b, a); + glBegin(GL_QUADS); + glVertex2i(x, y); + glVertex2i(x+width, y); + glVertex2i(x+width, y+height); + glVertex2i(x, y+height); + glEnd(); +} + +void Graphics::gradientrect(int x, int y, int width, int height, int r, int g, int b, int a, int r2, int g2, int b2, int a2) +{ + glBegin(GL_QUADS); + glColor4ub(r, g, b, a); + glVertex2i(x, y); + glColor4ub(r2, g2, b2, a2); + glVertex2i(x+width, y); + glColor4ub(r2, g2, b2, a2); + glVertex2i(x+width, y+height); + glColor4ub(r, g, b, a); + glVertex2i(x, y+height); + glEnd(); +} + +void Graphics::clearrect(int x, int y, int width, int height) +{ + glColor4ub(0, 0, 0, 255); + glBegin(GL_QUADS); + glVertex2i(x, y); + glVertex2i(x+width, y); + glVertex2i(x+width, y+height); + glVertex2i(x, y+height); + glEnd(); +} + +void Graphics::draw_image(pixel *img, int x, int y, int w, int h, int a) +{ + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, textTexture); + + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, img); + glBegin(GL_QUADS); + glTexCoord2d(0, 0); + glVertex2f(x, y); + glTexCoord2d(1, 0); + glVertex2f(x+w, y); + glTexCoord2d(1, 1); + glVertex2f(x+w, y+h); + glTexCoord2d(0, 1); + glVertex2f(x, y+h); + glEnd(); + + glBindTexture(GL_TEXTURE_2D, 0); + glDisable(GL_TEXTURE_2D); +} \ No newline at end of file diff --git a/src/graphics/OpenGLGraphics.cpp b/src/graphics/OpenGLGraphics.cpp index baef250..66a1753 100644 --- a/src/graphics/OpenGLGraphics.cpp +++ b/src/graphics/OpenGLGraphics.cpp @@ -69,7 +69,7 @@ void Graphics::Finalise() #define VIDXRES XRES+BARSIZE #define VIDYRES YRES+MENUSIZE #define PIXELMETHODS_CLASS Graphics -#include "OpenGLDrawMethods.inc" +#include "OpenGLDrawMethods.inl" #undef VIDYRES #undef VIDXRES #undef PIXELMETHODS_CLASS diff --git a/src/graphics/RasterDrawMethods.inc b/src/graphics/RasterDrawMethods.inc deleted file mode 100644 index 76b9dde..0000000 --- a/src/graphics/RasterDrawMethods.inc +++ /dev/null @@ -1,351 +0,0 @@ -#include "font.h" - -int PIXELMETHODS_CLASS::drawtext(int x, int y, const char *s, int r, int g, int b, int a) -{ - if(!strlen(s)) - return 0; - int width, height; - - int oR = r, oG = g, oB = b; - int characterX = x, characterY = y; - int startX = characterX; - for (; *s; s++) - { - if (*s == '\n') - { - characterX = startX; - characterY += FONT_H+2; - } - else if (*s == '\x0F') - { - if(!s[1] || !s[2] || !s[3]) break; - oR = r; - oG = g; - oB = b; - r = s[1]; - g = s[2]; - b = s[3]; - s += 3; - } - else if (*s == '\x0E') - { - r = oR; - g = oG; - b = oB; - } - else if (*s == '\b') - { - if(!s[1]) break; - switch (s[1]) - { - case 'w': - r = g = b = 255; - break; - case 'g': - r = g = b = 192; - break; - case 'o': - r = 255; - g = 216; - b = 32; - break; - case 'r': - r = 255; - g = b = 0; - break; - case 'l': - r = 255; - g = b = 75; - break; - case 'b': - r = g = 0; - b = 255; - break; - case 't': - b = 255; - g = 170; - r = 32; - break; - } - s++; - } - else - { - characterX = drawchar(characterX, characterY, *(unsigned char *)s, r, g, b, a); - } - } - return x; -} - -int PIXELMETHODS_CLASS::drawtext(int x, int y, std::string s, int r, int g, int b, int a) -{ - return drawtext(x, y, s.c_str(), r, g, b, a); -} - -TPT_INLINE int PIXELMETHODS_CLASS::drawchar(int x, int y, int c, int r, int g, int b, int a) -{ - int i, j, w, bn = 0, ba = 0; - char *rp = font_data + font_ptrs[c]; - w = *(rp++); - for (j=0; j>= 2; - bn -= 2; - } - return x + w; -} - -TPT_INLINE int PIXELMETHODS_CLASS::addchar(int x, int y, int c, int r, int g, int b, int a) -{ - int i, j, w, bn = 0, ba = 0; - char *rp = font_data + font_ptrs[c]; - w = *(rp++); - for (j=0; j>= 2; - bn -= 2; - } - return x + w; -} - -TPT_INLINE void PIXELMETHODS_CLASS::xor_pixel(int x, int y) -{ - int c; - if (x<0 || y<0 || x>=XRES || y>=YRES) - return; - c = vid[y*(VIDXRES)+x]; - c = PIXB(c) + 3*PIXG(c) + 2*PIXR(c); - if (c<512) - vid[y*(VIDXRES)+x] = PIXPACK(0xC0C0C0); - else - vid[y*(VIDXRES)+x] = PIXPACK(0x404040); -} - -TPT_INLINE void PIXELMETHODS_CLASS::blendpixel(int x, int y, int r, int g, int b, int a) -{ - pixel t; - if (x<0 || y<0 || x>=VIDXRES || y>=VIDYRES) - return; - if (a!=255) - { - t = vid[y*(VIDXRES)+x]; - r = (a*r + (255-a)*PIXR(t)) >> 8; - g = (a*g + (255-a)*PIXG(t)) >> 8; - b = (a*b + (255-a)*PIXB(t)) >> 8; - } - vid[y*(VIDXRES)+x] = PIXRGB(r,g,b); -} - -TPT_INLINE void PIXELMETHODS_CLASS::addpixel(int x, int y, int r, int g, int b, int a) -{ - pixel t; - if (x<0 || y<0 || x>=VIDXRES || y>=VIDYRES) - return; - t = vid[y*(VIDXRES)+x]; - r = (a*r + 255*PIXR(t)) >> 8; - g = (a*g + 255*PIXG(t)) >> 8; - b = (a*b + 255*PIXB(t)) >> 8; - if (r>255) - r = 255; - if (g>255) - g = 255; - if (b>255) - b = 255; - vid[y*(VIDXRES)+x] = PIXRGB(r,g,b); -} - -void PIXELMETHODS_CLASS::xor_line(int x1, int y1, int x2, int y2) -{ - int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy; - float e, de; - if (cp) - { - y = x1; - x1 = y1; - y1 = y; - y = x2; - x2 = y2; - y2 = y; - } - if (x1 > x2) - { - y = x1; - x1 = x2; - x2 = y; - y = y1; - y1 = y2; - y2 = y; - } - dx = x2 - x1; - dy = abs(y2 - y1); - e = 0.0f; - if (dx) - de = dy/(float)dx; - else - de = 0.0f; - y = y1; - sy = (y1= 0.5f) - { - y += sy; - e -= 1.0f; - } - } -} - -void PIXELMETHODS_CLASS::xor_rect(int x, int y, int w, int h) -{ - int i; - for (i=0; iabs(x2-x1), x, y, dx, dy, sy; - float e, de; - if (cp) - { - y = x1; - x1 = y1; - y1 = y; - y = x2; - x2 = y2; - y2 = y; - } - if (x1 > x2) - { - y = x1; - x1 = x2; - x2 = y; - y = y1; - y1 = y2; - y2 = y; - } - dx = x2 - x1; - dy = abs(y2 - y1); - e = 0.0f; - if (dx) - de = dy/(float)dx; - else - de = 0.0f; - y = y1; - sy = (y1= 0.5f) - { - y += sy; - e -= 1.0f; - } - } -} - -void PIXELMETHODS_CLASS::drawrect(int x, int y, int w, int h, int r, int g, int b, int a) -{ - int i; - w--; - h--; - for (i=0; i<=w; i++) - { - blendpixel(x+i, y, r, g, b, a); - blendpixel(x+i, y+h, r, g, b, a); - } - for (i=1; i VIDYRES) h = (VIDYRES)-y; //Adjust height to prevent drawing off the bottom - if(a >= 255) - for (j=0; j>= 2; + bn -= 2; + } + return x + w; +} + +TPT_INLINE int PIXELMETHODS_CLASS::addchar(int x, int y, int c, int r, int g, int b, int a) +{ + int i, j, w, bn = 0, ba = 0; + char *rp = font_data + font_ptrs[c]; + w = *(rp++); + for (j=0; j>= 2; + bn -= 2; + } + return x + w; +} + +TPT_INLINE void PIXELMETHODS_CLASS::xor_pixel(int x, int y) +{ + int c; + if (x<0 || y<0 || x>=XRES || y>=YRES) + return; + c = vid[y*(VIDXRES)+x]; + c = PIXB(c) + 3*PIXG(c) + 2*PIXR(c); + if (c<512) + vid[y*(VIDXRES)+x] = PIXPACK(0xC0C0C0); + else + vid[y*(VIDXRES)+x] = PIXPACK(0x404040); +} + +TPT_INLINE void PIXELMETHODS_CLASS::blendpixel(int x, int y, int r, int g, int b, int a) +{ + pixel t; + if (x<0 || y<0 || x>=VIDXRES || y>=VIDYRES) + return; + if (a!=255) + { + t = vid[y*(VIDXRES)+x]; + r = (a*r + (255-a)*PIXR(t)) >> 8; + g = (a*g + (255-a)*PIXG(t)) >> 8; + b = (a*b + (255-a)*PIXB(t)) >> 8; + } + vid[y*(VIDXRES)+x] = PIXRGB(r,g,b); +} + +TPT_INLINE void PIXELMETHODS_CLASS::addpixel(int x, int y, int r, int g, int b, int a) +{ + pixel t; + if (x<0 || y<0 || x>=VIDXRES || y>=VIDYRES) + return; + t = vid[y*(VIDXRES)+x]; + r = (a*r + 255*PIXR(t)) >> 8; + g = (a*g + 255*PIXG(t)) >> 8; + b = (a*b + 255*PIXB(t)) >> 8; + if (r>255) + r = 255; + if (g>255) + g = 255; + if (b>255) + b = 255; + vid[y*(VIDXRES)+x] = PIXRGB(r,g,b); +} + +void PIXELMETHODS_CLASS::xor_line(int x1, int y1, int x2, int y2) +{ + int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy; + float e, de; + if (cp) + { + y = x1; + x1 = y1; + y1 = y; + y = x2; + x2 = y2; + y2 = y; + } + if (x1 > x2) + { + y = x1; + x1 = x2; + x2 = y; + y = y1; + y1 = y2; + y2 = y; + } + dx = x2 - x1; + dy = abs(y2 - y1); + e = 0.0f; + if (dx) + de = dy/(float)dx; + else + de = 0.0f; + y = y1; + sy = (y1= 0.5f) + { + y += sy; + e -= 1.0f; + } + } +} + +void PIXELMETHODS_CLASS::xor_rect(int x, int y, int w, int h) +{ + int i; + for (i=0; iabs(x2-x1), x, y, dx, dy, sy; + float e, de; + if (cp) + { + y = x1; + x1 = y1; + y1 = y; + y = x2; + x2 = y2; + y2 = y; + } + if (x1 > x2) + { + y = x1; + x1 = x2; + x2 = y; + y = y1; + y1 = y2; + y2 = y; + } + dx = x2 - x1; + dy = abs(y2 - y1); + e = 0.0f; + if (dx) + de = dy/(float)dx; + else + de = 0.0f; + y = y1; + sy = (y1= 0.5f) + { + y += sy; + e -= 1.0f; + } + } +} + +void PIXELMETHODS_CLASS::drawrect(int x, int y, int w, int h, int r, int g, int b, int a) +{ + int i; + w--; + h--; + for (i=0; i<=w; i++) + { + blendpixel(x+i, y, r, g, b, a); + blendpixel(x+i, y+h, r, g, b, a); + } + for (i=1; i VIDYRES) h = (VIDYRES)-y; //Adjust height to prevent drawing off the bottom + if(a >= 255) + for (j=0; j