summaryrefslogtreecommitdiff
path: root/src/graphics/Graphics.h
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-09-25 16:53:48 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-09-25 16:53:48 (GMT)
commit25d872ec48b6af1e6bc682bdaadca173926b07d1 (patch)
tree3c66cd4cf69ed2d8608e4bc702f6e6fed8a31528 /src/graphics/Graphics.h
parent8d9b351568250cbd59c6cc4d390f790d6699332c (diff)
downloadpowder-25d872ec48b6af1e6bc682bdaadca173926b07d1.zip
powder-25d872ec48b6af1e6bc682bdaadca173926b07d1.tar.gz
MacOS X targets for Scons, Fix some inlines for clang
Diffstat (limited to 'src/graphics/Graphics.h')
-rw-r--r--src/graphics/Graphics.h63
1 files changed, 59 insertions, 4 deletions
diff --git a/src/graphics/Graphics.h b/src/graphics/Graphics.h
index 2fab43a..c23400f 100644
--- a/src/graphics/Graphics.h
+++ b/src/graphics/Graphics.h
@@ -95,12 +95,67 @@ public:
VideoBuffer(const VideoBuffer & old);
VideoBuffer(VideoBuffer * old);
VideoBuffer(int width, int height);
- void BlendPixel(int x, int y, int r, int g, int b, int a);
- void AddPixel(int x, int y, int r, int g, int b, int a);
- void SetPixel(int x, int y, int r, int g, int b, int a);
+ TPT_INLINE void BlendPixel(int x, int y, int r, int g, int b, int a)
+ {
+ #ifdef PIX32OGL
+ pixel t;
+ if (x<0 || y<0 || x>=Width || y>=Height)
+ return;
+ if (a!=255)
+ {
+ t = Buffer[y*(Width)+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;
+ a = a > PIXA(t) ? a : PIXA(t);
+ }
+ Buffer[y*(Width)+x] = PIXRGBA(r,g,b,a);
+ #else
+ pixel t;
+ if (x<0 || y<0 || x>=Width || y>=Height)
+ return;
+ if (a!=255)
+ {
+ t = Buffer[y*(Width)+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;
+ }
+ Buffer[y*(Width)+x] = PIXRGB(r,g,b);
+ #endif
+ }
+
+ TPT_INLINE void SetPixel(int x, int y, int r, int g, int b, int a)
+ {
+ if (x<0 || y<0 || x>=Width || y>=Height)
+ return;
+ #ifdef PIX32OGL
+ Buffer[y*(Width)+x] = PIXRGBA(r,g,b,a);
+ #else
+ Buffer[y*(Width)+x] = PIXRGB((r*a)>>8, (g*a)>>8, (b*a)>>8);
+ #endif
+ }
+
+ TPT_INLINE void AddPixel(int x, int y, int r, int g, int b, int a)
+ {
+ pixel t;
+ if (x<0 || y<0 || x>=Width || y>=Height)
+ return;
+ t = Buffer[y*(Width)+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;
+ Buffer[y*(Width)+x] = PIXRGB(r,g,b);
+ }
+ int SetCharacter(int x, int y, int c, int r, int g, int b, int a);
int BlendCharacter(int x, int y, int c, int r, int g, int b, int a);
int AddCharacter(int x, int y, int c, int r, int g, int b, int a);
- int SetCharacter(int x, int y, int c, int r, int g, int b, int a);
~VideoBuffer();
};